* Code from Williams, Allison, Moral-Benito paper * xtdpdml version 2.12 or later is required. version 13.1 *** Section 2 part 3: Sem code for Cornwell & Rupert use https://www3.nd.edu/~rwilliam/statafiles/wages, clear keep wks lwage union ed id t xtset id t reshape wide wks lwage union, i(id) j(t) sem (wks2 <- wks1@b1 lwage1@b2 union1@b3 ed@b4 Alpha@1 E2@1) /// (wks3 <- wks2@b1 lwage2@b2 union2@b3 ed@b4 Alpha@1 E3@1) /// (wks4 <- wks3@b1 lwage3@b2 union3@b3 ed@b4 Alpha@1 E4@1) /// (wks5 <- wks4@b1 lwage4@b2 union4@b3 ed@b4 Alpha@1 E5@1) /// (wks6 <- wks5@b1 lwage5@b2 union5@b3 ed@b4 Alpha@1 E6@1) /// (wks7 <- wks6@b1 lwage6@b2 union6@b3 ed@b4 Alpha@1), /// var(e.wks2@0 e.wks3@0 e.wks4@0 e.wks5@0 e.wks6@0) var(Alpha) /// cov(Alpha*(ed)@0) cov(Alpha*(E2 E3 E4 E5 E6)@0) /// cov(_OEx*(E2 E3 E4 E5 E6)@0) cov(E2*(E3 E4 E5 E6)@0) /// cov(E3*(E4 E5 E6)@0) cov(E4*(E5 E6)@0) cov(E5*(E6)@0) /// cov(union3*(E2)) cov(union4*(E2 E3)) cov(union5*(E2 E3 E4)) /// cov(union6*(E2 E3 E4 E5)) /// iterate(250) technique(nr 25 bhhh 25) noxconditional * Section 2 part 3: Equivalent xtdpdml code use https://www3.nd.edu/~rwilliam/statafiles/wages, clear xtset id t xtdpdml wks L.lwage, inv(ed) pre(L.union) ******************************************************* *** Section 4.1 -- Comparisons with AB, real data, using fiml and listwise use https://www3.nd.edu/~rwilliam/statafiles/bollenbrand, clear set matsize 7500 xtabond lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break black hisp estimates store gmm * FIML xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv fiml tfix store(fiml) /// inv(black hisp) ti(Adapted from Bollen & Brand Social Forces 2010) * Listwise deletion used instead of fiml xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(normal) /// inv(black hisp) gof ******************************************************* *** Section 4.2. Panel Model with fixed effects; Goodness of Fit measures. * Bollen & Brand Social Forces 2010 Fixed Effects Table 3 Model 2 p. 15 use https://www3.nd.edu/~rwilliam/statafiles/bollenbrand, clear xtdpdml lnwg hchild marr div, ylag(0) fiml tfix errorinv gof sto(baseline) estat scoretests xtdpdml lnwg hchild marr div, ylag(0) fiml tfix alphafree gof sto(modified) lrtest baseline_f modified_f, stats ******************************************************* *** 4.3 Fixed Effects vs Random Effects Models; Alternative to the Hausman Test use https://www3.nd.edu/~rwilliam/statafiles/bollenbrand, clear set matsize 7500 set more off * Random effects xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv fiml tfix re store(re) /// inv(black hisp) ti(Adapted from Bollen & Brand Social Forces 2010) * Fixed effects xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv fiml tfix store(fe) /// inv(black hisp) ti(Adapted from Bollen & Brand Social Forces 2010) esttab re_h fe_h , mtitles(Random Fixed) scalar(chi2_ms df_ms p_ms BIC AIC ) z lrtest re_f fe_f, stats ******************************************************* *4.4 Non-Normality use https://www3.nd.edu/~rwilliam/statafiles/bollenbrand, clear set matsize 7500 * Use vce(sbentler). Coefficients are the same as when listwise is used * Standard errors and GOF measures change xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(sbentler) vce(sbentler) /// inv(black hisp) gof * vce(sbentler) does NOT work with fiml capture noisily xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(sbentler) vce(sbentler) /// inv(black hisp) gof fiml * Produces the error message "vce(sbentler) not allowed with method(mlmv)" * Now use vce(robust). * Coefficients stay the same as when listwise is usedbut standard errors change. * In these particular examples vce(sbentler) and vce(robust) produce very * similar estimates of the standard errors. * But, few GOF measures are reported with vce(robust). xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(robust) /// inv(black hisp) vce(robust) gof * vce(robust) does work with fiml * Coefficients are the same as in example 4.1 using FIML but standard errors differ xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(robustfiml) /// inv(black hisp) vce(robust) gof fiml * Now use method(adf). Both coefficients and standard errors change. * But, won't converge for this example xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(adf) /// inv(black hisp) method(adf) gof * Also fiml will NOT work with adf capture noisily xtdpdml lnwg hchild marr div eduatt cursc snrpt snrft exppt expft break , /// constinv errorinv tfix store(adf2) /// inv(black hisp) method(adf) gof fiml * Produces the error message "You cannot specify both fiml and method(adf)"