Statistical Rethinking with PyMC#

Welcome to the Statistical Rethinking with PyMC interactive textbook companion! This resource brings Richard McElreath’s exceptional Statistical Rethinking course to Python developers.

πŸ“š About This Project#

Statistical Rethinking is an incredible resource for learning Bayesian Statistics, written by Richard McElreath, Full Professor of Anthropology at the Max Planck Institute for Evolutionary Anthropology.

What Makes This Different#

The original textbook uses R and Stan for its code examples. The core PyMC development team created Python ports of these examples, and we’ve taken it one step further:

✨ Each notebook includes comprehensive summaries of the textbook material alongside the Python code, eliminating the need to constantly switch between the book and notebooks.

This approach makes Statistical Rethinking accessible to anyone proficient in Python, reducing friction and making your learning journey as seamless as possible.

🎯 What You’ll Learn#

  • Bayesian Thinking: Build intuition for probabilistic reasoning

  • PyMC Modeling: Hands-on experience with modern Bayesian tools

  • Causal Inference: Understand DAGs and causal relationships

  • Practical Skills: Apply these techniques to real-world data

πŸš€ How to Use This Book#

Online Reading#

Navigate through chapters using the sidebar. Each chapter includes:

  • πŸ“– Detailed explanations of statistical concepts

  • πŸ’» Python/PyMC code implementations

  • πŸ“Š Visualizations and examples

  • πŸŽ“ Exercises to test your understanding

Interactive Coding#

Every notebook can be opened in Google Colab! Just click the Colab button at the top of any chapter to:

  • Run code interactively

  • Modify examples

  • Experiment with your own data

Local Development#

Clone the repository to work offline:

git clone https://github.com/vanislekahuna/Statistical-Rethinking-PyMC.git
cd Statistical-Rethinking-PyMC

πŸ“‹ Prerequisites#

To get the most from this material:

  • Python: Basic understanding of Python syntax

  • NumPy/Pandas: Familiarity with these libraries is helpful

  • Statistics: Some exposure helpful, but Bayesian knowledge not required!

  • Curiosity: A genuine interest in understanding data through a Bayesian lens

πŸ—ΊοΈ Course Structure#

The book follows Richard McElreath’s textbook structure:

Part I: Foundations

  • Chapters 1-3: Bayesian basics and sampling

  • Chapter 4: Linear models

Part II: Linear Models

  • Chapters 5-8: Multiple regression, causality, interactions

Part III: Generalized Linear Models

  • Chapters 9-11: MCMC, maximum entropy, count data

Part IV: Advanced Topics

  • Chapters 12-17: Multilevel models, measurement error, missing data

🎬 Getting Started#

Ready to begin your Bayesian journey? Head to Chapter 1: The Golem of Prague to start learning!

πŸ™ Acknowledgments#

This work builds upon:

  • Richard McElreath: For the incredible original textbook and course

  • PyMC Team: For porting the R/Stan code to Python

  • Community Contributors: Everyone who has helped improve these materials

πŸ“– Reference#

McElreath, R. (2020). Statistical Rethinking: A Bayesian Course with Examples in R and Stan (2nd ed.). CRC Press.

πŸ”— Additional Resources#


Questions or feedback? Open an issue on our GitHub repository