Difference-in-Differences
Estimating causal effects by comparing changes over time between treated and untreated groups
Many treatments or policy changes happen at a specific point in time. We observe the world before and after — but how much of the change is actually caused by the treatment?
Difference-in-Differences (DiD) answers this by comparing changes over time between a group that received treatment and a group that didn't. The key insight: use the untreated group's change as a proxy for what would have happened to the treated group without treatment.
These notes walk through the intuition, the regression framework, and the assumptions that make it all work.
The Key Concept
Treatment shocks, the back door of time, control groups, and the parallel trends assumption
The Regression
Two-way fixed effects, the interaction-term model, and interpreting DiD coefficients
Supporting Parallel Trends
Prior trends tests, placebo tests, and what to do when parallel trends might not hold
Control Variables (Covariates) in DiD
Conditional parallel trends, when and how to include covariates, and checking your work
Python Code
Reproduce the DiD estimate in Python with the diff-diff library
References & Further Reading
Books, articles, and resources to deepen your understanding