Difference-in-differences calculator
Estimate the 2×2 difference-in-differences contrast from treated and control means before and after. Your inputs stay on your device.
Set up your task
Starting local processing
Ready. Processing stays in this browser.
2 Your result
Your result updates in this browser. Check your input if the result looks unexpected.
How to use Difference-in-differences calculator
Estimate the 2×2 difference-in-differences contrast from treated and control means before and after. The example below shows the input values and the result so you can compare the calculator’s method with your own working.
- Start with the pre-filled values for treated group before, treated group after, control group before, control group after.
- Replace the example with your own coursework values. Keep units consistent across the inputs and compare with the stated model.
- Read the intermediate values in the result. Use the check below to see how a change in the assumptions affects the answer.
Supported inputs and limits
Enter four comparable group means on the same outcome scale. This two-group, two-period calculation uses one treatment date.
How it works
Difference-in-differences compares how an outcome changes for a treated group with how it changes for a comparison group. Start by taking each group’s post-period mean minus its pre-period mean. Subtract the comparison group’s change from the treated group’s change. This contrast removes a common change shared by both groups.
For a causal interpretation, the untreated trend of the treated group must be represented by the observed control trend. In the example the comparison group rises by eight. Adding eight to the treated group’s baseline gives a post-period counterfactual of 48. Comparing the actual treated post-period mean with that value gives the same contrast as subtracting the two changes.
Example
The pre-filled example gives “Difference-in-differences: 8” as its first result.
- Treated group before
- 40
- Treated group after
- 56
- Control group before
- 30
- Control group after
- 38
Difference-in-differences: 8 Treated change: 16 · Control change: 8 Treated post-period counterfactual under parallel trends: 48 Calculation: (56 − 40) − (38 − 30)
Questions about Difference-in-differences calculator
Does this calculate a confidence interval?
It uses four group means, which are enough to calculate the contrast. Standard errors require observation-level variation and an appropriate design, including clustering when needed.
Do the groups need the same pre-treatment level?
Parallel trends concerns their changes in the absence of treatment. Different baseline levels are compatible with equal counterfactual changes.
Can I apply this directly to staggered adoption?
Use this calculator for one treatment date and two periods. Staggered timing can require group-time effects and an estimator designed for that setting.
Related tools
Last updated