chat {secr} | R Documentation |
Activity centres may be clumped (overdispersed) relative to a Poisson distribution,
the model used in secr.fit
(Borchers and Efford 2008). This can cause
the sampling variance of density estimates to be understated. One solution currently under investigation is to apply a variance inflation factor, a measure of overdispersion, based on the number of individuals detected at each detector (Bischof et al. 2020).
Functions described here compute the observed (nk) or expected (Enk) number of individuals detected at each detector and use that to compute Fletcher's \hat c
estimate of overdispersion
for use as a variance inflation factor.
Enk
uses exact formulae for 'multi', 'proximity' and 'count' detector types. Other types may be simulated by setting a positive value for 'nrepl', which should be large (e.g., nrepl = 10000).
adjustVarD
adjusts the SE and confidence limits of density estimates
using Fletcher's \hat c
. The implementation is limited to simple detection models
(see Warnings).
See Cooch and White (2022) for an introduction to measurement of overdispersion in capture–recapture. The focus here is on overdispersion of activity centres relative to a Poisson distribution, rather than on non-independence in the spatial detection process.
nk(capthist)
Enk(D, mask, traps, detectfn = 0, detectpar = list(g0 = 0.2,
sigma = 25, z = 1), noccasions = NULL, binomN = NULL,
userdist = NULL, ncores = NULL, nrepl = NULL)
chat.nk(object, nsim = NULL, ...)
adjustVarD(object, chatmin = 1, alpha = 0.05, chat = NULL)
capthist |
secr |
D |
numeric density, either scalar or vector of length nrow(mask) |
mask |
single-session habitat mask |
traps |
|
detectfn |
integer code for detection function q.v. |
detectpar |
a named list giving a value for each parameter of detection function |
noccasions |
number of sampling intervals (occasions) |
binomN |
integer code for discrete distribution (see
|
userdist |
user-defined distance function or matrix (see userdist) |
ncores |
integer number of threads |
nrepl |
integer number of replicates for E(nk) by simulation (optional) |
object |
fitted secr model or dataframe (see Warnings for restrictions) |
nsim |
integer number of c-hat values to simulate (optional) |
... |
other arguments passed to |
chatmin |
minimum value of Fletcher's |
alpha |
alpha level for confidence intervals |
chat |
numeric chat (optional) |
If traps
has a usage attribute then noccasions
is
set accordingly; otherwise it must be provided.
The environment variable RCPP_PARALLEL_NUM_THREADS determines the number of
parallel threads. It is set to the value of ncores
, unless that is NULL
(see setNumThreads
).
A conventional variance inflation factor due to Wedderburn (1974) is
\hat c_X = X^2/(K-p)
where K
is the number of detectors, p
is the number of estimated parameters, and
X^2 = \sum_k (n_k - E (n_k))^2/ E(n_k).
Fletcher's \hat c
is an improvement on \hat c_X
that is less affected
by small expected counts. It is defined by
\hat c = c_X / (1+ \bar s),
where \bar s = \sum_k s_k / K
and s_k = (n_k - E(n_k)) / E(n_k)
.
chat.nk
may be used to simulate \hat c
values under the given model (set nsim > 0). The ... argument may include 'ncores = x' (x>1) to specify parallel processing of simulations - the speed up is large on unix-like machines for which the cluster type of makeCluster
is "FORK" rather than "PSOCK". If 'ncores' is not provided then the value returned by setNumThreads()
is used.
No adjustment is made by adjustVarD
when \hat c
is less than the
minimum. adjustVarD
by default computes Fletcher's ‘chat’ using chat.nk
,
but a value may be provided.
If chat has been computed separately and provided in the argument of that name, adjustVarD
also accepts a single dataframe as the argument ‘object’; the dataframe should have row ‘D’ and columns ‘link’, ‘estimate’, ‘SE.estimate’ as in the output from predict.secr
.
For nk
, a vector of observed counts, one for each detector in traps(capthist)
.
For Enk
, a vector of expected counts, one for each detector in traps
.
For chat.nk
, usually a list comprising –
expected.nk |
expected number at each detector |
nk |
observed number at each detector |
stats |
vector of summary statistics: mean(expected.nk), var(expected.nk), mean(nk), var(nk), nu (=df), X2/nu |
chat |
|
There are two variations –
If ‘verbose = FALSE’ then only the numeric value of \hat c
is returned (a vector of 2 values if ‘type = "both"’).
If chat.nk
is called with ‘nsim > 0’ then the output is a list comprising –
type |
from input |
nsim |
from input |
sim.chat |
vector of simulated |
chat |
|
p |
probability of observing |
For adjustVarD
, a dataframe with one row for each session, based on predict.secr
or derived.secr
, with extra column ‘c-hat’.
These functions are experimental in secr 4.6, and do not work with polygon-like and single-catch detectors. No allowance is made for modelled variation in detection parameters with respect to occasion, detector or animal; this includes mixture models (e.g., g0~h2).
Versions before 4.5.11 did not correctly compute expected counts for multi-catch detectors.
Furthermore, we doubt that the adjustment actually solves the problem of overdispersion (Efford and Fletcher unpubl.).
Bischof, R., P. Dupont, C. Milleret, J. Chipperfield, and J. A. Royle. 2020. Consequences of ignoring group association in spatial capture–recapture analysis. Wildlife Biology wlb.00649. DOI 10.2981/wlb.00649
Cooch, E. and White, G. (eds) (2022) Program MARK: A Gentle Introduction. 22nd edition. Most recent edition available online at www.phidot.org/software/mark/docs/book/.
Fletcher, D. (2012) Estimating overdispersion when fitting a generalized linear model to sparse data. Biometrika 99, 230–237.
Wedderburn, R. W. M. (1974) Quasi-likelihood functions, generalized linear models, and the Gauss-Newton method. Biometrika 61, 439–47.
secr
,
make.mask
,
Detection functions
,
Fletcher.chat
temptrap <- make.grid()
msk <- make.mask(temptrap)
## expected number of individuals per detector (multi-catch)
Enk (D = 5, msk, temptrap, detectpar = list(g0 = 0.2, sigma = 25),
noccasions = 5)
# useful plotting function for simulated chat (nsim>0)
plotchat <- function(chat, head = '', breaks = seq(0.5,2.5,0.05)) {
hist(chat$sim.chat, xlim = range(breaks), main = head, xlab = 'c-hat',
breaks = breaks, cex.main = 1, yaxs = 'i')
abline(v = chat$chat, lwd = 1.5, col = 'blue')
}