** Pooled-Nested Example: Contextual Earnings Models for White Females log using x:\Pooled_Nested_example_out.log, replace infix raceth 1 female 2 occ80 3-5 ind2d 6-7 ernuslwk 8-11 ed 12-13 hrsusual 14-15 potexp 16-17 /// potexpsq 18-21 public 22 married 23 kids 24 skill 25-31 pfem 32-39 phisp 40-47 /// pblk 48-55 using "s:\fac\rlk\703\occearnwf.dat" xi i.ind2d,noomit renpfix _Iind2d_ ind summarize global ivars = "ed hrsusual potexp potexpsq public married kids skill pfem pblk phisp" regress ernuslwk $ivars ** COMMENT Lagrange-Multiplier test for Occupation Error lmtest ernuslwk 1 occ80 ** COMMENT Run FEM for Occupation Error xtreg ernuslwk $ivars, fe i(occ80) ** COMMENT Run REM for Occupation Error xtmixed ernuslwk $ivars || occ80: ** COMMENT Lagrange-Multiplier test for Industry error lmtest ernuslwk 1 ind2d ** COMMENT Run FEM for Industry Error xtreg ernuslwk $ivars, fe i( ind2d) est store fixed ** COMMENT Run REM for Industry Error xtmixed ernuslwk $ivars || ind2d: est store random ** COMMENT Hausman test of FEM vs. REM for Industry Error hausman fixed random, eq(1:1) ** COMMENT Lagrange-Multiplier test for Occupation & Industry Errors lmtest ernuslwk 2 occ80 ind2d ** COMMENT Run REM for Occupation Error and FEM for Industry Error xtmixed ernuslwk $ivars ind1-ind35 || occ80: mixedvars glsbeta ernuslwk ** COMMENT Get 1 REM component Buse's R Squared and Squared Correlation Observed, Predicted Y busepool ernuslwk 1 occ80 ** COMMENT Run REM for both Occupation Error and Industry Error xtmixed ernuslwk $ivars || _all: R.ind2d || occ80: glsbeta ernuslwk ** COMMENT Get 2 REM component Buse's R Squared and Squared Correlation Observed, Predicted Y busepool ernuslwk 2 ind2d occ80 ** COMMENT F-tests for 1 & 2 Component FEMs for Occ & Industry Errors w/o Context Measures global ivars = "ed hrsusual potexp potexpsq public married kids" femftest ernuslwk ind2d occ80 ** COMMENT Get OLS Corrected Standard Errors for 1 Component Clustering by Occupation global ivars = "ed hrsusual potexp potexpsq public married kids skill pfem pblk phisp" regress ernuslwk $ivars, cluster(occ80) ** COMMENT Get OLS Corrected Standard Errors for 2 Component Clustering by Occupation & Industry egen id2comp = group(occ80 ind2d) regress ernuslwk $ivars, cluster(id2comp)