Statistical Rethinking: A Bayesian Course with Examples in R and STAN, 2nd Edition (Hardback) book cover

Statistical Rethinking

A Bayesian Course with Examples in R and STAN, 2nd Edition

By Richard McElreath

Chapman and Hall/CRC

598 pages

Purchasing Options:$ = USD
Hardback: 9780367139919
pub: 2020-03-17
SAVE ~$19.99
Available for pre-order. Item will ship after 17th March 2020

FREE Standard Shipping!


The very popular Statistical Rethinking: A Bayesian Course with Examples in R and Stan, Second Edition builds readers’ knowledge of and confidence in statistical modeling. Reflecting the need for even minor programming in today’s model-based statistics, the book pushes readers to perform step-by-step calculations that are usually automated. This unique computational approach ensures that readers understand enough of the details to make reasonable choices and interpretations in their own modeling work.

The main changes in the second edition are:

  • Map2stan has been replaced by ulam. The new ulam is also much more flexible, mainly because it does not make any assumptions about GLM structure and allows explicit variable types within the formula list.
  • Most modeling examples have some prior predictive simulation. This is the most useful addition to the second edition as it helps understanding not only priors but the model itself.
  • Chapter 5 on multiple regression has been split into two chapters. The first chapter focuses on helpful aspects of regression. The second focuses on ways that it can mislead.
  • Chapter 4 now ends with B-splines. The chapter on count models, Chapter 11, now includes an item-response (factor analytic) example. Chapter 12 contains a survival analysis with censoring. Chapter 14 has an example of a phylogenetic distance regression. The new Chapter 16 focuses on models that are not easily conceived of as GLMMs.
  • There are new data examples such as the Japanese cherry blossoms historical time series and a larger primate evolution data set with 300 species and a matching phylogeny.
  • There are several places where raw Stan model code is explained inside optional boxes. This makes the transition to working directly in Stan easier but the main text remains R script using the rethinking package’s teaching tools.


"The first edition (and this second edition) of *Statistical Rethinking* beautifully outlines the key steps in the statistical analysis cycle, starting from formulating the research question. I find that many statistics textbooks omit the issue of problem formulation and either jump into data acquisition or further into analysis after the fact. McElreath has created a fantastic text for students of applied statistics to not only learn about the Bayesian paradigm, but also to gain a deep appreciation for the statistical thought process. I also found that many students appreciated McElreath’s engaging writing style and humor, and personally found the infusion of humor quite refreshing."

~Adam Loy, Carleton College

"(The chapter) ‘Generalized Linear Madness’ represents another great chapter of an even better edition of an already awesome textbook."

~Benjamin K. Goodrich, Columbia University

"(Chapter 16) is a worthy concluding chapter to a masterful book. Eminently readable and enjoyable. Brimful of small thought-provoking bits which may inspire deeper studies, but first and foremost a window on the trial and error process involved in building a statistical model or rather, indeed, any scientific theory."

~Josep Fortiana Gregori, University of Barcelona

"I do regard the manuscript as technically correct, clearly written, and at an appropriate level of difficulty. The technical approaches and the R codes of the book are perfect for our students. They can learn concepts of Bayesian models, data analysis, and model validation methods through using the R codes. The codes help students to have better understanding of the models and data analysis process."

~Nguyet Nguyen, Youngstown State University

Table of Contents

Preface to the Second Edition



Teaching strategy

How to use this book

Installing the rethinking R package


Chapter 1. The Golem of Prague

Statistical golems

Statistical rethinking

Tools for golem engineering


Chapter 2. Small Worlds and Large Worlds

The garden of forking data

Building a model

Components of the model

Making the model go



Chapter 3. Sampling the Imaginary

Sampling from a grid-appromate posterior

Sampling to summarize

Sampling to simulate prediction



Chapter 4. Geocentric Models

Why normal distributions are normal

A language for describing models

Gaussian model of height

Linear prediction

Curves from lines



Chapter 5. The Many Variables & The Spurious Waffles

Spurious association

Masked relationship

Categorical variables



Chapter 6. The Haunted DAG & The Causal Terror


Post-treatment bias

Collider bias

Confronting confounding



Chapter 7. Ulysses’ Compass

The problem with parameters

Entropy and accuracy

Golem Taming: Regularization

Predicting predictive accuracy

Model comparison



Chapter 8. Conditional Manatees

Building an interaction

Symmetry of interactions

Continuous interactions



Chapter 9. Markov Chain Monte Carlo

Good King Markov and His island kingdom

Metropolis Algorithms

Hamiltonian Monte Carlo

Easy HMC: ulam

Care and feeding of your Markov chain



Chapter 10. Big Entropy and the Generalized Linear Model

Mamum entropy

Generalized linear models

Mamum entropy priors


Chapter 11. God Spiked the Integers

Binomial regression

Poisson regression

Multinomial and categorical models



Chapter 12. Monsters and Mixtures

Over-dispersed counts

Zero-inflated outcomes

Ordered categorical outcomes

Ordered categorical predictors



Chapter 13. Models With Memory

Example: Multilevel tadpoles

Varying effects and the underfitting/overfitting trade-off

More than one type of cluster

Divergent transitions and non-centered priors

Multilevel posterior predictions



Chapter 14. Adventures in Covariance

Varying slopes by construction

Advanced varying slopes

Instruments and causal designs

Social relations as correlated varying effects

Continuous categories and the Gaussian process



Chapter 15. Missing Data and Other Opportunities

Measurement error

Missing data

Categorical errors and discrete absences



Chapter 16. Generalized Linear Madness

Geometric people

Hidden minds and observed behavior

Ordinary differential nut cracking

Population dynamics



Chapter 17. Horoscopes


About the Author

Richard McElreath is the director of the Department of Human Behavior, Ecology, and Culture at the Max Planck Institute for Evolutionary Anthropology. He is also a professor in the Department of Anthropology at the University of California, Davis. His work lies at the intersection of evolutionary and cultural anthropology, specifically how the evolution of fancy social learning in humans accounts for the unusual nature of human adaptation and extraordinary scale and variety of human societies.

About the Series

Chapman & Hall/CRC Texts in Statistical Science

Learn more…

Subject Categories

BISAC Subject Codes/Headings:
MATHEMATICS / Probability & Statistics / General