← 8. Causal effects
Difference-in-Differences (DID)
Try this analysis →

Difference-in-differences (DID)

Estimates a policy effect by subtracting the change in the comparison group from the change in the treatment group.

Treatment & comparison groupsParallel trends assumptionEvent studyStaggered DID

55%60%65%70%+4 ppPolicy regions 68%64% without the policyNon-policy regions 62%60%58%BeforeAfter

Suppose the government introduced a youth employment support policy in certain regions. After the policy took effect, the youth employment rate in those regions rose from 60% to 68%. Can we then conclude that the policy raised the youth employment rate by 8 percentage points?

That is hard to say. During the same period, the economy may have recovered or companies may have increased hiring, so the youth employment rate could have risen regardless of the policy. So looking only at the change in the regions where the policy was implemented makes it hard to estimate the policy's effect accurately.

What if we could also observe regions where the policy was not implemented? For example, if the youth employment rate in regions without the policy also rose from 58% to 62% over the same period, part of the 8-point rise in the policy regions may be a change common to both kinds of regions.

In this way, the method that estimates a policy effect by subtracting the change in comparison regions from the change in policy regions is difference-in-differences (DID).

DID is a causal inference method widely used in policy evaluation, economics, and social science research. It can be used to analyze the impact of a policy or program when a randomized experiment is hard to carry out.

In this article, we cover difference-in-differences from its basic principle to how to calculate it, the regression model, a real policy evaluation example, the parallel trends assumption, event studies, and points to watch out for in the analysis.

SECTION 1

What is difference-in-differences (DID)?

Difference-in-differences estimates a policy effect by comparing the before-and-after changes of a group that received a policy or treatment and a group that did not.

The analysis generally needs two groups.

Outcomes are then observed before and after the policy takes effect. For example, if a youth employment support policy was introduced only in certain regions, those regions are the treatment group and the other regions without the policy are the comparison group. In DID, you first calculate each group's change from before to after the policy.

Then you subtract the comparison group's change from the treatment group's change. This helps remove differences between the groups that existed before the policy, as well as changes over time that affected both groups in common. However, it requires an important assumption: that without the policy, the two groups would have changed along similar trends.

SECTION 2

How is it different from a simple before-and-after comparison?

The easiest way to think about evaluating a policy effect is to compare outcomes before and after the policy.

For example, if the youth employment rate in the policy regions rose from 60% to 68%, the change is as follows.

68% − 60% = 8 pp

But these 8 points may include not only the policy effect but also changes in the economy, seasonal factors, changes in the industrial environment, and so on.

Change: policy regions8 ppChange: non-policy regions4 ppDID = difference4 pp
Breaking down the 8 points

To reduce this problem, DID also takes the comparison group's change into account.

AspectSimple before-after comparisonDifference-in-differences
Groups analyzedMainly the policy groupTreatment and comparison groups
Basis of comparisonBefore vs. afterDifference in the two groups' before-after changes
Common changes over timeNeed to be controlled separatelySubtracted out under appropriate assumptions
Key assumptionNo other factors causing changeParallel trends assumption
Main resultSimple change from before to afterEstimated policy effect relative to the comparison group

DID can be more useful for policy evaluation than a simple before-after comparison, but adding a comparison group does not remove every confounder. In particular, if an event occurred that affected the two groups' trends differently, the DID estimate can also be biased.

SECTION 3

How is DID calculated?

The most basic DID formula is as follows.

DID = (Ytreatment, post − Ytreatment, pre) − (Ycomparison, post − Ycomparison, pre)

Here, T denotes the treatment group and C the comparison group. Let's calculate it using the youth employment support policy example.

Youth employment rate before and after the policy

GroupBefore policyAfter policyChange
Policy regions60%68%+8 pp
Non-policy regions58%62%+4 pp

The change in the treatment group is 8 points. The change in the comparison group is 4 points. So the DID estimate is as follows.

DID = (68 − 60) − (62 − 58) = 4 pp

In other words, the youth employment rate in the policy regions rose 4 points more than the change in the comparison regions. If the required causal inference assumptions, such as parallel trends, hold, these 4 points can be interpreted as the policy's average treatment effect.

The important point is that the DID estimate is not the 8-point total rise in the policy regions but the 4-point difference between the two groups' rises.

SECTION 4

How do you understand DID results in a graph?

The principle of DID is to use the comparison group's trend to estimate how the treatment group would have changed without the policy.

In the example above, the employment rate in the policy regions rose from 60% to 68%. The non-policy regions rose 4 points, from 58% to 62%. If we assume parallel trends, we can estimate that without the policy, the employment rate in the policy regions would also have risen from 60% to 64%.

Since the actual employment rate after the policy was 68%, the difference between these two values is 4 points.

55%60%65%70%+4 ppPolicy regions 68%64% without the policyNon-policy regions 62%60%58%BeforeAfterCounterfactual (not observed)
Actual and counterfactual outcomes

Actual employment rate after the policy 68% · estimated employment rate without the policy 64%

Estimated policy effect: +4 pp

Here, the 64% employment rate without the policy is not an actually observed value. It is a counterfactual outcome estimated using the comparison group's change. The causal interpretation of DID depends on how valid this counterfactual estimate is.

SECTION 5

Real example: evaluating a youth employment support policy

Suppose a state government introduced a policy that pays companies a subsidy for newly hiring young people, in order to raise the youth employment rate.

The policy was implemented only in some regions and not in other similar regions. The researcher surveyed the youth employment rate by region for 2 years before and after the policy.

Study design

ItemDetails
Purpose of analysisEstimating the effect of the youth employment support policy
Treatment groupRegions with the youth hiring subsidy policy
Comparison groupRegions without the policy in the same period
Dependent variableYouth employment rate (%)
Treatment variableWhether the policy was implemented
Period variableBefore / after the policy
Main resultDifference in employment rate change due to the policy

To estimate the policy effect, you need to consider not just the difference in employment rates but also the timing of the policy and each group's change. It is also important to check how similar the comparison group is to the policy regions and what the employment rate trend looked like before the policy.

SECTION 6

How is the DID regression model set up?

DID can be analyzed not only by simply calculating differences in means but also with a regression model.

The basic two-group, two-period DID regression model is as follows.

Yit = β0 + β1Treatmenti + β2Postt + β3(Treatmenti × Postt) + εit

Here, each term means the following.

VariableMeaning
YitYouth employment rate of region i at time t
Treatment1 if a policy region, 0 otherwise
Post1 if after the policy, 0 if before
Treatment × PostInteraction term indicating policy regions after the policy
β3DID estimate coefficient
β₀ intercept58Comparison group, beforeTreatment2.00Pre-policy differencePost4.00Comparison group changeTreatment × Post4.00DID estimate coefficient
The four cells and the regression coefficients

The most important thing in this model is the coefficient of the Treatment × Post interaction term. This coefficient represents the difference in the two groups' before-after changes. In the example above, this value is 4, so it is interpreted as the employment rate in the policy regions rising 4 points more than in the comparison regions.

Note that this interpretation applies when the outcome variable is entered in percentage units (e.g., 60, 68). If the outcome variable is entered as a proportion between 0 and 1, the coefficient is expressed as 0.04.

SECTION 7

How do you interpret actual DID regression results?

Suppose that for the policy evaluation example above, a DID regression was run on data spanning several regions and years.

DID regression results

VariableCoefficient (B)Standard errorp-value
Policy region (Treatment)2.000.85.019
After policy (Post)4.000.90< .001
Treatment × Post4.001.30.002

The employment rate is assumed to be entered in percentage units.

The coefficient for policy region is 2.00. This means the difference in youth employment rates between the two groups before the policy was 2 points. The coefficient for after the policy is 4.00.

This means the comparison group's youth employment rate rose 4 points after the policy. The coefficient of the most important term, the interaction, is 4.00. This means the youth employment rate in the policy regions rose 4 points more than in the comparison group.

The p-value was .002, confirming a statistically significant positive DID estimate. But statistical significance alone does not prove the policy's causal effect. You need to check the validity of the study design, including the parallel trends assumption.

SECTION 8

What is the parallel trends assumption?

The parallel trends assumption is the most important causal inference assumption in DID.

It is the assumption that, had the policy not been implemented, the outcome variable of the treatment and comparison groups would have followed the same trend on average. The important point here is that the two groups' employment rate levels do not have to be the same.

For example, even if the treatment group's employment rate before the policy was 60% and the comparison group's was 55%, the parallel trends assumption can hold if, without the policy, the two groups' employment rates would have changed by similar amounts. Conversely, even if the employment rates were the same before the policy, it is a problem if their subsequent trends are expected to differ.

Example of pre-policy trends

YearTreatment groupComparison group
202154%52%
202256%54%
202358%56%
2024 (just before policy)60%58%
52%56%60%+2+2+2+2+2+22021202220232024TreatmentComparison
Pre-policy trends

In this example, both groups rose 2 points each year before the policy. So the observed past trends look consistent with the parallel trends assumption. But similar past trends do not prove that, without the policy, the groups would necessarily have followed the same trend after the policy took effect.

This is because the parallel trends assumption is about counterfactual outcomes that cannot actually be observed.

SECTION 9

How do you check the parallel trends assumption?

The parallel trends assumption is hard to prove completely, but you can examine its plausibility using data from before the policy.

The most basic way is to compare the outcome variable at several points before the policy in a graph. For example, you can look at the youth employment rate for 4–5 years before the policy to see whether the two groups changed in a similar direction and by a similar amount.

You can also use an event study regression to check how the difference between the groups changed at each point before the policy. However, the fact that the pre-policy coefficients are not statistically significant does not by itself let you conclude that parallel trends hold.

This is because, if power is low, a real difference in trends may not show up as significant. So it is good to consider the following as well.

In particular, if the policy was introduced only in regions where employment was deteriorating rapidly, the selection of policy targets itself can make the causal interpretation of DID difficult.

SECTION 10

What is an event study?

An event study estimates effects at several points before and after the policy, relative to the time the policy took effect.

Whereas basic DID compares two broad periods, before and after the policy, an event study looks at the relationship at each point in time, such as 2 years before, 1 year before, the year of implementation, 1 year after, and 2 years after. For example, suppose we obtained the following results.

Estimated coefficients relative to policy start

TimeDID coefficient (pp)95% confidence interval
3 years before-0.3-1.5~0.9
2 years before0.2-0.8~1.2
1 year beforeReference—
Policy year1.50.2~2.8
1 year after3.21.5~4.9
2 years after4.52.3~6.7
−20246Policy start−0.33 yrs before+0.22 yrs beforeReference1 yr before+1.5Policy year+3.21 yr after+4.52 yrs afterVertical lines = 95% confidence intervals
Coefficients by time point

In this example, 1 year before the policy was set as the reference point. The pre-policy coefficients were not very different from 0, and after the policy the coefficients gradually increased. These results show a pattern in which, after the policy, the youth employment rate in the treatment group became relatively higher compared with the comparison group.

However, insignificant pre-policy coefficients alone do not complete causal identification. It is best to think of the event study as a supplementary method for seeing how the policy effect changes over time and for examining the DID assumptions.

SECTION 11

What role do fixed effects play in DID?

With data observing many regions over many years, you can use a DID model that includes region fixed effects and year fixed effects.

For example, it can be written as follows.

Yit = αi + λt + δ·Dit + εit

Here, each symbol means the following.

SymbolMeaning
αiRegion fixed effects
λtYear fixed effects
Dit1 if the policy is in effect in region i at time t
δDID estimate coefficient

Region fixed effects control for characteristics of each region that do not change. Year fixed effects control for period-specific changes that act on all regions in common. In such a model, the policy effect is estimated using changes over time within the same region and changes in comparison regions.

However, including fixed effects does not automatically satisfy the DID parallel trends assumption. In particular, if different economic shocks hit different regions, region and year fixed effects alone may not control for them sufficiently.

SECTION 12

What if the policy starts at different times in different regions?

The basic DID described so far assumes a situation in which all treatment groups implement the policy at the same time.

But in real policies, implementation timing can differ by region. For example, suppose region A introduced a youth employment support policy in 2022, region B in 2023, and region C in 2024.

Region APrePolicyPolicyPolicyPolicyRegion BPrePrePolicyPolicyPolicyRegion CPrePrePrePolicyPolicy202120222023202420252024: A and B, already treated, serve as C's comparison group
Staggered DID

This situation is called staggered difference-in-differences.

When the policy effect differs by region or by time since implementation, the ordinary two-way fixed effects regression coefficient can be interpreted differently from a simple average policy effect. In particular, problems can arise in estimation when regions that have already implemented the policy are used as comparison groups for other regions.

So for data with different implementation timing, it is good to consider methods that estimate treatment effects by adoption cohort and time point. Well-known examples include the Callaway–Sant'Anna and Sun–Abraham approaches.

The important point is that just because they share the name DID does not mean the same regression model can be applied to every policy adoption structure.

SECTION 13

Points to watch in DID analysis

DID is useful for analyzing policy effects, but several conditions must be examined for a causal interpretation.

Parallel trends assumption

The assumption that, without the policy, the treatment and comparison groups would have changed along similar trends on average is crucial.

Anticipation before the policy

If companies or individuals knew about the policy in advance and changed their behavior, policy effects could occur even before the official start date. In this case, treating the pre-policy period as unaffected may be inappropriate.

Other policies or shocks at the same time

If a large industrial park was built in the treatment regions at the same time as the youth employment support policy, it may be hard to separate out the cause of the rise in employment.

Spillovers between groups

The employment support policy in the treatment regions may also affect companies and young people in nearby comparison regions. In this case, the comparison group may actually have been affected by the policy.

Changes in group composition

If young people moved into the treatment regions after the policy, the change in regional employment rates may reflect not only the policy's direct employment effect but also changes in population composition.

Calculating standard errors

Observations from the same region may be related to each other across years. So you should consider standard errors clustered at the region level. In particular, if the policy was implemented in only a few regions, ordinary cluster-robust standard errors alone may not be enough, so inference methods suited to a small number of clusters should be considered.

SECTION 14

How do you report DID results?

When reporting DID results, it is good to present the policy content and timing, the definitions of the treatment and comparison groups, the observation period, the outcome variable, the estimated coefficient, the confidence interval, the p-value, and so on.

You should also explain in particular how the pre-policy trends were checked and which fixed effects and control variables were included. Using the youth employment support policy example above, you could write it as follows.

Example report

Difference-in-differences (DID) was applied to estimate the effect of the youth employment support policy on regional youth employment rates. Comparing employment rates before and after the policy in policy and non-policy regions, the youth employment rate in the policy regions rose 8 percentage points, from 60% to 68%, while the comparison regions rose 4 points, from 58% to 62%. The resulting DID estimate was 4 percentage points. In the regression analysis, the interaction term between policy region and post-policy period also showed a statistically significant positive coefficient (B = 4.00, SE = 1.30, p = .002). These results show that the youth employment rate in the policy regions rose relatively more than in the comparison regions. Provided that parallel trends and the other identifying assumptions hold, this can be interpreted as the policy's average effect of increasing the employment rate.

In real studies, it is important to report the pre-policy trends and the rationale for choosing the comparison regions as well. Also, if the policy was adopted at different times in different regions, you should state clearly which DID estimation method was applied and how the comparison group was defined.

✓Wrap-up

DID estimates a policy effect from the difference in two groups' changes.

Difference-in-differences (DID) estimates a policy effect by comparing the before-and-after changes of a group where a policy or program was implemented and a group where it was not.


Even if the outcome in the policy regions increased by 8 points, if the comparison regions increased by 4 points over the same period, the DID estimate is 4 points. This approach helps remove fixed differences between groups and changes over time that occurred in both groups in common.

However, to interpret DID results as a causal effect, you need the assumption that, without the policy, the two groups would have followed parallel trends. So you should check the pre-policy trends and also examine whether other policies were implemented at the same time, spillovers between groups, how policy targets were selected, and so on.

Also, when the policy starts at different times for different groups or the policy effect changes over time, you may need an estimation method that reflects that structure rather than the basic DID model.

KEY TAKEAWAY

The key to DID is not just looking at how much changed after the policy, but using the comparison group to estimate the change that would have occurred without the policy and evaluating the difference as the policy effect.