scr-stan icon indicating copy to clipboard operation
scr-stan copied to clipboard

Spatial capture-recapture models in Stan

scr-stan: spatial capture-recapture examples in Stan

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

The goal of scr-stan is to provide Stan implementations for a variety of spatial capture-recapture models described in the book Spatial Capture-Recapture by Royle, Chandler, Gardner, and Sollmann. The emphasis is on translating models from JAGS to Stan.

Why?

Stan is a flexible language that enables full Bayesian inference with dynamic Hamiltonian Monte Carlo, approximate Bayesian inference with automatic differentiation variational inference, and optimization (e.g., penalized maximum likelihood).

There are some good reasons to use Stan:

Using Stan can be hard for ecologists with experience in JAGS/BUGS/NIMBLE, because you have to marginalize over discrete parameters. But, you don't have to start from scratch. This repo provide a variety of examples, and if you've never marginalized over discrete parameters to implement a model in Stan, you might find this tutorial helpful.

Hopefully these Stan implementations lower the barrier to entry.

Dependencies

These examples use the scrbook R package, which you can download from here: https://sites.google.com/site/spatialcapturerecapture/scrbook-r-package

The remaining dependencies are on CRAN, and you can install them from R with:

devtools::install_deps()

What's here

This repo contains a bunch of Stan translations of JAGS models provided in the SCR book. Each example is a self-contained R script, and one or two Stan files.

  • Chapter 5: fully spatial capture-recapture models
  • Chapter 6: likelihood analysis of spatial capture-recapture models
  • Chapter 7: variation in encounter probability
  • Chapter 8: model selection and assessment
  • Chapter 9: alternative observation models
  • Chapter 11: spatial variation in density
  • Chapter 14: stratified populations: multi-session and multi-site data
  • Chapter 15: models for search-encounter data
  • Chapter 16: open population models

Inspiration

This repo was built in the spirit of the Hiroki Itô's excellent Stan translations of "Bayesian Population Analysis using WinBUGS --- A Hierarchical Perspective" (2012) by Marc Kéry and Michael Schaub.

Contributing

If you have questions or find any issues, feel free to open an issue on GitHub: https://github.com/mbjoseph/scr-stan/issues