| Pitfall | Consequence | Solution | |---------|------------|----------| | Forgetting xtset | Commands fail | Always start with xtset | | Mistaking i.id for FE | Inefficient / wrong model | Use xtreg, fe | | Using FE with time-invariant X | Variables dropped | Use RE or correlated random effects | | Ignoring serial correlation | Biased standard errors | Cluster or use xtregar | | Over-interpreting between R-squared in FE | Misleading | Focus on within R-squared | | Using xtreg, fe with T=2 and many units | Low power | Consider first-differences | | Applying RE when Hausman rejects | Inconsistent estimates | Use FE or Hausman-Taylor | | No lag structure in dynamic panel | Omitted variable bias | Include lags or use GMM |
Stata will report if the panel is (same number of time points for all entities) or unbalanced . 4. Core Panel Commands Once set, you can use specialized xt commands :
Understanding Panel Data Analysis in Stata: A Comprehensive Guide
xtreg ln_wage hours age tenure, fe estimates store fe stata panel data
: The xtline command creates a separate line graph for every entity in your dataset, which is great for spotting outliers . xtline gdp 3. Choosing the Right Model
Modified Wald test for groupwise heteroskedasticity in FE models.
This model uses only cross‑sectional variation and is occasionally useful for checking the source of variation in the data, but it is less common in applied work. xtline gdp 3
If these issues are present, you should use robust standard errors. The vce(robust) or vce(cluster panelvar) options can be used with xtreg to produce standard errors that are robust to heteroskedasticity and within-panel correlation. For more complex issues (e.g., cross-sectional dependence), you might use:
This ignores the panel structure and pools all data together. It is simple but often biased if unobserved unit-specific characteristics exist (omitted variable bias).
reshape long stubname, i(panelvar) j(timevar) If these issues are present, you should use
xtreg income education experience, fe estimates store fe_model xtreg income education experience, re estimates store re_model hausman fe_model re_model Use code with caution. If the -value is significant (
xtline ln_wage if idcode <= 20, overlay legend(off) title("Individual Wage Trajectories")