Nonspatial or spatial open-population analyses are performed on data formatted for `secr'. Several parameterisations are provided for the nonspatial Jolly-Seber Schwarz-Arnason model (`JSSA', also known as `POPAN'). Corresponding spatial models are designated `JSSAsecr'. The prefix `PLB' (Pradel-Link-Barker) is used for versions of the JSSA models that are conditional on the number observed. Cormack-Jolly-Seber (CJS) models are also fitted.
openCR.fit (capthist, type = "CJS", model = list(p~1, phi~1, sigma~1),
distribution = c("poisson", "binomial"), mask = NULL,
detectfn = c("HHN", "HHR", "HEX", "HAN", "HCG", "HVP", "HPX"), binomN = 0,
movementmodel = c('static', 'BVN', 'BVE', 'BVT', 'RDE', 'RDG','RDL','IND', 'UNI',
'BVNzi', 'BVEzi', 'RDEzi', 'INDzi', 'UNIzi'), edgemethod =
c("truncate", "wrap", "none"), kernelradius = 30, sparsekernel = TRUE,
start = NULL, link = list(), fixed = list(), stratumcov = NULL,
sessioncov = NULL, timecov = NULL, agecov = NULL, dframe = NULL,
dframe0 = NULL, details = list(), method = "Newton-Raphson", trace = NULL,
ncores = NULL, stratified = FALSE, ...)
If details$LLonly == TRUE
then a numeric vector is returned with logLik in
position 1, followed by the named coefficients.
Otherwise, an object of class `openCR' with components
function call
saved input (unique histories; see covariates(capthist)$freq for frequencies)
saved input
saved input
saved input
saved input
saved input
saved input
saved input
saved input
saved input
relative positions of move.a and move.b arguments
coordinates of kernel (movement models only)
vector of starting values for beta parameters
saved input
saved input
saved input
saved input
saved input
saved input
saved input
saved input
saved input
saved input (NULL replaced with default)
reduced design matrices, parameter table and parameter
index array for actual animals (see openCR.design
)
reduced design matrices, parameter table and parameter
index array for `naive' animal (see openCR.design
)
list with one component for each real parameter giving the indices of the `beta' parameters associated with each real parameter
intervals between primary sessions
vector of unique variable names in model
names of beta parameters
names of fitted (real) parameters
name of each primary session
list describing the fit (output from nlm
or
optim
)
variance-covariance matrix of beta parameters
vector of eigenvalue corresponding to each beta parameter
openCR version number
character string of date and time at start of fit
processor time for model fit, in seconds
The environment variable RCPP_PARALLEL_NUM_THREADS is updated with the
value of ncores
if provided.
capthist
object from `secr'
character string for type of analysis (see Details)
list with optional components, each symbolically
defining a linear predictor for the relevant real parameter using
formula
notation. See Details for names of real parameters.
character distribution of number of individuals detected
single-session mask
object; required for spatial (secr) models
character code
integer code for distribution of counts (see secr.fit
)
character; model for movement between primary sessions (see Details)
character; method for movement at edge of mask (see Details)
integer; radius in mask cells of discretized kernel (movement models only)
logical; if TRUE then only cardinal and intercardinal axes are included
vector of initial values for beta parameters, or fitted model(s) from which they may be derived
list with named components, each a character string in {"log", "logit", "loglog", "identity", "sin", "mlogit"} for the link function of the relevant real parameter
list with optional components corresponding to each `real' parameter, the scalar value to which parameter is to be fixed
optional dataframe of values of stratum-specific covariate(s).
optional dataframe of values of session-specific covariate(s).
optional dataframe of values of occasion-specific covariate(s).
optional dataframe of values of age-specific covariate(s)
optional data frame of design data for detection parameters (seldom used)
optional data frame of design data for detection parameters of naive (undetected) animals (seldom used)
list of additional settings (see Details)
character string giving method for maximizing log likelihood
logical or integer; output log likelihood at each evaluation, or at some lesser frequency as given
integer number of cores for parallel processing (see Details)
logical; if TRUE then sessions of capthist interpreted as indpendent strata
other arguments passed to join()
The permitted nonspatial models are CJS, Pradel, Pradelg, JSSAbCL = PLBb, JSSAfCL = PLBf, JSSAgCL = PLBg, JSSAlCL = PLBl, JSSAb, JSSAf, JSSAg, JSSAl, JSSAB and JSSAN.
The permitted spatial models are CJSsecr, JSSAsecrbCL = PLBsecrb, JSSAsecrfCL = PLBsecrf, JSSAsecrgCL = PLBsecrg, JSSAsecrlCL = PLBsecrl, JSSAsecrb, JSSAsecrf, JSSAsecrg, JSSAsecrl, JSSAsecrB, JSSAsecrN, secrCL, and secrD.
See openCR-vignette.pdf for a table of the `real' parameters associated with each model type.
Parameterisations of the JSSA models differ in how they include recruitment: the core parameterisations express recruitment either as a per capita rate (`f'), as a finite rate of increase for the population (`l' for lambda) or as per-occasion entry probability (`b' for the classic JSSA beta parameter, aka PENT in MARK). Each of these models may be fitted by maximising either the full likelihood, or the likelihood conditional on capture in the Huggins (1989) sense, distinguished by the suffix `CL'. Full-likelihood JSSA models may also be parameterized in terms of the time-specific absolute recruitment (BN, BD) or the time-specific population size(N) or density (D).
`secrCL' and `secrD' are closed-population spatial models.
Data are provided as secr `capthist' objects, with some restrictions. For nonspatial analyses, `capthist' may be single-session or multi-session, with any of the main detector types. For spatial analyses `capthist' should be a single-session dataset of a point detector type (`multi', `proximity' or `count') (see also details$distribution below). In openCR the occasions of a single-session dataset are treated as open-population temporal samples except that occasions separated by an interval of zero (0) are from the same primary session (multi-session input is collapsed to single-session if necessary).
model
formulae may include the pre-defined terms
`session',`Session', `h2', and `h3' as in secr. `session'
is the name given to primary sampling times in `secr', so a fully
time-specific CJS model is list(p ~ session, phi
~ session)
. `t' is a synonym of `session'. `Session' is for a
trend over sessions. `h2' and `h3' allow finite mixture models.
Learned (behavioural) responses (`b', `B', etc.) were redefined and extended in version 1.3.0. The vignette should be consulted for current definitions.
Formulae may also include named occasion-specific and session-specific covariates in the dataframe arguments `timecov' and `sessioncov' (occasion = secondary session of robust design). Named age-specific covariates in 'agecov` are treated similarly. Individual covariates present as an attribute of the `capthist' input may be used in CJS and ..CL models. Groups are not supported in this version, but may be implemented via a factor-level covariate in ..CL models.
distribution
specifies the distribution of the number of
individuals detected; this may be conditional on the population size (or number in the
masked area) ("binomial") or unconditional ("poisson").
distribution
affects the sampling variance of the estimated
density. The default is "poisson" as in secr.
Movement models are list at Movement models. Their use is described in the vignette.
edgemethod
controls movement probabilities at the mask edge in spatial models that include movement. "none" typically causes bias in estimates; "wrap" wraps kernel probabilities to the opposing edge of a rectangular mask; "truncate" scales the values of an edge-truncated kernel so that they always sum to 1.0 (safer and more general than "wrap").
The mlogit link function is used for the JSSA (POPAN) entry parameter
`b' (PENT in MARK) and for mixture proportions, regardless of link
.
Spatial models use one of the hazard-based detection functions (see detectfn
) and require data
from independent point detectors (secr detector types `multi', `proximity' or `count').
Code is executed in multiple threads unless the user specifies ncores = 1
or there is only one core available or details$R == TRUE
. Setting ncores = NULL
uses the existing value from the environment variable RCPP_PARALLEL_NUM_THREADS (see setNumThreads
) or 2 if that has not been set.
Optional stratification was introduced in openCR 2.0.0. See openCR-vignette.pdf for details.
The ... argument may be used to pass a vector of unequal intervals to
join (interval
), or to vary the tolerance for merging detector sites (tol
).
The start
argument may be
In the case of two fitted models, the values are melded. This is handy for initialising an open spatial model from a closed spatial model and an open non-spatial model. If a beta parameter appears in both models then the first is used.
details
is a list used for various specialized settings --
Component | Default | Description |
agebreaks | minimumage:maximumage | Limits of age classes (vector passed to cut ) |
autoini | 1 | Number of the session used to determine initial values of D, lambda0 and sigma (secr types only) |
CJSp1 | FALSE | Modified CJS model including initial detection (estimable with robust design and many spatial models) |
contrasts | NULL | Value suitable for the `contrasts.arg' argument
of model.matrix used to specify the coding of factor predictors |
control | list() | Components may be named arguments of nlm , or passed intact as argument `control' of optim - useful for increasing maxit for method = Nelder-Mead (see vignette) |
debug | 0 | debug=1 prints various intermediate values; debug>=2 interrupts execution by calling browser() (position variable) |
fixedbeta | NULL | Vector with one element for each coefficient (beta parameter) in the model. Only 'NA' coefficients will be estimated; others will be fixed at the value given (coefficients define a linear predictor on the link scale). The number and order of coefficients may be determined by calling openCR.fit with trace = TRUE and interrupting execution after the first likelihood evaluation. |
grain | 1 | Obscure setting for multithreading - see RcppParallel package |
hessian | "auto" | Computation of the Hessian matrix from which variances and covariances are obtained. Options are "none" (no variances), "auto" or "fdhess" (use the function fdHess in nlme). If "auto" then the Hessian from the optimisation function is used. |
ignoreusage | FALSE | Overrides usage in traps object of capthist |
initialage | 0 | Numeric (uniform age at first capture)
or character value naming an individual covariate; see age.matrix |
initialstratum | 1 | Number of stratum to use for finding default starting values (cf autoini in secr) |
LLonly | FALSE | TRUE causes the function to return a single evaluation of the log likelihood at the initial values, followed by the initial values |
minimumage | 0 | Sets a minimum age; see age.matrix |
maximumage | 1 | Sets a maximum age; older animals are recycled into
this age class; see age.matrix |
multinom | FALSE | Include the multinomial constant in the reported log-likelihood. |
r0 | 0.5 | effective radius of zero cell in movement kernel (multiple of cell width) |
R | FALSE | Switch from the default C++ code to slower functions in native R (useful for debugging; not all models) |
squeeze | TRUE | Apply squeeze to capthist before analysis. Non-spatial models fit faster, because histories often non-unique. |
userdist | NULL | Function to compute distances (see secr) |
stepmax | NULL | stepmax argument of nlm (step on link scale) |
If method = "Newton-Raphson"
then nlm
is
used to maximize the log likelihood (minimize the negative log
likelihood); otherwise optim
is used with the
chosen method ("BFGS", "Nelder-Mead", etc.). If maximization fails a
warning is given appropriate to the method. method = "none"
may
be used to compute or re-compute the variance-covariance matrix at
given starting values (i.e. providing a previously fitted model as
the value of start
).
Parameter redundancies are common in open-population models. The output
from openCR.fit
includes the singular values (eigenvalues) of the
Hessian - a useful post-hoc indicator of redundancy (e.g., Gimenez et
al. 2004). Eigenvalues are scaled so the largest is 1.0. Very small
scaled values represent redundant parameters - in my experience with
simple JSSA models a threshold of 0.00001 seems effective.
[There is an undocumented option to fix specific `beta' parameters.]
Numeric ages may be grouped into age classes by providing `agebreaks'. In models, ~age then refers to the age-class factor. See the vignette for more detail.
Gimenez, O., Viallefont, A., Catchpole, E. A., Choquet, R. and Morgan, B. J. T. (2004) Methods for investigating parameter redundancy. Animal Biodiversity and Conservation 27, 561--572.
Huggins, R. M. (1989) On the statistical analysis of capture experiments. Biometrika 76, 133--140.
Pledger, S., Efford, M., Pollock. K., Collazo, J. and Lyons, J. (2009) Stopover duration analysis with departure probability dependent on unknown time since arrival. In: D. L. Thompson, E. G. Cooch and M. J. Conroy (eds) Modeling Demographic Processes in Marked Populations. Springer. Pp. 349--363.
Pledger, S., Pollock, K. H. and Norris, J. L. (2010) Open capture--recapture models with heterogeneity: II. Jolly-Seber model. Biometrics 66, 883--890.
Pradel, R. (1996) Utilization of capture-mark-recapture for the study of recruitment and population growth rate. Biometrics 52, 703--709.
Schwarz, C. J. and Arnason, A. N. (1996) A general methodology for the analysis of capture-recapture experiments in open populations. Biometrics 52, 860--873.
classMembership.openCR
,
derived.openCR
,
openCR.design
,
par.openCR.fit
,
predict.openCR
,
summary.openCR
if (FALSE) {
## CJS default
openCR.fit(ovenCH)
## POPAN Jolly-Seber Schwarz-Arnason, lambda parameterisation
L1 <- openCR.fit(ovenCH, type = 'JSSAl')
predict(L1)
JSSA1 <- openCR.fit(ovenCH, type = 'JSSAf')
JSSA2 <- openCR.fit(ovenCH, type = 'JSSAf', model = list(phi~t))
JSSA3 <- openCR.fit(ovenCH, type = 'JSSAf', model = list(p~t,phi~t))
AIC (JSSA1, JSSA2, JSSA3)
predict(JSSA1)
RMdata <- RMarkInput (join(reduce(ovenCH, by = "all")))
if (require(RMark)) {
MarkPath <- 'c:/Mark/'
if (!all (nchar(Sys.which(c('mark.exe', 'mark64.exe', 'mark32.exe'))) < 2)) {
openCHtest <- process.data(RMdata, model = 'POPAN')
openCHPOPAN <- mark(data = openCHtest, model = 'POPAN',
model.parameters = list(p = list(formula = ~1),
pent = list(formula = ~1),
Phi = list(formula = ~1)))
popan.derived(openCHtest, openCHPOPAN)
cleanup(ask = FALSE)
} else message ("mark.exe not found")
} else message ("RMark not found")
}
Run the code above in your browser using DataLab