DID Textbook: Translations

Author

Anzony Quispe Rojas

Preface

This book provides complete, executable solutions to all computer questions (CQs) from:

Difference-in-Differences for Natural Experiments 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

Download the dataset in your preferred format and place it in your working directory. All code blocks in the chapters assume the dataset is in the current directory.

Requirements

  • Stata 17+ with nbstata: pip install nbstata && python -m nbstata.install
  • R with packages: install.packages(c("haven", "fixest", "dplyr", "ggplot2", "broom", "car"))
  • Python with packages: pip install pandas numpy pyfixest scipy matplotlib pyreadstat

Source code

https://github.com/anzonyquispe/did_book