BoccSS: Bayesian single-season occupancy modelling

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/BoccSS.R


Functions to estimate occupancy from detection/non-detection data for a single season using a Gibbs sampler coded in R or JAGS.

BoccSS0 runs a model in R without covariates, and allows priors to be specified as beta distributions for probability of occupancy and probability of detection.

BoccSS runs a model in R allowing for covariates, using a probit link and conjugate normal priors, which can be specified as mean and covariance.


BoccSS0(y, n, psiPrior=c(1,1), pPrior=c(1,1),
                    chains=3, sample=30000, burnin=100)

BoccSS(DH, model=NULL, data=NULL, priors=list(),
                    chains=3, sample=30000, burnin=1000, thin=1, parallel,
                    seed=NULL, doWAIC=FALSE)



a vector with the number of detections at each site.


a scalar or vector with the number of visits (survey occasions) at each site.

psiPrior, pPrior

parameters for beta distributions to be used as priors for psi and p.


a 1/0/NA matrix (or data frame) of detection histories, sites x occasions.


a list of formulae symbolically defining a linear predictor for each parameter in terms of covariates. If NULL, an intercept-only model is used, ie, psi(.) p(.).


a data frame containing the variables in the model. For occSStime, a data frame with a row for each survey occasion; otherwise, a row for each site. Each site covariate has one column. Each survey covariate has one column for each occasion, and the column name must end with the occasion number (without leading zeros); eg, Cov1, Cov2, ..., Cov15. All covariates should be included in data, otherwise they will be sought in enclosing environments, which may not produce what you want – and they won't be standardised.


a list with elements for prior mean and variance for coefficients; see Details. If NULL, improper flat priors are used.


number of MCMC chains to run.


minimum number of values to return. The actual number will be a multiple of the number of chains.


number of iterations per chain to discard as burn-in.


the thinning interval between consecutive values in the sample


logical; if TRUE and n.chains > 1 and available cores (as returned by parallel::detectCores) > 2, chains will be run in parallel. If missing, chains will be run in parallel if n.chains < available cores.


logical; if TRUE, the Watanabe-Akaike Information Criterion is calculated. NOTE: THIS FEATURE IS STILL EXPERIMENTAL.


for reproducible results; note that parallel and sequential methods use different random number generators, so will give different results with the same seed.


BoccSS0 implements a simple model with one parameter for probability of occupancy and one for probability of detection, ie. a psi(.) p(.) model, using a Gibbs sampler implemented in R.

Independent beta distributions are used as priors for BoccSS0, as specified by psiPrior and pPrior. The defaults, c(1, 1), correspond to uniform priors on the probabilities of occupancy and detection.

BoccSS uses a probit link to model occupancy and detection as a function of covariates (Dorazio and Rodriguez 2011); most software uses a logistic (logit) link. See Links. Coefficients on the probit scale are about half the size of the equivalent on the logit scale.

Priors for BoccSS are listed in the priors argument, which may contain elements:

muPsi and muP : the means for occupancy and detection coefficients respectively. This may be a vector with one value for each coefficient, including the intercept, or a scalar, which will be used for all. The default is 0.

sigmaPsi and sigmaP : the (co)variance for occupancy and detection coefficients respectively. This may be (1) a vector with one value for each coefficient, including the intercept, which represents the variance, assuming independence, or (2) a scalar, which will be used for all, or (3) a variance-covariance matrix. The default is 100.

When specifying priors, note that numerical covariates are standardized internally before fitting the model. For an intercept-only model, a prior of Normal(0, 1) on the probit scale implies a Uniform(0, 1) or Beta(1, 1) prior on the probability scale.

If you are unsure of the order of predictors, do a short run and check the output, or pass unusable values (eg, muPsi=numeric(100)) and check the error message.


Returns an object of class Bwiqid, which is a data frame with a column for each parameter in the model.

There are print and plot methods for class Bwiqid, as well as diagnostic plots.


Mike Meredith. BoccSS uses the Gibbs sampler described by Dorazio and Rodriguez (2012).


MacKenzie, D I; J D Nichols; A J Royle; K H Pollock; L L Bailey; J E Hines 2006. Occupancy estimation and modeling : inferring patterns and dynamics of species occurrence. Elsevier Publishing.

Dorazio and Rodriguez. 2012. A Gibbs sampler for Bayesian analysis of site-occupancy data. Methods in Ecology and Evolution, 3, 1093-1098

See Also

See the examples for the weta data set.


# The blue ridge salamanders data from MacKenzie et al (2006) p99:
y <- rowSums(salamanders)
n <- rowSums(!

tmp <- BoccSS0(y, n)
occSS0(y, n)  # for comparison

wiqid documentation built on May 19, 2017, 11:18 p.m.

Search within the wiqid package
Search all R packages, documentation and source code