The materials used in the tutorial are available here.
The Stan project implements a probabalistic programming language, a library of mathematical and statistical
functions, and a variety of algorithms to estimate statistical models in order to make Bayesian inferences
from data. The three main sections of this tutorial will
Modern Bayesian Inference (55 minutes, followed by a 5 minute break)
Using the rstanarm, shinystan, and loo packages for Bayesian Inference (55 minutes, followed by a 5 minute break)
Sampling from Arbitrary Posterior Distributions Defined in the Stan Language Using the rstan Package (60 minutes)
stan()function in the rstan package
Tutorial participants should have a good understanding of probability theory in order to utilize the various probability density functions and probability mass functions that are available in Stan. Participants should also be familiar with frequentist model-fitting functions in R such as
glm. Ideally, participants would also be familiar with functions that fit models with group-specific terms, such as
glmer in the lme4 package, but this is not absolutely required.
It is not necessary to have any previous experience with Stan, although anyone who has previous experience with the BUGS family (WinBUGS, JAGS, OpenBUGS, etc.) is likely ready to learn Stan. We would ask that all tutorial participants read in advance these two sample chapters
from Richard McElreath’s 2016 book Statistical Rethinking: A Bayesian Course with Examples in R and Stan, which has been published by Chapman and Hall / CRC Press.
Getting the rstan package to work is not as simple as it is for most R packages because Stan requires a C++ toolchain. A few days before the tutorial, please follow the instructions at
to install a C++ toolchain for your operating system and the latest version of the rstan package and its suggested R packages. At that point, installing the latest version of the rstanarm R package is straightforward via
which will also install the loo and shinystan R packages. Any questions about installation can be posted to
The tutorial will utilize the RStudio IDE, so we highly suggest installing its latest version along with the knitr and rmarkdown packages. Although we will not discuss them in detail, participants may also be interested in the rethinking package (which can be installed with
devtools::install_github("rmcelreath/rethinking")) and / or the brms package (which can be installed with
install.packages("brms")), which can generate a Stan program from R syntax and then draw from its posterior distribution.
Ben Goodrich is a core developer of the Stan project and a frequent contributor to both the Stan Users Google Group (660+ threads) and the Stan Developer Google Group (705+ threads). He is the maintainer of two Stan-related R packages that will be heavily used in this tutorial, a coauthor of a forthcoming article on Stan in the Journal of Statistical Software, and a Lecturer at Columbia University where he teaches graduate classes in quantitative methodology, including a masters-level course based on Stan entitled “Bayesian Statistics for the Social Sciences” (3 times). He is supported in part by a grant from the Sloan Foundation to build the Stan community and to ensure that the Stan project thrives over the long-term.