BoccSS: Bayesian single-season occupancy modelling

View source: R/BoccSS.R

Bayesian Occupancy Single SeasonR Documentation

Bayesian single-season occupancy modelling

Description

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.

Usage

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

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

Arguments

y

a vector with the number of detections at each site; or a 1/0/NA matrix (or data frame) of detection histories, sites x occasions.

n

a scalar or vector with the number of visits (survey occasions) at each site; ignored if y is a matrix or data frame.

psiPrior, pPrior

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

DH

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

model

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(.).

data

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.

priors

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

chains

number of MCMC chains to run.

draws

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

burnin

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

thin

the thinning interval between consecutive values in the chain.

parallel

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.

doWAIC

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

seed

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

...

other arguments to pass to the function.

Details

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 site covariates or survey covariates, as specified by model(Dorazio and Rodriguez 2011). It includes a built in .time covariate which can be used for modelling p with time as a fixed effect, and .Time, .Time2, .Time3 for a linear, quadratic or cubic trend. A built-in .b covariate corresponds to a behavioural effect, where detection depends on whether the species was detected on the previous occasion or not.

Note that 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 1, which for a probit link and standardized covariates is only mildly informative.

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.

Value

Returns an object of class mcmcOutput.

Author(s)

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

References

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.

Examples

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

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

wiqid documentation built on Nov. 18, 2022, 1:07 a.m.