* Test for cross-sectional dependence xtcsd, pesaran abs * Estimate using Panel-Corrected Standard Errors (PCSE) xtpcse y x1 x2 x3 Use code with caution. Summary Workflow Cheat Sheet Stata Command xtset id time Defines entity and time dimensions Descriptives xtsum varlist Splits variance into within/between components Static Panel xtreg y x, fe / xtreg y x, re Runs fixed or random effects regressions LM Test xttest0 Compares Pooled OLS vs. Random Effects Hausman Test hausman fe_model re_model Compares Fixed Effects vs. Random Effects Robustness vce(cluster id) Controls for heteroskedasticity and autocorrelation Dynamic Panel xtabond / xtdpdsys Estimates models with lagged dependent variables
* 1. Run FE and store results xtreg y x1 x2, fe estimates store fe_model * 2. Run RE and store results xtreg y x1 x2, re estimates store re_model * 3. Perform the test hausman fe_model re_model Use code with caution. : A low p-value (
Descriptive analysis summarize xtsum
ssc install xttest3 xtreg GDP inflation trade_openness, fe xttest3 Use code with caution.
Pooled OLS regress gdp fdi trade gcf eststo pooled stata panel data
Generate data (or import real data) do "generate_data.do"
Note: FE logit drops panels with no variation in the outcome. * Test for cross-sectional dependence xtcsd, pesaran abs
Pooled OLS ignores the panel structure entirely, treating all observations as independent. regress GDP inflation trade_openness Use code with caution.
When you run xtreg, fe , Stata automatically includes an F-test at the bottom of the output window: Perform the test hausman fe_model re_model Use code
Before typing a single command, you must grasp how Stata "thinks" about panel data.
| Variable | Coef. | Std. Err. | t | P>|t| | |----------|-------|-----------|----|----| | fdi | 0.098 | 0.018 | 5.44 | 0.000 | | trade | 0.006 | 0.002 | 3.00 | 0.003 | | gcf | 0.031 | 0.009 | 3.44 | 0.001 | | _cons | 6.892 | 0.189 | 36.46 | 0.000 |