Calculating the DiD Estimator
What you'll learn: How to compute the actual Difference-in-Differences estimate that isolates the causal treatment effect.
The Double Difference Formula
Now that you understand the DiD setup and parallel trends assumption, it's time to calculate the DiD estimator itself. This is where the "double difference" happens.
The formula works in two steps:
-
First difference (Treatment group): Calculate the change in the treatment group from before to after the intervention:
(Y_treatment_after - Y_treatment_before) -
First difference (Control group): Calculate the change in the control group over the same period:
(Y_control_after - Y_control_before) -
Second difference (DiD): Subtract the control group's change from the treatment group's change:
DiD = (Y_treatment_after - Y_treatment_before) - (Y_control_after - Y_control_before)
Why This Works
The control group's change captures time trends and external factors affecting both groups. By subtracting it, you "difference out" those confounders, leaving only the causal effect of the treatment.
Think of it like adjusting for inflation: if your salary increased by 3,000, your real gain is only $2,000.
Example Calculation
Suppose average sales are:
- Treatment group: Before = 100, After = 130
- Control group: Before = 90, After = 110
DiD = (130 - 100) - (110 - 90)
DiD = 30 - 20 = 10
The treatment caused a 10-unit increase in sales, net of the 20-unit background trend.
Key Takeaway: The DiD estimator subtracts the control group's before-after change from the treatment group's before-after change, isolating the causal treatment effect by removing common time trends.