Difference in differences and parallel trends
Identify a post-treatment effect from changes only when untreated counterfactual trends are comparable.
On this page
The question for today
What you’ll understand
- Derive the two-group, two-period DID estimand.
- Distinguish parallel untreated trends from equal levels or observed pretrend evidence.
- Recognize composition and staggered-adoption complications.
Difference in differences compares how outcomes change in a treated group with how they change in a comparison group. It can accommodate fixed differences in baseline outcome levels, but its causal interpretation requires a restriction on an unobserved trajectory: how the treated group would have changed without treatment. We begin with a stable panel, two periods, and one group treated only in the second period. That simple design makes the target and the identifying assumption visible before considering more complicated adoption patterns.
Subtract a comparison change to form the counterfactual
Let G=1 denote the group treated in period one, with period zero as baseline, while G=0 remains untreated in both periods. Write Yₜ(0) for untreated potential outcomes and Y₁(1) for the treated post outcome. No anticipation requires that baseline outcomes in the eventually treated group equal their untreated potential outcomes. Assume consistency, no interference, positive probabilities for both groups, and integrability. The target is the post-period effect on the treated group, not automatically an effect for everyone.
Parallel trends equates the two groups’ mean untreated changes between the periods. Add the observed comparison-group change to the treated group’s observed baseline mean to obtain its counterfactual untreated post mean. Subtracting that prediction from its observed post mean yields the DID contrast. Baseline levels may differ because the identifying restriction concerns changes. A common additive time shock with a fixed group offset satisfies this condition, while a group-specific untreated shock can violate it.
An observed pattern cannot reveal the missing post trend
Several untreated pre-periods permit useful checks for earlier trend differences and dynamic behavior. A failure to reject a pretrend difference is not proof that the relevant post-period counterfactual trends would have been parallel. Tests can lack power, treatment may be anticipated, and a new shock can coincide with adoption. Conversely, identification for a specified post comparison need not assert identical group trends at every historical date. The exact temporal assumption should match the design and scientific context.
A useful sensitivity parameter is the difference between the treated and comparison groups’ untreated mean changes. The observed DID equals the treated effect plus that difference, so specifying a possible deviation immediately shows how the causal conclusion moves. This is not an estimated correction unless the deviation is identified by additional information. It makes the identifying content transparent: DID cancels a common trend, not an arbitrary differential trend. A regression coefficient with group and time indicators does not remove the assumption.
Changing samples and treatment timing add structure
With repeated cross-sections, group means may change because different kinds of units are sampled at each date. Comparable group composition or an explicit covariate-standardization design is needed to interpret those changes as the desired population trajectories. A stable panel avoids that particular replacement issue but can still suffer attrition, interference, or changing measurement. Uncertainty also needs to reflect serial dependence and the level at which treatment varies; treating every repeated observation as independent can exaggerate precision.
With staggered adoption and heterogeneous effects, a simple two-way fixed-effects coefficient can combine comparisons involving already-treated groups and weight different group-time effects in unintuitive ways. One should define cohort-time targets and select genuinely appropriate never-treated or not-yet-treated comparisons under explicit anticipation and trend assumptions. The two-period formula does not automatically validate every multigroup regression using a similar name. The durable principle is to construct a credible untreated trajectory for a named treated target before aggregating effects across groups or dates.
Work it through
Build the treated group’s missing post mean
A stable treated group has mean outcome ten before treatment and seventeen afterward. A comparison group has means six and ten. Assume no anticipation and parallel untreated mean trends. Compute the counterfactual post mean and DID effect.
The comparison group changes by ten minus six, or four. Parallel trends assigns that same untreated change to the treated group.
Its counterfactual untreated post mean is therefore ten plus four, or fourteen. Its observed post mean is seventeen, so the post ATT is three.
Equivalently, subtract the changes: (17−10)−(10−6)=7−4=3. If the treated group’s untreated trend were one larger instead, the same observed DID would overstate its effect by one.
Different baseline levels are allowed. The conclusion three relies on the counterfactual change restriction, not merely on observing an increase after adoption.
The living notebook
Explore the model
Interactive lab · function
Equal baseline levels need not imply parallel changes
Interpret x as a toy time coordinate. Reset, set a=1,x=0 and predict zero; change x to 1 and predict one. Reset, set a=0.5,x=0, then change x to 1 and predict one half. Both quadratic paths start at zero but have different zero-to-one changes. The model illustrates a counterexample to inferring parallel trends from equal levels; it does not identify treatment effects or fit a DID model. Changes retain clock time; Reset restores both controls and zero time.
- y at chosen x
- 0.608
- Tangent slope · 2ax
- 1.35
- Signed area · ax³/3
- 0.182
This lab uses only y = ax². Playback traces the curve within the fixed integration interval from 0 to x; it does not estimate numerical error or change the chosen point. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forMatching baseline levels is different from equal untreated changes over the comparison period.
Pause & reason
Check your understanding
Your turn
Try it yourself
Treated means are twenty before and twenty-five after adoption; comparison means are twelve and fifteen. Compute DID. If the treated group’s true untreated mean increase were four rather than the comparison increase three, what would its actual post ATT be?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
First subtract observed changes. Then construct the counterfactual post mean using the stipulated nonparallel untreated increase.
Compare with the solution
Observed changes are five and three, so DID equals two. Under the stipulated untreated increase four, the treated counterfactual post mean would be twenty-four. Its actual post ATT would then be twenty-five minus twenty-four, or one. The trend deviation delta is one, and DID=ATT+delta gives two=one+one. This calculation illustrates the sensitivity of the effect to the unobserved untreated path rather than estimating that deviation from the four means.
Keep the idea
Take it with you
- DID targets a post effect for a named treated group under no anticipation and parallel untreated mean changes.
- Equal baseline levels and nonsignificant pretrend tests do not establish the identifying restriction.
- Changing composition, dependence, and staggered adoption require additional design and inference choices.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.