Statistical Rethinking: A Bayesian Course with Examples in R and Stan builds your knowledge of and confidence in making inferences from data. Reflecting the need for scripting in today's model-based statistics, the book pushes you to perform step-by-step calculations that are usually automated. This unique computational approach ensures that you understand enough of the details to make reasonable choices and interpretations in your own modeling work.

The text presents causal inference and generalized linear multilevel models from a simple Bayesian perspective that builds on information theory and maximum entropy. The core material ranges from the basics of regression to advanced multilevel models. It also presents measurement error, missing data, and Gaussian process models for spatial and phylogenetic confounding.

The second edition emphasizes the directed acyclic graph (DAG) approach to causal inference, integrating DAGs into many examples. The new edition also contains new material on the design of prior distributions, splines, ordered categorical predictors, social relations models, cross-validation, importance sampling, instrumental variables, and Hamiltonian Monte Carlo. It ends with an entirely new chapter that goes beyond generalized linear modeling, showing how domain-specific scientific models can be built into statistical analyses.


  • Integrates working code into the main text
  • Illustrates concepts through worked data analysis examples
  • Emphasizes understanding assumptions and how assumptions are reflected in code
  • Offers more detailed explanations of the mathematics in optional sections
  • Presents examples of using the dagitty R package to analyze causal graphs
  • Provides the rethinking R package on the author's website and on GitHub

chapter 1|18 pages

The Golem of Prague

chapter 2|30 pages

Small Worlds and Large Worlds

chapter 3|22 pages

Sampling the Imaginary

chapter 4|52 pages

Geocentric Models

chapter 5|38 pages

The Many Variables & The Spurious Waffles

chapter 6|30 pages

The Haunted DAG & The Causal Terror

chapter 7|46 pages

Ulysses’ Compass

chapter 8|26 pages

Conditional Manatees

chapter 9|36 pages

Markov Chain Monte Carlo

chapter 10|23 pages

Big Entropy and the Generalized Linear Model

chapter 11|45 pages

God Spiked the Integers

chapter 12|30 pages

Monsters and Mixtures

chapter 13|35 pages

Models With Memory

chapter 14|53 pages

Adventures in Covariance

chapter 15|36 pages

Missing Data and Other Opportunities

chapter 16|27 pages

Generalized Linear Madness

chapter 17|3 pages