Difference in differences estimates causal effects from changes that affect some groups and not others.
It suits policies, price changes and launches that reach one place before another.
It needs data from before and after the change in both groups.
Step 1 is the change in the treated group from before to after.
Step 2 is the change in the comparison group over the same period.
Step 3 subtracts the second from the first, which removes trends common to both groups.
It also removes fixed differences between the groups, such as one city always having higher wages.
The key assumption, parallel trends, says the groups would have moved together without the change.
Several periods of data before the change let analysts check whether the trends really were parallel.
If the groups were already drifting apart, the estimate mixes that drift with the effect.
Other events that hit only the treated group at the same time also bias the estimate.
Choosing a comparison group as similar as possible, such as a neighbouring region, makes the assumption more believable.
When many groups adopt a change at different times, newer methods avoid biases that affect the simple version.
In practice, difference in differences is one of the most common designs for judging policy and business changes.
The usual mistake is skipping the check of trends before the change, which is the main evidence that the assumption holds.