Run regression analyses in Stata with publication-ready output tables.
This skill produces reproducible regression analysis workflows in Stata, including model diagnostics and publication-ready tables using esttab or outreg2.
Follow these steps to complete the task:
Before generating any code, ask the user:
Based on the context, generate Stata code that:
regress, reghdfe, or xtreg as appropriateesttab or outreg2 with clear labelsAfter generating output:
* ============================================
* Regression Analysis with Stata
* ============================================
* Load data
use "data.dta", clear
* Summary stats
summarize y x1 x2 x3
* Main regression with clustered SEs
regress y x1 x2 x3, vce(cluster firm_id)
eststo model1
* Alternative specification with fixed effects
reghdfe y x1 x2 x3, absorb(firm_id year) vce(cluster firm_id)
eststo model2
* Export table
esttab model1 model2 using "results/regression_table.tex", replace se label
estout (for esttab)reghdfe (optional, for high-dimensional fixed effects)Install with:
ssc install estout
ssc install reghdfe