ε

Difference-in-Differences

Treatment effects from before/after × treated/control, parallel trends, event studies.

Intermediate · 4 modules · Free and browser-based

View the course outline

Course overview

Learn Difference-in-Differences interactively

This free course uses real Python and statsmodels in your browser. Work through the modules below with explanations, executable examples, interactive controls, and questions.

1 · The DiD idea

Why comparing one group's before/after change against a control group's change isolates a causal effect.

2 · The 2×2 estimator

The DiD estimate is exactly the interaction coefficient in a regression of y on treated, post, and their product.

3 · Parallel trends

DiD is valid only if the groups would have moved in parallel absent treatment; a pre-trend difference biases the ATT.

4 · Event-study / dynamic DiD

Estimate a separate effect for each period relative to treatment to test pre-trends and trace the effect's dynamics.