Beyond the Cookbook _ Teaching Bayesian Data Analysis with Statistical Rethinking
包含视频讲解
When teaching modern data analysis, the biggest hurdle isn’t the mathematics or the syntax—it is unlearning the “cookbook” approach. For decades, standard statistical education has treated data analysis like a menu: if your data looks like this, run a t-test; if it looks like that, run an ANOVA.
When I set out to teach Richard McElreath’s Statistical Rethinking (2020, Second Edition), the goal was to completely subvert that paradigm.
McElreath’s text is exceptional because it treats statistical models not as black boxes, but as engineering artifacts or, as he famously calls them, golems. They are powerful, literal-minded machines that do exactly what we program them to do, which means we must understand their internal mechanics and assumptions intimately.
Why This Curriculum Matters
Teaching this material requires shifting focus from p-values and significance testing to generative workflows and causal inference. In this course iteration, we focused heavily on three foundational pillars:
- Generative Model Design: Before touching real-world data, we simulate it. If you cannot write a simulation that generates data matching your theoretical assumptions, you do not truly understand your model.
- Causal Graphs (DAGs): The second edition introduces Directed Acyclic Graphs early on. This is a game-changer for students. It forces an explicit realization that data alone cannot tell you the causal structure; you must inject domain knowledge to correctly handle confounds, colliders, and pipes.
- The MCMC Engine: Rather than hiding behind optimization shortcuts, we pull back the curtain on Markov Chain Monte Carlo (MCMC) estimation. Understanding why a chain fails to converge tells us something profound about the geometry of our target distribution and the flaws in our model’s parameterization.
Key Takeaways from the Classroom
-
Priors are not a liability; they are an asset. Students initially view selecting priors as subjective guesswork. Once they see how regularizing priors prevent overfitting and handle small sample sizes, the skepticism vanishes.
-
The value of model failure. The most instructive moments in class happen when the Stan engine struggles. A divergent transition is not a software error to be avoided; it is a diagnostic flag revealing that your model is asking a question the data cannot answer.
Teaching this course reinforces a fundamental truth: robust statistical modeling requires equal parts mathematical rigor, software proficiency, and causal humility.
Richard McElreath 2020年发表的贝叶斯统计学书 Statistical Rethinking 第二版 PDF 的视频讲解,使用Julia (而不是书中的R和Stan)来做里面的题目, use (Turing.jl MCMC package).
- 该书的特点是有很多实际案例和对应的概率模型编程,而PRML 侧重数学原理和推导。
- 原书使用 R 和 Stan 作为概率编程语言,Statistical Rethinking: A Bayesian Course with Examples in R and Stan
- 本课程采用Julia语言,尤其是Turing.jl package, 因为Julia的速度,代码和数学公式的高相似度。可先看这个bilibili视频 Julia and Probabilistic Programming Julia概率编程来熟悉Julia概率编程。
- 讲解用到的 Julia Pluto.jl code/代码
Videos on YouTube (upload ongoing):
视频列表/Videos on bilibili:
- Chapter 1 The Golem of Prague
- Chapter 2 Small Worlds and Large Worlds
- Chapter 3 Sampling the Imaginary
- Chapter 4.1-4.3 Normal distributions & Gaussian model
- Chapter 4.4 1st Linear prediction
- Chapter 4.4-4.5 Linear prediction & Curves from lines
- Chapter 5.1 Spurious association
- Chapter 5.2-5.4 Masked relationship & Categorical variables
- Chapter 6.1-6.2 Multicollinearity & Post-treatment bias
- Chapter 6.3-6.4 Collider bias & Confronting confounding
- Chapter 7.1-7.2 The problem with parameters & Entropy and accuracy
- Chapter 7.3-7.5 Regularization & Model comparison
- Chapter 8 Conditional Manatees/Interactions
- Chapter 9.1-9.3 Markov Chain Monte Carlo
- Chapter 9.4-9.5 Hamiltonian Monte Carlo
- Chapter 10 Big Entropy and Generalized Linear Model
- Chapter 11 God Spiked the Integers
- Chapter 12 Monsters and Mixtures
- Chapter 13.1-13.2 Models with Memory
- Chapter 13.3-13.5 Models with Memory
- Chapter 14.1 Adventures in Covariance -> Varying Slopes by Construction
- Chapter 14.2 Adventures in Covariance -> Advanced Varying Slopes
- Chapter 14.3-14.4 Adventures in Covariance -> Instruments and Causal Designs, Social Relations as Correlated Varying Effects
- Chapter 14.5 Adventures in Covariance -> Continuous Categories and the Gaussian Process
- Chapter 15.1-3 Missing Data and Other Opportunities -> Measurement Error, Missing Data, Categorical errors and discrete absences
- Chapter 15.1 Missing Data and Other Opportunities -> Measurement Error
- Chapter 15.3 Missing Data and Other Opportunities -> Categorical errors and discrete absences
- 本书还有Python版本的代码: