FreeStatisticalTools.com
Panel data and causal inference

Difference-in-Differences (DiD) Analysis

Estimate the effect of a policy or intervention by comparing the change in a treated group with the change in a control group. You get the 2×2 means table, the DiD regression, a two-way fixed effects estimate and an event study that checks for parallel pre-trends.

Free · No sign-upReplaces Stata · R fixestWorks with your data
Updated · By Bibin Xavier

Data 640 × 5

Paste from Excel, or drop a CSV, TSV or Excel file here.
Example data 640 rows, 5 variables. Data stays in this browser tab.
Storetext · 80 levelsYearnumericTreatednumeric · codedSalesnumericStore_Sizenumeric
S012016172.71796
S012017167.51796
S012018173.91796
S012019171.11796
S012020178.81796
S012021181.81796
S012022180.61796
S0120231861796

Variables and options

Covariates (optional) 0 selected
Results update automatically when you change an option.

Results

640 rows · example data
Table 1

Difference-in-differences: group means

GroupBeforeAfterChange
Treated61.355 (n = 160)73.467 (n = 160)12.112
Control57.401 (n = 160)63.691 (n = 160)6.291
Difference3.9549.7765.821
Table 2

DiD regression (Clustered by unit (80 clusters) standard errors)

VariableCoefficientSEtp95% CI
Constant57.40061.097552.299< .001[55.2160, 59.5852]
Treated3.95441.39462.835.006[1.1784, 6.7303]
Post6.29060.232927.006< .001[5.8270, 6.7543]
Treated × Post (DiD)5.82120.320318.172< .001[5.1836, 6.4589]
Table 3

Two-way fixed effects (unit and time fixed effects)

EstimateCoefficientSEtp95% CI
Treatment effect (ATT)5.82120.321318.115< .001[5.1816, 6.4609]

Note. Clustered by unit. With treatment starting at the same time for all treated units, TWFE equals the canonical DiD; with staggered adoption it can be biased (Goodman-Bacon, 2021).

Outcome over time by group

Event study: effect relative to the period before treatment

Table 4

Event-study coefficients

Relative periodCoefficientSEp95% CI
-4-0.0550.753.942[-1.554, 1.444]
-3-0.5350.738.470[-2.003, 0.933]
-2-0.0420.736.954[-1.508, 1.423]
04.4450.682< .001[3.088, 5.802]
14.1200.691< .001[2.744, 5.496]
26.8880.696< .001[5.503, 8.272]
37.2000.652< .001[5.901, 8.499]

Note. Joint test that all pre-treatment coefficients are zero: F(3, 79) = 0.249, p = .861. Reference period: −1.

Interpretation

After treatment, the outcome of the treated group changed by 5.82 more than that of the control group (95% CI [5.18, 6.46]), which is statistically significant. The pre-treatment coefficients are jointly insignificant, consistent with parallel trends.

The difference-in-differences estimate was 5.82, 95% CI [5.18, 6.46], p < .001, with standard errors clustered by unit.

How to cite this tool

Using these results in a thesis, journal article, report or class assignment? Please cite this free tool so others can find it. It keeps the site free.

APA 7

Xavier, B. (2026). Difference-in-Differences (DiD) Analysis [Web application]. FreeStatisticalTools.com. https://freestatisticaltools.com/difference-in-differences-calculator/

BibTeX

@software{xavier_differenceindifferences_2026,
  author = {Xavier, Bibin},
  title = {Difference-in-Differences (DiD) Analysis},
  publisher = {FreeStatisticalTools.com},
  year = {2026},
  url = {https://freestatisticaltools.com/difference-in-differences-calculator/},
  note = {Web application}
}

Suggested sentence for your methods section: “The analysis was carried out with the free Difference-in-Differences (DiD) Analysis tool on FreeStatisticalTools.com (Xavier, 2026).”

What is difference-in-differences?

Difference-in-differences estimates a causal effect by comparing how an outcome changed for a group exposed to a treatment with how it changed for an unexposed group. The comparison removes stable differences between groups and common shocks over time.

When to use difference-in-differences

Use DiD to evaluate a policy, programme or event that affected some units and not others, when you observe both groups before and after.

Assumptions

  • Parallel trends: without treatment, both groups would have followed the same path (check the event study).
  • No anticipation and no spill-overs to the control group.
  • Treatment starts at the same time for all treated units in this tool; staggered adoption needs dedicated estimators.

How to set up your data

Long format: one row per unit and period with the outcome, a 0/1 treated-group indicator, the time variable and optionally a unit identifier.

How to use this tool

  1. Enter your data. Paste columns from Excel, Google Sheets or SPSS with variable names in the first row, or upload a CSV or Excel file. The example data shows the expected layout.
  2. Choose the variables. Select the outcome, treatment group indicator, value for the treated group and time variable.
  3. Set the options. Fill in first treated period.
  4. Read the results. Results update automatically. Read the plain-English interpretation, then use Copy table to paste APA-style tables into Word and Copy for the results sentence.

How to report difference-in-differences in APA style

Report the DiD estimate with clustered standard errors, the group means, and the event-study plot with the pre-trend test.

Frequently asked questions

What is the parallel trends assumption?

That without the treatment, the treated and control groups would have followed the same trend. Pre-treatment event-study coefficients close to zero support it.

How do I interpret the interaction coefficient?

The Treated × Post coefficient is the DiD estimate: the extra change in the outcome for the treated group after treatment.

What if units are treated at different times?

Staggered adoption can bias two-way fixed effects. Use estimators designed for it, such as Callaway and Sant’Anna (2021).

Related tools

Browse all categories