A city introduces a new minimum wage. Six months later, employment in that city has dropped slightly. Did the policy cause it?
Not necessarily. Maybe the whole region was slowing down anyway. Simply comparing “before” and “after” can’t separate the effect of the policy from everything else happening at the same time.
That’s the problem difference-in-differences (DiD) solves. It is one of the most popular methods in economics, public health, and social science for estimating cause and effect when you can’t run a randomized experiment. Here is how it works, in plain English.

What Is Difference-in-Differences?
DiD compares how an outcome changed over time in a treatment group (affected by an intervention) with how it changed in a control group (not affected).
The logic is simple:
- Measure both groups before and after the intervention
- Calculate the change in each group
- Subtract the control group’s change from the treatment group’s change
That final subtraction is your DiD estimate: the “difference in the differences.”
A Quick Example
Suppose a school district launches a tutoring program in some schools.
| Group | Before | After | Change |
|---|---|---|---|
| Schools with tutoring | 70 | 80 | +10 |
| Schools without tutoring | 68 | 72 | +4 |
DiD estimate = 10 − 4 = 6 points.
Test scores rose everywhere (maybe due to easier exams or general trends), but the tutoring schools improved by 6 points more. That extra gain is the estimated effect of the program.

Why Use DiD?
- Controls for stable differences between groups (some schools are simply stronger)
- Controls for shared time trends that affect everyone (economy, weather, new regulations)
- Works with observational data, so no randomized trial is needed
- Easy to explain to non-technical audiences
The Key Assumption: Parallel Trends
DiD depends on one critical idea: without the intervention, both groups would have followed similar trends.
This doesn’t mean the groups must have the same starting level. It means their paths should have moved in parallel.
How to Check It
- Plot pre-treatment trends. Do the two lines move together before the intervention?
- Run an event-study. Test whether treatment and control diverge before the policy starts.
- Use placebo tests. Pretend the intervention happened earlier and confirm you find no effect.
If the trends were already diverging, your result may reflect that gap rather than the intervention.
Running DiD as a Regression
In practice, researchers estimate DiD with a simple regression:
Outcome = β₀ + β₁(Treated) + β₂(Post) + β₃(Treated × Post) + error
What Each Term Means
- Treated: 1 if the unit is in the treatment group
- Post: 1 if the period is after the intervention
- Treated × Post (interaction): the DiD estimate, which is the coefficient you care about (β₃)
Regression lets you add control variables, use fixed effects, and calculate proper standard errors.
When Should You Use DiD?
DiD works well when:
- A policy, program, or event affects some units but not others
- You have data before and after the event
- A reasonable comparison group exists
- You can defend the parallel trends assumption
Common use cases:
- Evaluating a new law or tax change
- Measuring the impact of a health campaign
- Testing whether a company’s new rollout boosted performance in certain regions
Common Pitfalls to Avoid
- Weak control group: if the groups are fundamentally different, the comparison breaks down
- Ignoring pre-trends: always visualize the data before trusting the result
- Other events at the same time: a second policy hitting the treatment group can contaminate your estimate
- Clustered errors: observations within the same city or school are related, so cluster your standard errors
- Staggered adoption: when units get treated at different times, standard two-way fixed effects can give misleading results, and newer estimators (such as Callaway–Sant’Anna) are designed to fix this
Tools to Get Started
- R:
fixest,did, or baselm()with an interaction term - Python:
statsmodelsorlinearmodels - Stata:
reghdfeorcsdid
Conclusion
Difference-in-differences gives researchers a practical way to answer the question, “Did this intervention actually make a difference?” By comparing changes over time between a treated and untreated group, you filter out background trends and stable group differences. Just remember that the method is only as credible as its parallel trends assumption, so always check it.
Ready to try it yourself? Pick a public dataset with a policy change (many U.S. state-level datasets work well), plot the pre-trends, and run your first DiD regression. Have a question about your own research design? Leave a comment below, and subscribe for more plain-English guides to causal inference.