Occupancy modeling in Stan

The purpose of this post is to raise awareness of my occupancy modeling work with RStan, help people find my work, and seek out possible collaborators to help other avoid reinventing the wheel. I also hope others would please add links to your own tutorials on occupancy modeling with Stan.

I am writing a set of tutorials on doing Occupancy Modeling with RStan. The tutorials are on GitHub (link here). I am also in the process of putting the tutorials into an R Package (currently in rough shape on GitHub). My long term goal is to put all of the tutorials as Vignettes in the R Package.

I am motivated for my project by environmental DNA (eDNA) occupancy modeling (or occupancy modeling with sub-sampling). The models require at least 3-levels: Molecular detection (e.g., did qPCR detect the eDNA?); Sample capture (e.g., did you get eDNA in your water bottle?); and Site-level occupancy (e.g., is eDNA at the site?). I am currently working with USGS and USFWS scientists who use these 3-level models for their work and my tutorials builds up to them, starting with glm() in R before moving to Stan and occupancy models.

I have found that @jsocolar has posted a nice tutorial comparing JAGS to RStan (and @jsocolar, I invite you (and anyone else!) to collaborate with me on my projects). I also know that @mbjoseph has a nice tutorial on Dynamic occupancy models in Stan and a paper using SEM models with occupancy models in Stan.


Nice! Happy to hear this @Richard_Erickson. Note that my blog post is now directing folks to the BPA Stan implementations: https://github.com/stan-dev/example-models/tree/master/BPA


I am very interested also to see any development of occupancy models with brms or rstanarm.


1 Like

@Manuel I’m doing my own project independent of those. However, the package will avoid making people compile their own models (or serve as a starting place if they do want to create their!).

@Richard_Erickson that´s great. I will be very interested on see that. I am not very good on programming so I feel more confortable with brms.

Thanks for posting. We can also provide a link in our external references page on our web site (where we link books and tutorials on Stan).

Also, I wrote a case study on the Dorazio and Royle (2006) model:


1 Like

Thank you @Bob_Carpenter. Once I get things more polished, I’ll seek to promote it on your resources page.

As another resource: I recently learned about this package: Bayesian Models for Data from Unmarked Animals using Stan • ubms (kenkellner.com)

1 Like