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.

1 2 3 4 5 6 |

`y` |
a vector with the number of detections at each site. |

`n` |
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. |

`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 |

`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. |

`sample` |
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 sample |

`parallel` |
logical; if TRUE |

`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. |

`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 the examples for the `weta`

data set.

1 2 3 4 5 6 7 8 9 | ```
# 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)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.