Flexible Occupancy Estimation with Stan
Overview
Fit occupancy models in 'Stan' via 'brms'. The full variety of 'brms' formula-based effects structures are available to use in multiple classes of occupancy model, including single-season models, models with data augmentation for never-observed species, dynamic (multiseason) models with explicit colonization and extinction processes, and dynamic models with autologistic occupancy dynamics. Formulas can be specified for all relevant distributional terms, including detection and one or more of occupancy, colonization, extinction, and autologistic depending on the model type. Several important forms of model post-processing are provided. References: Bürkner (2017) doi:10.18637/jss.v080.i01; Carpenter et al. (2017) doi:10.18637/jss.v076.i01; Socolar & Mills (2023) doi:10.1101/2023.10.26.564080.
- Added the
twolevel_singlemodel family for single-season occupancy models in which groups of closure units may themselves be structurally absent. Users specify the grouping factor withlevel2_group, may supply a separate table of group-level predictors withlevel2_covs, and model group-level occupancy withf_meta. - Refactored the data-augmented model as a special case of the general two-level model, with shared data formatting, likelihood, fitting, and post-processing machinery.
- Breaking change for augmented models: every species supplied in the original
obsarray must have at least one detection. Never-observed pseudospecies must instead be added throughn_aug. - Breaking change for augmented models:
get_Z()now returns a list containingunitstates for species-site combinations andlevel2states for species. Generic two-level models use the same return structure. Joint samples from the two levels are mutually consistent.
Show all changes in 1.1-0Hide the rest of the changes in 1.1-0
- Two-level outputs from
get_Z(),log_lik_flocker(), andloo_flocker()now retain user-supplied group names. Augmented models similarly retain supplied species names and assign stable names to augmented pseudospecies. - Improved the numerical stability of two-level log-likelihood calculations by evaluating occupancy mixtures in log space.
- Corrected backward smoothing and backward sampling of latent states from multiseason models so that both use the appropriate transition probabilities and future-data likelihoods.
- Corrected history-conditioned
get_Z()calculations for augmented models and when usingnew_data, including rep-constant models. Augmented group-level probabilities now marginalize over unit occupancy and incorporate the fitted group-level occupancy probability. - Fixed expansion of user-supplied unit and event covariates in
simulate_flocker_data()so that values are shared across species at each unit or visit, and allowedmake_flocker_data()to accept data-frame observation inputs as documented. - Fixed reconstruction of maximally ragged observation and covariate arrays, including multiseason data with a final season that is unobserved in every series, and made post-processing robust when exactly one posterior draw is requested.
- Fitted models and formatted data objects are now tagged with the version of
flockerthat created them. Two-level packing metadata is stored separately from the underlyingbrmsfitdata.
From NEWS.md in the release
Install
Health
- OK13 OK2026-10-20
- ERROR12 OK, 1 ERROR2026-09-04
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
Show 6 earlier changesHide 6 earlier changes
- ERROR12 OK, 1 ERROR2026-06-08
- OK13 OK2026-05-10
- WARNING12 OK, 1 WARNING2026-05-09
- OK14 OK2026-04-22
- ERROR13 OK, 1 ERROR2026-04-18
- OK14 OK2026-03-10
Documentation
The repository also keeps web-only articles.
- Help pages
- 21
- Examples that run
- 50%8 run in a plain check · 1 only when donttest examples are enabled (R CMD check --as-cran) · 7 never run
- Exported functions with examples
- 84%
- Documented parameters
- 100%
- Return-value docs
- 95%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 95%
- Median days to close, 50 most recently updated closed issues
- 36
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Issues over time
PRs over time
Commits over time
9 development-tooling and community-health practices detected across 5 families in the upstream repository
Checks run against github.com/jsocolar/flocker on 2026-10-21.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-16 · The repository has a site deploy workflow
Show all practicesHide 1 practice
Dependencies
Installing flocker adds 73 packages (35 with compiled code, 75 MB of source tarballs). Heaviest: BH 14 MB, stringi 11 MB, ggplot2 6.0 MB.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 1.1-0Latest2026-10-16 · current release · diff ↗ ··
added 1 export
make_flocker_data_twolevel_singlelisted once in CRAN's queue
Seen in one reading of CRAN's incoming queue, at 2026-10-16 02:28 UTC, so it stayed less than the time between readings. - 1.0-2
- RR 4.6.0 released · 2026-04-24
- RR 4.5.0 released · 2025-04-11
- RR 4.4.0 released · 2024-04-24
- 1.0-02024-02-05
- RR 4.3.0 released · 2023-04-21
Package metadata
- First published
- 2024-02-05
- Total releases
- 3 / 2 yrs
- License
- BSD_3_clause + file LICENSE OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 3.8 KB / 1 file
- Download size
- 6.1 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("flocker")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-25, which the citation names so these numbers can be found later. More on citing and the projects behind them.