flocker logo

The flocker R package enables users to fit flexible occupancy models using the extended lme4 formula syntax provided by R package brms. Also included are functions to format data for occupancy modeling and functions for model post-processing, including posterior predictions, the posterior distribution of the latent true occupancy state, and model comparison. flocker is under active development: development priorities include better direct functionality for posterior predictive checking and implementation of dynamic (multiseason) occupancy models and N-mixture models.

Compared to existing R packages for fitting occupancy models, flocker is substantially more flexible in the variety of single-season models that can be fit, and contains advanced functionality for model comparison and checking.

Getting started

To get started, check out our tutorial vignette, available here. For installation instructions, see below.

Installation

Install flocker in R with

# install.packages("remotes")
remotes::install_github("jsocolar/flocker")

flocker requires a working version of either Rstan or cmdstan, which are interfaces to Stan, a state-of-the-art the probabilistic programming language. We recommend using cmdstan if possible. To do so, first install R package cmdstanr with

install.packages("cmdstanr", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

You must additionally install cmdstan itself. We strongly recommend using cmdstanr to manage the cmdstan installation:

cmdstanr::install_cmdstan()

If using Rstan, we strongly recommend installing the development version rather than the CRAN version. In a fresh R session, do

# Uncomment the next line if you have previously installed rstan
# remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

Both Rstan and cmdstan require a working C++ toolchain, which has posed occasional complications for Stan users. See here for Rstan-focused advice on installing the toolchain, and see here for cmdstan-focused advice. If you encounter toolchain issues that you are unable to troubleshoot, ask for help at https://discourse.mc-stan.org/.

Bugs, features, contributions

To request a feature or report a bug (much appreciated!) please open an issue at the GitHub repository. To contribute to flocker (very much appreciated!) have a look at existing open issues, or open a new issue to discuss.

Citing flocker

Please cite flocker as: * Socolar, J.B. & Mills, S.C. (2021). “flocker: flexible occupancy estimation in R.” R package version XXX, <URL: https://github.com/jsocolar/flocker/>.

Additionally, please consider citing Stan and R package brms.