← Economics
Universityeconometrics

Difference-in-Differences: A Credible Comparison Over Time

Estimate a policy effect by comparing treated and comparison groups before and after a change, while making the parallel-trends assumption—and its limits—explicit.

Before this, you should know:

A city introduces a childcare subsidy in one region but not in a nearby comparison region. Employment among eligible parents rises after the subsidy in the treated region. Is that the program's effect? Perhaps—but employment could have risen everywhere because the economy improved. And the treated region might have started with a different employment rate before the subsidy.

Difference-in-differences, or DiD, uses both dimensions of the comparison: the difference between groups and the change over time. The goal is not to pretend the regions are identical. It is to ask whether the treated region changed more than a credible comparison suggests it would have changed without the program.

Why use two differences?

Consider two groups: a treated group TT and a comparison group CC. Observe each before (00) and after (11) the policy. The simple DiD estimate is

τ^DiD=(YT,1−YT,0)−(YC,1−YC,0).\widehat{\tau}_{DiD} = (Y_{T,1}-Y_{T,0})-(Y_{C,1}-Y_{C,0}).

The first difference is the treated group's before-after change. That change includes both the policy and everything else that happened over time. The second difference is the comparison group's change over the same period. Subtracting it removes the time change shared by the groups—if that shared-change assumption is credible.

This also handles a stable starting difference. Suppose the treated region has lower employment than the comparison region both before and after the policy. The level gap itself does not invalidate DiD. What matters is whether, without the policy, the two groups would have followed the same trend.

A two-period difference-in-differences graph. Treated-region employment rises from 60 to 68 percent; comparison-region employment rises from 64 to 66 percent. A dashed counterfactual line projects the treated region's no-policy outcome to 62 percent, leaving a six-percentage-point gap to the observed 68 percent.

The comparison group supplies the treated group's missing trend under no treatment. The estimated policy effect is the gap between that counterfactual and the treated group's observed outcome—not the whole before-after rise.

The assumption that does the identifying work

Let Yg,t(0)Y_{g,t}(0) be group gg's average outcome at time tt if it does not receive the treatment. For DiD to identify the post-treatment effect on the treated group, the key parallel-trends assumption is

E[YT,1(0)]−E[YT,0(0)]=E[YC,1(0)]−E[YC,0(0)].E[Y_{T,1}(0)]-E[Y_{T,0}(0)] = E[Y_{C,1}(0)]-E[Y_{C,0}(0)].

The treated group's post-policy no-treatment outcome, YT,1(0)Y_{T,1}(0), is counterfactual: after treatment begins, we cannot observe what would have happened in that region without it. Parallel trends says the comparison group's change is a good estimate of that missing change. It does not say the groups have equal outcomes, equal characteristics, or flat trends. It says their average trends would have matched in the absence of treatment.

Under this assumption, the observed difference-in-differences subtracts the counterfactual change from the treated group's actual change, leaving the average treatment effect on the treated group in the post period. If parallel trends fails, DiD may attribute a pre-existing divergence or a treated-region-specific shock to the program.

A regression version of the same calculation

For two groups and two periods, the same estimate can be written as a regression:

Yg,t=α+γ Treatedg+δ Postt+τ(Treatedg×Postt)+εg,t.Y_{g,t}=\alpha+\gamma\,Treated_g+\delta\,Post_t +\tau(Treated_g\times Post_t)+\varepsilon_{g,t}.

Here TreatedgTreated_g equals one for the treated group, PosttPost_t equals one after the policy, and their interaction equals one only for treated observations after the policy. Its coefficient τ\tau is the DiD estimate. The group indicator absorbs stable level differences; the period indicator absorbs changes common to both groups. The interaction captures the additional post-period change in the treated group.

This is the simple two-by-two design. It is useful to understand before moving to many groups, many dates, or policies adopted at different times; those extensions require additional care and are outside this lesson's calculation.

What should make us cautious?

Parallel trends is an assumption about an unobserved counterfactual, so no graph or test can prove it. Several pre-treatment periods let us check whether the groups had similar trends before the policy. Similar pre-trends support the design's plausibility; they do not guarantee that the trends would have remained parallel after treatment. Pre-trend tests can also have little power when data are noisy or the pre-period is short.

Other threats deserve an explicit check:

DiD is therefore not a recipe that turns any two before-after series into a causal answer. The researcher must explain why the comparison group's trend is a credible stand-in for the treated group's missing counterfactual and examine evidence that could challenge that argument.

Worked example

A childcare subsidy begins in Region A but not Region B. Employment among eligible parents is 60% in A and 64% in B before the policy. One year later it is 68% in A and 66% in B. Calculate the difference-in-differences estimate. Under parallel trends, what would A's employment rate have been without the subsidy?

Step 1 — calculate the treated region's change. Region A moves from 60% to 68%, an increase of 8 percentage points.

ΔYA=68−60=8 percentage points.\Delta Y_A = 68-60=8 \text{ percentage points}.

Step 2 — calculate the comparison region's change. Region B moves from 64% to 66%, an increase of 2 percentage points.

ΔYB=66−64=2 percentage points.\Delta Y_B = 66-64=2 \text{ percentage points}.

Step 3 — subtract the common comparison trend.

τ^DiD=ΔYA−ΔYB=8−2=6 percentage points.\widehat{\tau}_{DiD}=\Delta Y_A-\Delta Y_B=8-2=6 \text{ percentage points}.

The estimated effect is 6 percentage points. Notice that A began four points below B; DiD does not require their starting levels to match.

Step 4 — construct A's no-subsidy counterfactual. If A would have followed the same two-point trend as B without the subsidy, its counterfactual employment rate would be

60%+2 percentage points=62%.60\%+2 \text{ percentage points}=62\%.

The observed rate is 68%, which is six points above that counterfactual. Under parallel trends and the other design assumptions, we attribute that extra six-point rise to the subsidy for the treated group.

Step 5 — state what the arithmetic cannot establish. The estimate is not automatically causal just because it was calculated correctly. We still need to defend parallel trends, rule out a simultaneous shock unique to Region A, check for anticipation and spillovers, and quantify sampling uncertainty. The four numbers alone cannot verify those conditions.

Where this leads

DiD builds a counterfactual trend by combining a treated group's before-after change with a comparison group's before-after change. Its identifying claim rests on parallel trends—not on equal starting levels or on the arithmetic itself. This is the first of several applied designs in the roadmap. Next, we will study instrumental variables, which use a source of variation that shifts treatment while, under demanding assumptions, affecting the outcome only through that treatment; regression discontinuity will follow as a separate threshold-based design.

Check yourself

4 questions

  1. In a two-group, two-period difference-in-differences design, which assumption identifies the treatment effect?

  2. Employment in a treated region rises by 8 percentage points; in the comparison region it rises by 2 percentage points. What is the difference-in-differences estimate?

  3. Several pre-treatment years show similar trends in the treated and comparison groups. What does this evidence establish?

  4. A new policy starts only in the treated region, at the same time as the program being evaluated, and also affects employment. Why is this a threat to DiD?