# Statistical Rethinking: A Bayesian Course Using CmdStanPy and Plotnine

## Intro

This repo contains the `python`

/`stan`

version of the Statistical Rethinking course that Professor Richard McElreath taught on the Max Planck Institute for Evolutionary Anthropology in Leipzig during the Winter of 2019/2020. The original repo for the course, from which this repo is forked, can be found here. The course contains 20 lectures structured in 10 weeks with a series of assignments for each week. The course is an excellent introduction to bayesian modelling in general and to the Rethinking Statistics wonderful book written by Professor McElreath.

## How to use this repo

There are ten `jupyter`

notebooks, one for each week of the course. At the beginning of each notebook there are links to the youtube videos of the lectures, the slides used and the original homework questions and answers in `R`

.

How I would use this repo is like this:

- Go to the notebook of the week.
- Watch the two videos for the lectures of that week. Their URL are at the very top of each notebook.
- Read the original problems presented to the students and try to solve them on your own.
- Follow the exercises solutions of the notebook with my code and explanations by Professor McElreath.

`CmdStanPy`

Installing The `stan`

code is executed thanks to `CmdStanPy`

. CmdStanPy is a lightweight pure-Python interface to CmdStan which provides access to the Stan compiler and all inference algorithms. It provides the function `install_cmdstan()`

which downloads CmdStan from GitHub and builds the CmdStan utilities. It can be can be called from within Python or from the command line.

```
import cmdstanpy
cmdstanpy.install_cmdstan()
```

You can found more information about the installation process here.

## Other useful resources

There are a lot of very useful resources for bayesian statistical modelling out there. Specifically centered on Professor McElreath work I would mention:

## Copyright

The present work is a derivative work of Statistical Rethinking: A Bayesian Course Using python and pymc3 by Gabriel Bosque Chacon and Statistical Rethinking: A Bayesian Course Using Python and NumPyro by Andrés Suárez. I made the stan code, the plotnine figures and slightly modifications to his comments.