Causal Inference with Differences-in-Differences: Credible Answers to Hard Questions
Preface
This book provides complete, executable solutions to all Computer Questions (coding exercises) from: > Causal Inference with Differences-in-Differences: Credible Answers to Hard Questions > by Clément de Chaisemartin & Xavier D’Haultfœuille (Princeton University Press, forthcoming)
Every exercise is solved in three programming languages — Stata, R, and Python — and the code executes directly inside this book, producing outputs, tables, and graphs so the reader can verify that results are exactly the same across all three languages.
Each chapter is presented in three separate pages, one per language, so that all outputs are generated live.
Datasets
| Chapters | Paper | Stata (.dta) | R (.RData) | Python (.parquet) |
|---|---|---|---|---|
| 3 & 4 | Moser & Voena (2012) | .dta | .RData | .parquet |
| 5 & 8 | Gentzkow et al. (2011) | .dta | .RData | .parquet |
| 6 | Wolfers (2006) | .dta | .RData | .parquet |
| 7 | Pierce & Schott (2016) | .dta | .RData | .parquet |
Datasets are loaded directly from the book’s GitHub repository inside each code block, so there is nothing to download. The files are also available in Stata (.dta), R (.RData) and Python (.parquet) formats in the table above.
Requirements
- Quarto ≥ 1.4: https://quarto.org/docs/download/
- Stata 17+ with
nbstata:pip install nbstata && python -m nbstata.install - R with packages:
source("https://raw.githubusercontent.com/Credible-Answers/did_book/Version2/did_book_final/requirements/setup.R") - Python with packages:
pip install pandas numpy pyfixest scipy matplotlib pyreadstat