Skip to contents

Single, 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:

  • whichObserver names 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-occasion type="response" prediction is itself conditional on that; multiplying by type.fitted = "onempall0" (P(captured on at least one occasion)) converts it back to an unconditional, marginal probability for that one occasion.

  • whichObserver = "any": returns onempall0 directly – the probability that at least one of the modeled occasions/detectors detects the call. This is the union detection probability, and needs only one VGAM::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, as pDetInArea()'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 to model@extra$whichObserver (and, matching that existing default's own fallback, the last modeled column if that's also NULL).

na.action

Passed to VGAM::predict(). Default stats::na.pass, so a newdata$SNR containing NA (as pDetInArea()'s truncated transects do) comes back as NA in the same row rather than being dropped and silently shifting every row after it.

Value

A numeric vector of detection probabilities, one per row of newdata.