EconStatsCraft › Difference-in-differences

Difference-in-differences

The workhorse of policy evaluation. Reports the 2×2 table, the two-way fixed-effects regression, an event study by period, and an explicit parallel-trends check.

What it needs

The intuition

A before-after comparison confuses the policy with everything else that happened. A treated-versus-untreated comparison confuses the policy with pre-existing differences. Doing both and subtracting kills each problem with the other - provided the two groups would have moved in parallel absent the policy, which is the one thing you cannot test.

When to use it

A policy hits some units and not others at a known date, and you have data before and after for both.

Where the estimator comes from

With potential outcomes, \mathrm{ATT}=E[Y^1-Y^0\mid D=1]. The counterfactual E[Y^0_{\text{post}}\mid D=1] is unobserved; parallel trends assumes it equals E[Y_{\text{pre}}\mid D=1]+\bigl(E[Y_{\text{post}}\mid D=0]-E[Y_{\text{pre}}\mid D=0]\bigr). Substituting gives the difference of differences. In regression form, y_{it}=\alpha+\gamma\,\text{Treat}_i+\lambda\,\text{Post}_t+\delta(\text{Treat}_i\times\text{Post}_t)+u_{it}, and \delta=\mathrm{ATT}. Two-way fixed effects generalises this by absorbing arbitrary unit and period effects.

The model

y_{it}=\alpha+\gamma\,\text{Treat}_i+\lambda\,\text{Post}_t+\delta\,(\text{Treat}_i\times\text{Post}_t)+u_{it},\qquad \delta=\text{ATT}

What it assumes

Statistical properties

How to read the output

A worked reading

The 2×2 table does the whole job in four numbers: treated regions go from 23.7768 to 30.8688, a change of 7.0921; controls go from 21.8280 to 24.7728, a change of 2.9448; the difference of the differences is 4.1473. The regression returns exactly that, with a standard error of 0.1590 and a 95% interval of [3.8357, 4.4589], and the two-way fixed-effects specification reproduces it to four decimals - which is the point, since they are the same estimator written two ways. The event study is where the credibility sits rather than the coefficient: the pre-treatment effects are -0.1138, -0.0184 and 0.3305 against a 2017 baseline, none of them significant and all within a third of a unit of zero. That is what a defensible parallel-trends story looks like, and it is evidence for the assumption rather than proof of it.

Symptom → diagnosis → what to do

If you see thisIt meansDo this
Pre-treatment event-study coefficients are significantParallel trends failsUnit-specific trends, another control group, or abandon the design
Staggered treatment timingTWFE can be badly biasedCallaway–Sant'Anna or stacked DiD
Few treated clustersSEs unreliableWild cluster bootstrap, or randomisation inference
Group composition changes over timeCompositional confoundUse a balanced panel of the same units
Another policy hit the same group at the same dateConfoundedNo statistical fix - argue institutionally
Effect appears BEFORE treatmentAnticipation, or mis-dated treatmentCheck the timing; consider excluding the anticipation window

Common mistakes

Where to read this properly

See also

Staggered difference-in-differences, the moment units are treated at different dates - which is when the estimator on this page stops being the right one. Panel regression, for the two-way fixed-effects machinery underneath. If you have a single treated unit and many candidate controls, synthetic control is the method to read about; it is not in this library.

Related Causal

Spatial autocorrelation · Spatial regression · Heckman selection · Instrumental variables (2SLS) · Staggered difference-in-differences · Regression discontinuity · Matching & weighting · Oaxaca–Blinder decomposition

All analyses

Charts

Line chart · Area chart · Bar chart · Stacked bar · Scatter plot · Bubble chart · Histogram · Box plot · Pie chart · Heat map · Rebased to 100 · Lorenz curve and Gini

Maps

World map · Bivariate map · Flow map · India - state map · India - district map

Explore

Descriptive statistics · Summary by group · Two-way table · Classical statistical tests

Regression

Multiple regression (OLS) · Logit / Probit · Tobit (censored) · Truncated regression · Multinomial logit · Ordered logit / probit · Quantile regression · Poisson / Negative binomial

Time series - one series

Time-varying coefficients (Kalman) · Unit root tests · Correlogram (ACF / PACF) · ARIMA / SARIMA · Rolling-origin cross-validation · Theta method · Unobserved components · STL forecasting · Forecast combination · Markov regime switching · Change frequency (resample) · ARCH / GARCH volatility · Decompose & filter · Spectral analysis · Exponential smoothing · Forecast accuracy

Time series - several series

Yield curve (Nelson–Siegel / Svensson) · Dynamic factor model · Dynamic regression (ARIMAX) · Structural VAR · VAR · Granger causality · Cointegration · VECM · ARDL & bounds test

Panel data

Panel regression · Panel cointegration tests · Heterogeneous panel: Mean Group & PMG · Gravity model of trade · Dynamic panel GMM · Panel diagnostics · Panel unit-root tests

Multivariate statistics

Principal components (PCA) · Factor analysis · Cluster analysis

Marketing research

Conjoint analysis · MaxDiff (best–worst scaling) · TURF - reach of a product line · Price sensitivity (Van Westendorp) · Market basket analysis · Perceptual map · Scale reliability (Cronbach’s alpha) · Key driver analysis

Causal

Spatial autocorrelation · Spatial regression · Heckman selection · Instrumental variables (2SLS) · Difference-in-differences · Staggered difference-in-differences · Regression discontinuity · Matching & weighting · Oaxaca–Blinder decomposition

Finance & risk

Black–Scholes option pricing · Bond price, duration & convexity · Merton distance to default · EMI / home loan planner · CAPM / beta estimation · Multi-factor model · Portfolio optimization · Value at Risk & Expected Shortfall · Performance & drawdown · Time value of money & NPV/IRR · Equity valuation (DDM, FCF, residual income) · Cost of capital (WACC) · Binomial option pricing · Option strategies (payoff & profit) · Forwards, futures & swaps · Credit risk & Basel capital · Extreme value theory (tail risk)

Actuarial

Life table · Life annuity · Life insurance pricing · Chain ladder reserving · Buhlmann credibility · Survival analysis · Mortality graduation · Aggregate loss model · Ruin probability · Multi-state Markov model · Loss severity fitting

Tests & breaks

Monte Carlo experiment · F-test, Wald & Chow · Structural breaks & stability

Machine learning

Regression vs machine learning · Ridge / Lasso / Elastic Net · Random forest · Gradient boosting

Open the workspace →

Starting engine…

EconStatsCraft rigorous, plain-spoken econometrics

Econometrics that explains itself.

Regression, panel data, time series and the whole battery of tests. Every result is followed by a verdict you can defend.

Load a dataset to see it here.