Closed VLucet closed 11 months ago
Sure thing! The function flocker::flocker_stancode
will output the generated Stan code like brms::make_stancode
. For any fitted flocker model fm
you can also see the stancode via fm$model
(this is just like brms
). Note that you can also see the formatted Stan data via flocker::flocker_standata
, which is a replacement for brms::make_standata
, and you can see the default prior with flocker::get_flocker_prior
which replaces brms::get_prior
.
The best place to orient yourself to the general strategy of how this works internally is the vignette here https://jsocolar.github.io/flocker/articles/flocker_format.html. The best guide to the likelihoods themselves is probably the preprint here https://www.biorxiv.org/content/10.1101/2023.10.26.564080v1
Afterwards, you can look at make_flocker_data.R
to see how the data gets packaged, and make_occupancy_lpmf.R
to see how the Stan code gets made. occupancy_families.R
contains the custom family definitions, and flock.R
contains the fitting function itself (as well as functions for outputting generated stancode, generated standata and default priors). The rest of the package is data simulation, post-processing, and utility functions.
Thanks for the pointers @jsocolar
Finally, a package which implements all the marginalizations needed to run occupancy models in stan, with the power of brms! Really awesome. I am really interested in how all of it works under the hood. Could you give me some pointers as to how to properly inspect the internals of the package and the produced brms/Stan code? Any pointers would be greatly appreciated.