For each replicate, simulate.secr calls sim.popn to
generate session- and group-specific realizations of the (possibly
inhomogeneous) 2-D Poisson distribution fitted in object, across
the habitat mask(s) in object. Group subpopulations are combined
using rbind.popn within each session; information to
reconstruct groups is retained in the individual-level factor
covariate(s) of the resulting popn object (corresponding to
object$groups). Each population is then sampled using the fitted
detection model and detector (trap) array(s) in object.
The random number seed is managed as in simulate.lm.
Certain model types are not supported by simulate.secr. These
include models fitted using conditional likelihood (object$CL =
TRUE), telemetry models and exotic behavioural response models.
Detector type is determined by detector(traps(object$capthist)).
sim.secr is a wrapper function. If data = NULL (the
default) then it calls simulate.secr to generate nsim new datasets. If
data is provided then nsim is taken to be
length(data). secr.fit is called to fit the original model
to each new dataset. Results are summarized according to the
user-provided function extractfn. The default extractfn
returns the deviance and its degrees of freedom; a NULL value for
extractfn returns the fitted secr objects after
trimming to reduce bulk. Simulation uses the detector type
of the data, even when another likelihood is fitted (this is the case
with single-catch data, for which a multi-catch likelihood is fitted).
Warning messages from secr.fit are suppressed.
extractfn should be a function that takes an secr object
as its only argument.
tracelevel=0 suppresses most messages; tracelevel=1 gives a
terse message at the start of each fit; tracelevel=2 also sets
`details$trace = TRUE' for secr.fit, causing each likelihood
evaluation to be reported.
hessian controls computation of the Hessian matrix from which
variances and covariances are obtained. hessian replaces the
value in object\$details. Options are "none" (no variances),
"auto" (the default) or "fdhess" (see secr.fit). It is OK
(and faster) to use hessian="none" unless extractfn needs
variances or covariances. Logical TRUE and FALSE are interpreted by
secr.fit as "auto" and "none".
If ncores > 1 the parallel package is used to create
processes on multiple cores (see Parallel for more) and progress
messages are suppressed. New datasets are generated in the master
process, so there is no need to manage the random number streams
in the worker processes.
sim.capthist is a more direct way to simulate data from a null
model (i.e. one with constant parameters for density and detection), or
from a time-varying model.
sim.detect is a function used internally that will not usually be
called directly.