xtreg y x1 x2, re
Panel errors are correlated within units. Always use cluster-robust at the unit level.
xtreg y x1 x2, fe vce(cluster id)
For multi-way clustering (e.g., id + year):
vce(cluster id year) // Stata 17+
// Or use ivreg2 with cluster(id year)
xtreg y x1 x2, fe
Before diving into code, it is crucial to define what makes a panel data technique "exclusive." In Stata terminology, this typically involves: stata panel data exclusive
The Exclusive Advantage: While basic panel commands control for individual heterogeneity, exclusive techniques handle cross-sectional dependence, non-stationarity, and endogenous treatment assignment—the trifecta of real-world economic data.
| 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) | xtreg y x1 x2, re
To follow the "exclusive" path, you need to escape the xtreg, fe comfort zone. Begin with a robust environment:
* Set memory and panel structure
clear all
set maxvar 12000
use "your_exclusive_panel.dta", clear
Exclusive Tip: Most researchers ignore xtdes and xtpattern. Don't. Use: Panel errors are correlated within units
xtpattern, gen(pat)
tabulate pat
This reveals missing data patterns exclusive to your panel. If you see pattern "111101", you need specialized unbalanced panel routines (xtreg uses them automatically, but GMM does not).
Alternative to FE when errors follow random walk or for dynamic panels.
gen dy = d.y
gen dx1 = d.x1
reg dy dx1, vce(cluster id)
Stata’s xtreg with fd option:
xtreg y x1 x2, fd