DiD with Regression
What You'll Learn
You'll learn how to implement the Difference-in-Differences estimator using linear regression with indicator variables and an interaction term.
Why Use Regression for DiD?
Instead of manually calculating four group means and subtracting them (as you learned in "Calculating the DiD Estimator"), you can estimate the same treatment effect in a single regression model. This approach is more flexible, allows for standard errors and hypothesis tests, and easily extends to include additional control variables.
The Regression Formula
The DiD regression model is:
Y = β₀ + β₁·Treated + β₂·Post + β₃·(Treated × Post) + ε
Where:
- Y is your outcome variable
- Treated is a binary indicator (1 if unit is in treatment group, 0 if control)
- Post is a binary indicator (1 if observation is from post-treatment period, 0 if pre-treatment)
- Treated × Post is the interaction term between the two indicators
Interpreting the Coefficients
- β₀: Baseline outcome for control group in pre-period
- β₁: Pre-existing difference between treatment and control groups
- β₂: Common time trend (change affecting both groups)
- β₃: The DiD estimate — the treatment effect!
The interaction coefficient β₃ captures the differential change in the treatment group relative to the control group over time — exactly what DiD measures.
Why This Works
The interaction term isolates the "difference of differences." It answers: how much more (or less) did the treatment group change compared to the control group?
Key Takeaway: The DiD estimator can be implemented as a linear regression where the coefficient on the interaction between treatment and time indicators directly estimates the causal effect under the parallel trends assumption.