This function fits closed population abundance models for ``traditional'' capture-mark-recapture data consisting of a single mark type using Bayesian analysis methods. Markov chain Monte Carlo (MCMC) is used to draw samples from the joint posterior distribution.
markClosed(
Enc.Mat,
covs = data.frame(),
mod.p = ~1,
parms = c("pbeta", "N"),
nchains = 1,
iter = 12000,
adapt = 1000,
bin = 50,
thin = 1,
burnin = 2000,
taccept = 0.44,
tuneadjust = 0.95,
proppbeta = 0.1,
propzp = 1,
propsigmap = 1,
npoints = 500,
a = 25,
mu0 = 0,
sigma2_mu0 = 1.75,
initial.values = NULL,
printlog = FALSE,
...
)
A list containing the following:
Markov chain Monte Carlo object of class mcmc.list
.
Model formula for detection probability (as specified by mod.p
above).
Formula always NULL
; only for internal use in multimodelClosed
.
A list of design matrices for detection probability generated for model mod.p
, where DM$p is the design matrix for initial capture probability (p) and DM$c is the design matrix for recapture probability (c).
A list containing the parameter and latent variable values at iteration iter
for each chain. Values are provided for "pbeta
", "zp
", "sigma2_zp
", and "N
".
An object of class multimarksetup
A matrix of observed encounter histories with rows corresponding to individuals and columns corresponding to sampling occasions. With a single mark type, encounter histories consist of only non-detections (0) and type 1 encounters (1).
A data frame of temporal covariates for detection probabilities (ignored unless mms=NULL
). The number of rows in the data frame must equal the number of sampling occasions. Covariate names cannot be "time", "age", or "h"; these names are reserved for temporal, behavioral, and individual effects when specifying mod.p
and mod.phi
.
Model formula for detection probability. For example, mod.p=~1
specifies no effects (i.e., intercept only), mod.p~time
specifies temporal effects, mod.p~c
specifies behavioral reponse (i.e., trap "happy" or "shy"), mod.p~h
specifies individual heterogeneity, and mod.p~time+c
specifies additive temporal and behavioral effects.
A character vector giving the names of the parameters and latent variables to monitor. Possible parameters are logit-scale detection probability parameters ("pbeta
"), population abundance ("N
"), logit-scale individual heterogeneity variance term ("sigma2_zp
"), and logit-scale individual effects ("zp
"). The log posterior density ("logPosterior
") may also be monitored. Setting parms="all"
monitors all possible parameters and latent variables.
The number of parallel MCMC chains for the model.
The number of MCMC iterations.
The number of iterations for proposal distribution adaptation. If adapt = 0
then no adaptation occurs.
Bin length for calculating acceptance rates during adaptive phase (0 < bin <= iter
).
Thinning interval for monitored parameters.
Number of burn-in iterations (0 <= burnin < iter
).
Target acceptance rate during adaptive phase (0 < taccept <= 1
). Acceptance rate is monitored every bin
iterations. Default is taccept = 0.44
.
Adjustment term during adaptive phase (0 < tuneadjust <= 1
). If acceptance rate is less than taccept
, then proposal term (proppbeta
, propzp
, or propsigmap
) is multiplied by tuneadjust
. If acceptance rate is greater than or equal to taccept
, then proposal term is divided by tuneadjust
. Default is tuneadjust = 0.95
.
Scaler or vector (of length k) specifying the initial standard deviation of the Normal(pbeta[j], proppbeta[j]) proposal distribution. If proppbeta
is a scaler, then this value is used for all j = 1, ..., k. Default is proppbeta = 0.1
.
Scaler or vector (of length M) specifying the initial standard deviation of the Normal(zp[i], propzp[i]) proposal distribution. If propzp
is a scaler, then this value is used for all i = 1, ..., M individuals. Default is propzp = 1
.
Scaler specifying the initial Gamma(shape = 1/propsigmap
, scale = sigma_zp * propsigmap
) proposal distribution for sigma_zp = sqrt(sigma2_zp). Default is propsigmap=1
.
Number of Gauss-Hermite quadrature points to use for numerical integration. Accuracy increases with number of points, but so does computation time.
Scale parameter for [sigma_z] ~ half-Cauchy(a) prior for the individual hetegeneity term sigma_zp = sqrt(sigma2_zp). Default is ``uninformative'' a = 25
.
Scaler or vector (of length k) specifying mean of pbeta[j] ~ Normal(mu0[j], sigma2_mu0[j]) prior. If mu0
is a scaler, then this value is used for all j = 1, ..., k. Default is mu0 = 0
.
Scaler or vector (of length k) specifying variance of pbeta[j] ~ Normal(mu0[j], sigma2_mu0[j]) prior. If sigma2_mu0
is a scaler, then this value is used for all j = 1, ..., k. Default is sigma2_mu0 = 1.75
.
Optional list of nchain
list(s) specifying initial values for "pbeta
", "zp
", "sigma2_zp
", and "N
". Default is initial.values = NULL
, which causes initial values to be generated automatically.
Logical indicating whether to print the progress of chains and any errors to a log file in the working directory. Ignored when nchains=1
. Updates are printed to log file as 1% increments of iter
of each chain are completed. With >1 chains, setting printlog=TRUE
is probably most useful for Windows users because progress and errors are automatically printed to the R console for "Unix-like" machines (i.e., Mac and Linux) when printlog=FALSE
. Default is printlog=FALSE
.
Additional "parameters
" arguments for specifying mod.p
. See make.design.data
.
Brett T. McClintock
The first time markClosed
(or markCJS
) is called, it will likely produce a firewall warning alerting users that R has requested the ability to accept incoming network connections. Incoming network connections are required to use parallel processing as implemented in markClosed
. Note that setting parms="all"
is required for any markClosed
model output to be used in multimodelClosed
.
multimodelClosed
# \donttest{
# This example is excluded from testing to reduce package check time
# Example uses unrealistically low values for nchain, iter, and burnin
#Run single chain using the default model for simulated ``traditional'' data
data<-simdataClosed(delta_1=1,delta_2=0)$Enc.Mat
sim.dot<-markClosed(data)
#Posterior summary for monitored parameters
summary(sim.dot$mcmc)
plot(sim.dot$mcmc)# }
Run the code above in your browser using DataLab