Predict detection probability from a fitted vglm CR model
Source:R/predictDetFun.R
vglmDetectionProb.RdSingle, shared implementation of vglm/posbernoulli.t prediction, used by
both predictDetFun.vglm() and pDetInArea()'s vglm branch –
previously duplicated verbatim in both places, which is exactly how they
could silently drift apart.
Two modes:
whichObservernames one modeled occasion/observer column: returns that observer's own marginal detection probability. VGAM's posbernoulli models are fit by conditional likelihood (conditioning on "captured on at least one occasion", since all-zero capture histories are unobservable), so the raw per-occasiontype="response"prediction is itself conditional on that; multiplying bytype.fitted = "onempall0"(P(captured on at least one occasion)) converts it back to an unconditional, marginal probability for that one occasion.whichObserver = "any": returnsonempall0directly – the probability that at least one of the modeled occasions/detectors detects the call. This is the union detection probability, and needs only oneVGAM::predict()call rather than two, since the per-occasion matrix and column selection aren't needed at all.
Usage
vglmDetectionProb(
model,
newdata,
whichObserver = model@extra$whichObserver,
na.action = stats::na.pass
)Arguments
- model
A fitted vglm object from
fitDetFun(modelType = "vglm")(or a copy of one with swapped coefficients, aspDetInArea()'s parametric bootstrap uses).- newdata
Data.frame with a column
SNR.- whichObserver
Either the name of one modeled occasion/observer column, or
"any"for the union (at-least-one) probability. Defaults tomodel@extra$whichObserver(and, matching that existing default's own fallback, the last modeled column if that's alsoNULL).- na.action
Passed to
VGAM::predict(). Defaultstats::na.pass, so anewdata$SNRcontainingNA(aspDetInArea()'s truncated transects do) comes back asNAin the same row rather than being dropped and silently shifting every row after it.