Panel Data Difference-in-Differences (Panel DiD / TWFE)
Panel Data Difference-in-Differences Estimator · Also known as: Two-Way Fixed Effects DiD, TWFE, Panel DiD, Panel Diff-in-Diff
Panel Data Difference-in-Differences extends the classic two-period DiD design to settings with multiple units observed across many time periods. By absorbing unit-level fixed effects and time fixed effects simultaneously, it isolates the causal effect of a treatment or policy change while controlling for both time-invariant unit heterogeneity and common time shocks affecting all units.
Read the full method
Sign in with a free account to read this section.
Method map
The neighbourhood of related methods — select a node to explore.
+9 more
When to use it
Use Panel DiD when you have a balanced or unbalanced panel of units observed over multiple time periods, a treatment that switches on for some units (staggered or simultaneous) while others serve as controls, and an outcome measured repeatedly for each unit. It is well-suited to policy evaluation, labour economics, and health research where administrative panel data are available. It is not appropriate when you have only a single pre- or post-period (use basic DiD instead), when all units are treated at the same time (no within-period variation), when fewer than roughly 40 units are clustered, or when treatment adoption is driven by outcome trends (violating parallel trends). Be cautious with staggered adoption: in heterogeneous-effects settings the TWFE estimate can be a misleading weighted average; consider modern staggered DiD estimators in that case.
Strengths & limitations
- Controls simultaneously for unit-level time-invariant confounders and period-level common shocks via two-way fixed effects.
- Exploits rich panel variation, yielding more precise estimates than two-period designs when many units and periods are available.
- Transparent and interpretable: the treatment effect is a single regression coefficient with a clear counterfactual logic.
- Widely accepted in economics and social sciences; journals expect the TWFE specification as a standard causal-inference tool.
- Can accommodate time-varying covariates alongside fixed effects to further reduce residual confounding.
- The parallel-trends assumption is strong and untestable for the post-treatment period; any divergence in trends biases the estimate.
- Standard TWFE can produce misleading estimates under staggered treatment adoption with heterogeneous treatment effects, because late adopters can serve as controls for early adopters with negative implicit weights.
- Requires repeated observations of the same units, which is not always available; cross-sectional data cannot support this design.
- Clustering standard errors at the unit level requires enough clusters (typically 30+); too few clusters make inference unreliable even with large N×T.
- Does not handle violations of the stable unit treatment value assumption (SUTVA): spillovers between treated and control units will contaminate the estimate.
Frequently asked
How does Panel DiD differ from basic two-period DiD?
Basic DiD uses one pre- and one post-period for two groups and relies on a single interaction term. Panel DiD generalises this to many units and many periods, replacing the group and time dummies with full unit and time fixed effects. This absorbs richer heterogeneity and allows testing of parallel pre-trends, but also requires checking for problems specific to multi-period settings, such as serial correlation and staggered-adoption bias.
What is two-way fixed effects (TWFE)?
TWFE is the regression specification underlying Panel DiD. It includes a full set of unit fixed effects (one per panel unit) and a full set of time fixed effects (one per period), together with the treatment indicator. The unit fixed effects remove permanent between-unit differences; the time fixed effects remove period-level shocks common to all units. The treatment coefficient is then identified from within-unit variation over time, net of any common trend.
Why do I need to cluster standard errors?
Bertrand, Duflo, and Mullainathan (2004) showed that outcomes for the same unit across years are serially correlated. If standard errors are computed assuming independence across observations, they can be three to eight times too small, producing t-statistics far above conventional thresholds even under the null. Clustering at the unit (or treatment-assignment) level corrects for this by allowing arbitrary within-cluster correlation.
Is Panel DiD valid with staggered treatment timing?
The standard TWFE estimator is valid only if treatment effects are homogeneous across cohorts and time. When effects are heterogeneous — which is common — the TWFE coefficient is a weighted average of cohort-specific ATTs where some weights can be negative, potentially reversing the sign of the estimate. Modern staggered DiD estimators (Callaway & Sant'Anna, Sun & Abraham, Borusyak et al.) avoid these negative weights and should be preferred in heterogeneous settings.
How do I test the parallel-trends assumption?
The standard diagnostic is an event-study plot: include leads (lags of future treatment) and lags (periods after treatment) in the regression and plot their coefficients. If pre-treatment coefficients (leads) are jointly close to zero and statistically insignificant, the parallel-trends assumption is supported for the pre-period. Note this is a necessary but not sufficient condition — parallel pre-trends do not guarantee parallel counterfactual trends after treatment.
Sources
- Angrist, J. D., & Pischke, J.-S. (2009). Mostly Harmless Econometrics: An Empiricist's Companion. Princeton University Press. ISBN: 978-0691120355
- Bertrand, M., Duflo, E., & Mullainathan, S. (2004). How Much Should We Trust Differences-in-Differences Estimates? Quarterly Journal of Economics, 119(1), 249-275. DOI: 10.1162/003355304772839588 ↗
How to cite this page
ScholarGate. (2026, June 3). Panel Data Difference-in-Differences Estimator. ScholarGate. https://scholargate.app/en/causal-inference/panel-data-difference-in-differences
Which method?
Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.
- Difference-in-DifferencesEconometrics↔ compare
- Panel Fixed EffectsEconometrics↔ compare
- Propensity Score MatchingResearch Statistics↔ compare
- Synthetic Control MethodCausal inference↔ compare