------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\12.2.smcl log type: smcl opened on: 27 Mar 2020, 18:22:36 . **************************************************************************** . * Module 12: Cross-Classified Models - Stata Practical . * . * P12.2: A Cross-Classified Model of Attainment . * . * George Leckie . * Centre for Multilevel Modelling, 2011 . **************************************************************************** . * Stata do-file to replicate all analyses using runmlwin . * . * George Leckie . * Centre for Multilevel Modelling, 2013 . * http://www.bristol.ac.uk/cmm/software/runmlwin/ . **************************************************************************** . . * P12.2.1 Specifying and fitting the cross-classified model . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/12.2.dta", clear . . xtmixed attain || _all: R.schid || neighid:, mle variance Performing EM optimization: Performing gradient-based optimization: Iteration 0: log likelihood = -3178.3835 Iteration 1: log likelihood = -3178.3557 Iteration 2: log likelihood = -3178.3557 Computing standard errors: Mixed-effects ML regression Number of obs = 2,310 ------------------------------------------------------------- | No. of Observations per Group Group Variable | Groups Minimum Average Maximum ----------------+-------------------------------------------- _all | 1 2,310 2,310.0 2,310 neighid | 524 1 4.4 16 ------------------------------------------------------------- Wald chi2(0) = . Log likelihood = -3178.3557 Prob > chi2 = . ------------------------------------------------------------------------------ attain | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- _cons | .0753532 .0722216 1.04 0.297 -.0661987 .216905 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ _all: Identity | var(R.schid) | .075445 .0316491 .0331553 .1716755 -----------------------------+------------------------------------------------ neighid: Identity | var(_cons) | .1412201 .0218651 .104257 .191288 -----------------------------+------------------------------------------------ var(Residual) | .7990182 .0263652 .7489788 .8524007 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 207.44 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . . estimates store model1 . . . . * P12.2.2 Interpretation of the cross-classified model . . * P12.2.3 Calculating variance partition coefficients (VPC) and intra-class . * correlations (ICC) . . . . * P12.2.4 Predicting and examining school and neighbourhood effects . . predict v0, reffects level(_all) . . predict u0, reffects level(neighid) . . predict v0se, reses level(_all) . . predict u0se, reses level(neighid) . . egen v0rank = rank(v0) if pickone_school==1 (2293 missing values generated) . . egen u0rank = rank(u0) if pickone_neigh==1 (1786 missing values generated) . . sort v0rank . . list schid v0 v0se v0rank if pickone_school==1, noobs +---------------------------------------+ | schid v0 v0se v0rank | |---------------------------------------| | 1 -.4203102 .171911 1 | | 10 -.365078 .0963185 2 | | 20 -.3377112 .0829578 3 | | 9 -.249002 .0929058 4 | | 19 -.1888 .1061417 5 | |---------------------------------------| | 8 -.1046162 .0866322 6 | | 2 -.0737279 .0905647 7 | | 17 -.019355 .0857978 8 | | 7 .0397741 .0718181 9 | | 0 .0567248 .0947632 10 | |---------------------------------------| | 5 .101812 .0891645 11 | | 3 .1378104 .0890324 12 | | 16 .1448746 .1007428 13 | | 15 .1958423 .0816363 14 | | 6 .2301028 .1029594 15 | |---------------------------------------| | 18 .2421351 .0965405 16 | | 13 .6095243 .1101784 17 | +---------------------------------------+ . . summarize u0 if pickone_neigh==1 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- u0 | 524 -3.25e-10 .2348217 -.5765654 .695379 . . summarize u0 if pickone_neigh==1, detail BLUP r.e. for neighid: _cons ------------------------------------------------------------- Percentiles Smallest 1% -.4657722 -.5765654 5% -.3664438 -.5677193 10% -.2978136 -.5482477 Obs 524 25% -.1672465 -.4739119 Sum of Wgt. 524 50% -.0087194 Mean -3.25e-10 Largest Std. Dev. .2348217 75% .1416191 .6051867 90% .2975899 .6275532 Variance .0551412 95% .4239585 .6655953 Skewness .2630606 99% .5628019 .695379 Kurtosis 2.855424 . . display r(p75) - r(p25) .30886561 . . qnorm v0 if pickone_school==1, xlabel(-.4(.2).6) aspectratio(1) . . qnorm u0 if pickone_neigh==1, aspectratio(1) . . serrbar v0 v0se v0rank if pickone_school==1, /// > scale(1.96) yline(0) mvopts(mlabel(schid)) . . generate labheight = v0 + 1.96*v0se + 0.05 . . serrbar v0 v0se v0rank if pickone_school==1, scale(1.96) yline(0) /// > addplot(scatter labheight v0rank, /// > msymbol(none) mlabel(schid) /// > mlabposition(1) mlabangle(vertical) mlabcolor(navy)) /// > ytitle("Predicted school effect") xtitle("Rank") /// > legend(off) . . . serrbar u0 u0se u0rank if pickone_neigh==1, scale(1.96) yline(0) . . count if ((u0 + 1.96*u0se)<0 | (u0 - 1.96*u0se)>0) & pickone_neigh==1 19 . end of do-file