install.packages("cmdstanr",
repos = c("https://mc-stan.org/r-packages/",
getOption("repos")))Software and packages
There are numerous options for Bayesian scientific computing, including probabilistic programming languages. I will be using Stan, as it offers cross-platform support and uses Hamiltonian Monte Carlo. JAGS has very good automatic differentiation, but relies on Gibbs sampling. Other interfaces are platform-specific: below is a list of the main software (R, Python and Julia), along with associated packages.
R
The R programming language contains many packages on the Comprehensive R Archive Network (CRAN) dedicated for Bayesian analysis; see the CRAN Task View
Among the packages worth exploring are NIMBLE (https://r-nimble.org/), which allows for different samplers.
To install all R packages used throughout the course, use the command
I also use priorsense, bayesplot and loo. Good high-level interface include brms.
For beginners (without knowledge of Markov chain Monte Carlo), the packages bang + rust, and rethinking from McElreath (2020) are useful.
- The
INLAR package(https://www.r-inla.org/), which uses integrated nested Laplace approximations (INLA) for inference in latent Gaussian models, is not on the CRAN.
install.packages("BiocManager")
BiocManager::install("graph")
BiocManager::install("Rgraphviz")
install.packages(
"INLA",
repos = c(getOption("repos"),
INLA = "https://inla.r-inla-download.org/R/stable"),
dep = TRUE)I have bundled many datasets used in class in a R package available from this Github repository:
# Download databases for course
remotes::install_github("lbelzile/hecbayes")Python
Python can be installed through the uv package manager, which I recommend over other alternatives.
Beyond Stan via CmdStanPy, the most popular Python library for Bayesian data analysis is PyMC.
Julia
The Julia Programming Language (https://julialang.org/) has numerous packages for Bayesian analysis, including notably