McElreath’s Statistical Rethinking provides a function to see the Stan code behind his convenience functions (rethinking::stancode()
), but he doesn’t focus on how to work directly with stanfit
objects.
As an exercise, I have translated the examples from his book directly into Stan code, and extracted the information from stanfit objects using R and tidyverse/ggplot2 to recreate McElreath’s graphics too.
The code is organized in R Markdown files by chapter. I’d be happy to contribute.