A repository of worked problems and examples from Statistical Rethinking, 2nd Edition (McElreath, 2020), mainly in Julia and R.
This repository was created out of a desire to better understand Bayesian statistics by learning from Richard McElreath's Statistical Rethinking textbook. Here, you will find (in progress!) worked problems and example from the text. Statistical Rethinking's language of choice is R, but this repo also attempts to replicate some of the book using Julia.
The code in this repo is organized by book chapter. Within each chapter folder is code for both the textbook examples and problems, in each language.
- The Golem of Prague (no code)
- Small Worlds and Large Worlds
The programming environments used to work through Statistical Rethinking can be recreated using the following methods:
The R environment is managed with renv. To recreate the
environment locally, simply open statistical-rethinking.Rproj
in Rstudio then
run:
renv::restore()
and the rest should be taken care of. One pacakge, Rstan, may require additional setup described on the Rstan Getting Started Wiki. Another package of note is the companion package for this textbook: rethinking.
The Julia environment is managed by the native package manager and included
Project.toml
file. The environment can be activated by setting Julia's
working directory to this repo then running either:
julia> using Pkg; Pkg.activate(pwd()) # From the Julia REPL
or
pkg> activate . # From the package REPL (type `]` in the Julia REPL)
Note: this repository uses the 2nd edition of the book, published in March, 2020.