------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\15_Cross_Cl > assified_Models.smcl log type: smcl opened on: 27 Mar 2020, 18:00:10 . **************************************************************************** . * MLwiN MCMC Manual . * . * 15 Cross Classified Models . . . . . . . . . . . . . . . . . . . . . .215 . * . * Browne, W. J. (2009). MCMC Estimation in MLwiN, v2.26. Centre for . * Multilevel Modelling, University of Bristol. . **************************************************************************** . * Stata do-file to replicate all analyses using runmlwin . * . * George Leckie and Chris Charlton, . * Centre for Multilevel Modelling, 2012 . * http://www.bristol.ac.uk/cmm/software/runmlwin/ . **************************************************************************** . . * 15.1 Classifications and levels . . . . . . . . . . . . . . . . . . . .216 . . * 15.2 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . .217 . . * 15.3 The Fife educational dataset . . . . . . . . . . . . . . . . . . .217 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/xc1.dta", clear . . describe Contains data from http://www.bristol.ac.uk/cmm/media/runmlwin/xc1.dta obs: 3,435 vars: 11 21 Oct 2011 12:19 ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- vrq int %9.0g attain byte %9.0g pid int %9.0g sex byte %9.0g sc byte %9.0g sid byte %9.0g fed byte %9.0g choice byte %9.0g med byte %9.0g cons byte %9.0g pupil byte %9.0g ------------------------------------------------------------------------------- Sorted by: . . list attain pid sid pupil in 1/10 +----------------------------+ | attain pid sid pupil | |----------------------------| 1. | 2 1 1 39 | 2. | 8 1 1 37 | 3. | 6 1 1 48 | 4. | 6 1 1 41 | 5. | 4 1 1 7 | |----------------------------| 6. | 2 1 1 50 | 7. | 9 1 1 17 | 8. | 6 1 1 8 | 9. | 10 5 1 46 | 10. | 2 5 1 44 | +----------------------------+ . . runmlwin attain cons, /// > level3(sid: cons) level2(pid:) /// > level1(pupil: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 303 1 11.3 72 ----------------------------------------------------------- Run time (seconds) = 0.55 Number of iterations = 3 Log likelihood = -8666.0243 Deviance = 17332.049 ------------------------------------------------------------------------------ attain | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 5.588558 .1573136 35.52 0.000 5.280229 5.896887 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .4148371 .1510997 .1186872 .7109871 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 8.986666 .2174585 8.560455 9.412877 ------------------------------------------------------------------------------ . . runmlwin attain cons, /// > level3(sid: cons) level2(pid:) /// > level1(pupil: cons) /// > mcmc(on) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 303 1 11.3 72 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 1.81 Deviance (dbar) = 17291.83 Deviance (thetabar) = 17273.63 Effective no. of pars (pd) = 18.20 Bayesian DIC = 17310.02 ------------------------------------------------------------------------------ attain | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | 5.586465 .1613754 309 0.000 5.282391 5.922693 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .4928488 .208338 2402 .2212031 1.030093 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 8.99649 .2180419 5451 8.565801 9.429998 ------------------------------------------------------------------------------ . . . . * 15.4 A Cross-classified model . . . . . . . . . . . . . . . . . . . . .220 . . runmlwin attain cons, /// > level3(sid: cons) level2(pid: cons) /// > level1(pupil: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 303 1 11.3 72 ----------------------------------------------------------- Run time (seconds) = 0.61 Number of iterations = 4 Log likelihood = -8579.2043 Deviance = 17158.409 ------------------------------------------------------------------------------ attain | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 5.484828 .1541146 35.59 0.000 5.182769 5.786887 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .2687809 .1460812 -.0175329 .5550948 -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | 1.100592 .1926005 .7231016 1.478082 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 8.096222 .2014243 7.701438 8.491007 ------------------------------------------------------------------------------ . . runmlwin attain cons, /// > level3(sid: cons, residuals(v)) /// > level2(pid: cons, residuals(u)) /// > level1(pupil: cons) /// > mcmc(cc on) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (cross-classified) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 148 1 23.2 72 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 3.66 Deviance (dbar) = 16940.80 Deviance (thetabar) = 16833.53 Effective no. of pars (pd) = 107.26 Bayesian DIC = 17048.06 ------------------------------------------------------------------------------ attain | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | 5.508514 .1919313 206 0.000 5.110681 5.881994 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .4200779 .2197727 1155 .1403941 .9762861 -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | 1.144871 .2109528 1225 .7822415 1.599638 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 8.120436 .197473 3972 7.737964 8.519949 ------------------------------------------------------------------------------ . . mcmcsum [RP3]var(cons), detail [RP3]var(cons) ------------------------------------------------------------------------------ Percentiles Mean .4200779 0.5% .1003618 Thinned Chain Length 5000 MCSE of Mean .0050428 2.5% .1403941 Effective Sample Size 1155 Std. Dev. .2197727 5% .1623108 Raftery Lewis (2.5%) 7397 Mode .3439998 25% .269787 Raftery Lewis (97.5%) 4410 P(mean) 0.000 Brooks Draper (mean) 19538 P(mode) 0.000 50% .3732005 P(median) 0.000 75% .5141783 95% .8309478 97.5% .976286 99.5% 1.352075 ------------------------------------------------------------------------------ . . . . * 15.5 Residuals . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 . . egen pickone = tag(sid) . . egen v0rank = rank(v0) if pickone==1 (3416 missing values generated) . . serrbar v0 v0se v0rank if pickone==1, scale(0) yline(0) . . list sid v0 if v0rank==1 & pickone==1 +----------------+ | sid v0 | |----------------| 3325. | 19 -1.39007 | +----------------+ . . drop pickone . . egen pickone = tag(pid) . . egen u0rank = rank(u0) if pickone==1 (3287 missing values generated) . . serrbar u0 u0se u0rank if pickone==1, scale(0) yline(0) . . list pid u0 if u0rank==1 & pickone==1 +-----------------+ | pid u0 | |-----------------| 2545. | 139 -2.132843 | +-----------------+ . . drop v0* u0* pickone . . . . * 15.6 Adding predictors to the model . . . . . . . . . . . . . . . . . .225 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/xc1.dta", clear . . runmlwin attain cons vrq, /// > level3(sid: cons) level2(pid: cons) /// > level1(pupil: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 303 1 11.3 72 ----------------------------------------------------------- Run time (seconds) = 0.79 Number of iterations = 5 Log likelihood = -7427.3516 Deviance = 14854.703 ------------------------------------------------------------------------------ attain | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -10.05434 .2765236 -36.36 0.000 -10.59632 -9.512368 vrq | .1602103 .0027673 57.89 0.000 .1547864 .1656342 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .0075894 .021663 -.0348693 .050048 -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | .2648826 .060114 .1470613 .3827039 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 4.258025 .1053973 4.05145 4.4646 ------------------------------------------------------------------------------ . . runmlwin attain cons vrq, /// > level3(sid: cons) level2(pid: cons) /// > level1(pupil: cons) /// > mcmc(cc) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (cross-classified) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 148 1 23.2 72 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 3.91 Deviance (dbar) = 14724.55 Deviance (thetabar) = 14643.22 Effective no. of pars (pd) = 81.33 Bayesian DIC = 14805.88 ------------------------------------------------------------------------------ attain | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -10.0293 .2849077 3206 0.000 -10.57939 -9.458705 vrq | .160045 .0028313 3540 0.000 .1544902 .1655503 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .0192835 .0217508 349 .0007935 .0788979 -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | .2777144 .0628964 770 .1689811 .4163399 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 4.259644 .1034848 3993 4.058427 4.469845 ------------------------------------------------------------------------------ . . runmlwin attain cons vrq sc fed med choice, /// > level3(sid: cons) level2(pid: cons) /// > level1(pupil: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 303 1 11.3 72 ----------------------------------------------------------- Run time (seconds) = 0.65 Number of iterations = 3 Log likelihood = -7377.2036 Deviance = 14754.407 ------------------------------------------------------------------------------ attain | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -9.7401 .2873173 -33.90 0.000 -10.30323 -9.176968 vrq | .1552553 .00278 55.85 0.000 .1498067 .160704 sc | .0276984 .00335 8.27 0.000 .0211326 .0342642 fed | .220777 .0925128 2.39 0.017 .0394553 .4020988 med | .2179099 .0867628 2.51 0.012 .047858 .3879618 choice | -.1189545 .0551383 -2.16 0.031 -.2270236 -.0108855 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | 0 0 0 0 -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | .2031402 .0480276 .1090079 .2972726 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 4.162167 .1028999 3.960487 4.363848 ------------------------------------------------------------------------------ . . runmlwin attain cons vrq sc fed med choice, /// > level3(sid: cons, residuals(v)) level2(pid: cons) /// > level1(pupil: cons) /// > mcmc(cc) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (cross-classified) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ sid | 19 92 180.8 290 pid | 148 1 23.2 72 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 4.24 Deviance (dbar) = 14650.93 Deviance (thetabar) = 14573.61 Effective no. of pars (pd) = 77.32 Bayesian DIC = 14728.25 ------------------------------------------------------------------------------ attain | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -9.713235 .291583 3419 0.000 -10.28694 -9.139135 vrq | .1551546 .0028056 3942 0.000 .1497194 .1606532 sc | .0270923 .0033776 3948 0.000 .020631 .0336961 fed | .2154045 .093588 5833 0.009 .0282987 .396706 med | .2200657 .0862474 5272 0.007 .0518295 .3904517 choice | -.1218226 .0555688 5161 0.014 -.227621 -.0124454 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 3: sid | var(cons) | .0157162 .0183386 302 .000767 .0666246 -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | .2095304 .052767 591 .1201419 .328534 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 4.169144 .1022418 3835 3.972907 4.376141 ------------------------------------------------------------------------------ . . egen pickone = tag(sid) . . egen v0rank = rank(v0) if pickone==1 (3416 missing values generated) . . serrbar v0 v0se v0rank if pickone==1, scale(0) yline(0) . . list sid v0 if v0rank==1 & pickone==1 +-----------------+ | sid v0 | |-----------------| 3325. | 19 -.1095984 | +-----------------+ . . gen school19 = (sid==19) . . sort pid pupil . . runmlwin attain cons vrq sc fed med choice school19, /// > level2(pid: cons) /// > level1(pupil: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ pid | 148 1 23.2 72 ----------------------------------------------------------- Run time (seconds) = 0.67 Number of iterations = 3 Log likelihood = -7370.9298 Deviance = 14741.86 ------------------------------------------------------------------------------ attain | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -9.650131 .2888852 -33.40 0.000 -10.21634 -9.083926 vrq | .1547908 .0027836 55.61 0.000 .1493351 .1602465 sc | .0268615 .0033494 8.02 0.000 .0202968 .0334261 fed | .213288 .0923322 2.31 0.021 .0323202 .3942558 med | .224737 .0866031 2.60 0.009 .0549981 .394476 choice | -.1235296 .0548632 -2.25 0.024 -.2310594 -.0159997 school19 | -.6225944 .2457284 -2.53 0.011 -1.104213 -.1409756 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | .1986834 .0464089 .1077237 .2896431 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 4.156813 .1021516 3.9566 4.357027 ------------------------------------------------------------------------------ . . runmlwin attain cons vrq sc fed med choice school19, /// > level2(pid: cons) /// > level1(pupil: cons) /// > mcmc(on) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 3435 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ pid | 148 1 23.2 72 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 3.85 Deviance (dbar) = 14650.67 Deviance (thetabar) = 14576.32 Effective no. of pars (pd) = 74.35 Bayesian DIC = 14725.02 ------------------------------------------------------------------------------ attain | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -9.647805 .2942116 3526 0.000 -10.22027 -9.055028 vrq | .1548017 .0028464 3837 0.000 .1491229 .1604556 sc | .0268257 .0034105 4306 0.000 .0200203 .0334457 fed | .2147797 .0926662 4820 0.012 .0329981 .400859 med | .2249248 .0859953 4277 0.004 .0544691 .3920839 choice | -.1254885 .055668 4427 0.011 -.2354263 -.0148332 school19 | -.6162912 .2435422 2302 0.007 -1.085829 -.1368533 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 2: pid | var(cons) | .2022185 .0512953 690 .1138046 .3170045 -----------------------------+------------------------------------------------ Level 1: pupil | var(cons) | 4.168522 .103656 3912 3.972646 4.372459 ------------------------------------------------------------------------------ . . . . * 15.7 Current restrictions for cross-classified models . . . . . . . . .229 . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . .230 . . . . . . **************************************************************************** . exit end of do-file