For those interested in Bayesian models and probabilistic coding, I’m starting a new series on coding in STAN. We’ve done a lot of Bayesian coding in this blog, often with {rstanarm}, {bmrs}, and coding empirical Bayesian models by hand. We’ve also done a little bit with {PyMC3}, from the Python coding language.
STAN offers us a lot more flexibility to specify whatever model we want and full autonomy of the priors we can place on the various parameters. It is a little challenging given it is coming out of the C++ coding language. So, we will start slow and build up. This first post will simply be about how to code a STAN model and extract information from it. We will progress to building more complex models, modeling different outcome distributions, building hierarchical models, evaluating model diagnostics, and making predictions from the model.
I’m going to work with the {rstan} and {cmdstanr} packages to allow us to use R as our coding language and then call the C++ compiler when we need to fit the model. Along the way I’ll also provide some Jupyter Notebooks and show how to code stand models in Python using {cmdstanpy}, a Python analog for {cmdstanr} that allows us to run our same STAN models in Python.
In order to not repeat everything here in the blog, I’ll simply update the blog with links to my github repo for each new section so that all of the code is accessible and housed in one place.
Click here to read the RMarkdown Blog Article >> STAN Part 1 – Intro to STAN Code
Click here to access the code >> STAN Part 1 – Intro to STAN Code

