A First Course in Causal Inference
Executable chapter examples with crabbymetrics
These pages translate selected examples from Peng Ding’s A First Course in Causal Inference into Python. They use crabbymetrics for estimation and NumPy for explicit randomization and potential-outcomes calculations. They are companions to the book, not a complete translation.
Chapters
Grouped reading routes: foundations, design and adjustment, observational adjustment, and instrumental variables.
Data and scope
The real-data inputs come from Ding’s replication archive, with the matched-pairs data from HistData::ZeaMays. The small files used here are bundled under docs/data/ding/; data provenance records the sources and checksums. No external-drive symlink is needed.
Chapter 27 illustrates the additional identifying assumptions behind mediation; its regressions are not a general mediation estimator. Chapters without a link above are not covered by this documentation. Matching, sensitivity-analysis, regression-discontinuity, and principal-stratification extensions remain outside the current chapter collection.