ip.secr (capthist, predictorfn = pfn, predictortype = "null",
detectfn = 0, mask = NULL, start = NULL, boxsize = 0.1,
centre = 3, min.nsim = 10, max.nsim = 2000, CVmax = 0.002,
var.nsim = 1000, maxbox = 5, maxtries = 2, ncores = 1, ...)
pfn(capthist, N.estimator)
ip.secr
, a list comprisingpfn
, a vector of numeric values corresponding to $\hat{N}$, $\hat{p}$, and
RPSV
, a measure of the spatial scale of individual detections.predictorfn(capthist)
(the target vector) and statistics
from simulations of a 2-D population using the postulated detection
model. Statistics (see Note) are defined by the predictor function,
which should return a vector equal in length to the number of parameters
(np = 3). Simulations of the 2-D population use sim.popn
.
The simulated population is sampled with sim.capthist
according to the detector type (e.g., `single' or `multi') and detector
layout specified in traps(capthist), including allowance for varying
effort if the layout has a usage
attribute.
...may be used to control aspects of the simulation by passing named
arguments (other than D) to sim.popn
. The most important arguments of
sim.popn
to keep an eye on are `buffer' and `Ndist'. `buffer'
defines the region over which animals are simulated (unless mask
is specified) - the region should be large enough to encompass all
animals that might be caught. `Ndist' controls the number of individuals
simulated within the buffered or masked area. The default is `poisson'.
Use `Ndist = fixed' to fix the number in the buffered or masked area
$A$ at $N = DA$. This conditioning reduces the estimated
standard error of $\hat{D}$, but conditioning is not always
justified - seek advice from a statistician if you are unsure.
The simulated 2-D distribution of animals is Poisson by default. There
is no `even' option as in Density.
Simulations are conducted on a factorial experimental design in
parameter space - i.e. at the vertices of a cuboid `box' centred on the
working values of the parameters, plus an optional number of centre
points. The size of the `box' is specified as a fraction of the working
values, so for example the limits on the density axis are D*(1--boxsize)
and D*(1+boxsize) where D* is the working value of D. For g0, this
computation uses the odds transformation (g0/(1--g0)). boxsize
may be a vector defining different scaling on each parameter dimension.
A multivariate linear model is fitted to predict each set of simulated
statistics from the known parameter values. The number of simulations at
each design point is increased (doubled) until the residual standard
error divided by the central value is less than CVmax for all
parameters. An error occurs if max.nsim is exceeded.
Once a model with sufficient precision has been obtained, a new working
vector of parameter estimates is `predicted' by inverting the linear
model and applying it to the target vector. A working vector
is accepted as the final estimate when it lies within the box; this
reduces the bias from using a linear approximation to extrapolate a
nonlinear function. If the working vector lies outside the box then a new
design is centred on value for each parameter in the working vector.
Once a final estimate is accepted, further simulations are conducted to
estimate the variance-covariance matrix. These also provide a parametric
bootstrap sample to evaluate possible bias. Set var.nsim = 0
to suppress the variance step.
See Efford et al. (2004) for another description of the method, and
Efford et al. (2005) for an application.
The value of predictortype
is passed as the second argument of
the chosen predictorfn
. By default this is pfn
, for which
the second argument (N.estimator
) is a character value from
c("n", "null","zippin","jackknife"), corresponding respectively to the
number of individuals caught (Mt+1), and $\hat{N}$ from
models M0, Mh and Mb of Otis et al. (1978).
If not provided, the starting values are determined automatically
with autoini
.
Linear measurements are assumed to be in metres and density in animals
per hectare (10 000 $\mbox{m}^2$).
If ncores > 1
the capthist
, secr.fit
, RPSV
, autoini
,
sim.popn
, detection functions
## these calculations may take several minutes
## default settings
ip.secr (captdata)
## coarse initial fit, no variance step
ip1 <- ip.secr (captdata, boxsize = 0.2, CVmax=0.01, var=0)
## refined fit
ip2 <- ip.secr (captdata, start = ip1$IP[,"estimate"],
boxsize = 0.1, CVmax=0.002, var=1000)
ip2
## compare to MLE of same data using multi-catch assumption
predict(secrdemo.0)
## improvise another predictor function (dbar instead of RPSV)
pfn2 <- function (capthist, v) { ## v is not used
sumni <- sum(capthist!=0) ## total detections
n <- nrow(capthist) ## number of individuals
nocc <- ncol(capthist) ## number of occasions
c(N = n, p = sumni/n/nocc, dbar = dbar(capthist))
}
ip.secr (captdata, predictorfn = pfn2)
Run the code above in your browser using DataLab