set matsize 10000 cd "C:\Users\sovid\OneDrive - The University of Kansas\Lectures\Soc910_AdvStat\examples" use soc910_data_3_KLI_FEM.dta, clear egen count = count(pid), by(pid) keep if count>=2 xtset pid year xtsum lnwage age female reg lnwage age female i.educ xtreg lnwage age female i.educ, fe xtreg lnwage age female i.educ, fe vce(r) reg lnwage age female i.educ if pid<20000 est store OLS xtreg lnwage age female i.educ if pid<20000, fe vce(r) est store m1 reg lnwage age female i.educ i.pid if pid<20000, vce(r) est store m2 estout OLS m1 m2 xtreg lnwage c.age##i.female i.educ, fe vce(r) * Group-specific mean-centering for independent variables * You can estimate time-invariante variables along with time-variant variables. egen mlnwage = mean(lnwage), by(pid) gen clnwage = lnwage - mlnwage egen mage = mean(age), by(pid) tab educ, gen(educ) egen meduc1 = mean(educ1), by(pid) egen meduc2 = mean(educ2), by(pid) egen meduc3 = mean(educ3), by(pid) egen meduc4 = mean(educ4), by(pid) gen cage = age-mage gen ceduc1 = educ1 - meduc1 gen ceduc2 = educ2 - meduc2 gen ceduc3 = educ3 - meduc3 gen ceduc4 = educ4 - meduc4 reg lnwage cage ceduc2-ceduc4 female mage meduc1-meduc4 reg lnwage c.cage##i.female ceduc2-ceduc4 * Hausman test xtreg lnwage age female i.educ, fe v(r) estimates store fe xtreg lnwage age female i.educ, re v(r) estimates store re hausman fe re reg lnwage age female i.educ estimate store OLS xtreg lnwage age female i.educ, fe vce(r) estimate store FEM xtreg lnwage age female i.educ, re vce(r) estimate store REM xtreg lnwage age female i.educ, be estimate store BEM estout OLS FEM REM BEM, cells(b(star fmt(%9.4f)) se(par)) /// stats(r2_a N, fmt(%9.4f %9.0g) labels(R-squared)) /// legend label collabels(none) varlabels(_cons Constant)