Stata Panel Data Exclusive May 2026
Controls for time-invariant unobserved heterogeneity (unit-specific intercepts). Two equivalent estimators:
Within estimator (demeaned):
xtreg y x1 x2, fe
LSDV (least squares dummy variables) – avoid with many units: stata panel data exclusive
reg y x1 x2 i.id i.year
Key options:
xtreg y x1 x2 i.year, fe robust // cluster-robust SE
xtreg y x1 x2 i.year, fe vce(cluster id) // equivalent
xtreg y x1 x2, fe vce(bootstrap, reps(200)) // alternative
After FE:
estimates store fe
predict u, u // unit-specific fixed effects (residuals)
predict xb, xb // linear prediction
xtline xb, overlay // fitted trends by unit
Testing joint significance of FEs:
testparm i.id // after LSDV regression
Panel data (longitudinal data) combines cross-sectional units observed over time. Stata’s xt suite provides a dedicated, efficient workflow. This text covers all essential steps without extraneous filler. LSDV (least squares dummy variables) – avoid with
xtreg y x1 x2, fe vce(cluster panel_id)
xtreg y x1 x2 i.year, fe
xtserial y x1 x2
xttest3
xtunitroot llc var1
| Mistake | Correct |
|---------|---------|
| Using reg without clustering | xtreg, fe robust or reg, vce(cluster id) |
| Including time-invariant vars in FE | Dropped automatically – use RE or hybrid |
| Hausman with non-spherical errors | Use xtoverid after RE |
| Ignoring serial correlation | Use xtreg, fe with lagged DV or xtserial |
| GMM with too many instruments | Collapse instruments: collapse option in xtabond2 (external) |