------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\2_Single_Le > vel_Normal_Response_Modelling.smcl log type: smcl opened on: 27 Mar 2020, 17:43:46 . **************************************************************************** . * MLwiN MCMC Manual . * . * 2 Single Level Normal Response Modelling . . . . . . . . . . . . . . .21 . * . * 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/ . **************************************************************************** . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . describe Contains data from http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta obs: 4,059 vars: 10 21 Oct 2011 12:19 ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- school byte %9.0g School ID student int %9.0g Student ID normexam float %9.0g Age 16 exam score (normalised) cons byte %9.0g Constant standlrt float %9.0g Age 11 exam score (standardised) girl byte %9.0g Girl schgend byte %9.0g schgend School gender avslrt float %9.0g School average LRT score schav byte %9.0g schav School average LRT score (3 categories) vrband byte %9.0g vrband Age 11 verbal reasoning level ------------------------------------------------------------------------------- Sorted by: . . runmlwin normexam cons standlrt, /// > level2(school:) /// > level1(student: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Run time (seconds) = 0.64 Number of iterations = 2 Log likelihood = -4880.2547 Deviance = 9760.5094 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.0011911 .0126392 -0.09 0.925 -.0259635 .0235812 standlrt | .5950568 .012727 46.76 0.000 .5701124 .6200012 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .6484188 .0143933 .6202084 .6766292 ------------------------------------------------------------------------------ . . . . * 2.1 Running the Gibbs Sampler . . . . . . . . . . . . . . . . . . . . . 26 . runmlwin normexam cons standlrt, /// > level2(school:) /// > level1(student: cons) /// > mcmc(on) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 1.86 Deviance (dbar) = 9763.52 Deviance (thetabar) = 9760.51 Effective no. of pars (pd) = 3.01 Bayesian DIC = 9766.53 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.001237 .0126456 5612 0.460 -.0262346 .0231251 standlrt | .5952243 .0126118 4991 0.000 .5711035 .6200438 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .6488693 .0146139 4887 .6213565 .6785568 ------------------------------------------------------------------------------ . . mcmcsum, trajectories . . . . . * 2.2 Deviance statistic and the DIC diagnostic . . . . . . . . . . . . . 28 . . . * 2.3 Adding more predictors . . . . . . . . . . . . . . . . . . . . . . .29 . . gen boysch = (schgend==2) . . gen girlsch = (schgend==3) . . runmlwin normexam cons standlrt girl boysch girlsch, /// > level2(school:) /// > level1(student: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Run time (seconds) = 0.64 Number of iterations = 2 Log likelihood = -4836.0976 Deviance = 9672.1952 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.1608578 .0239369 -6.72 0.000 -.2077733 -.1139424 standlrt | .5910472 .0126182 46.84 0.000 .5663161 .6157784 girl | .1326419 .0342934 3.87 0.000 .0654282 .1998557 boysch | .1825543 .0425421 4.29 0.000 .0991734 .2659353 girlsch | .1680105 .032571 5.16 0.000 .1041726 .2318485 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .6344631 .0140835 .6068599 .6620664 ------------------------------------------------------------------------------ . . runmlwin normexam cons standlrt girl boysch girlsch, /// > level2(school:) /// > level1(student: cons) /// > mcmc(on) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 2.12 Deviance (dbar) = 9678.21 Deviance (thetabar) = 9672.20 Effective no. of pars (pd) = 6.01 Bayesian DIC = 9684.22 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | -.1609463 .0239465 5528 0.000 -.2076941 -.1150852 standlrt | .5910219 .0126554 4461 0.000 .5662505 .6156689 girl | .1320818 .034556 5442 0.000 .0627375 .1995954 boysch | .182375 .0427864 5570 0.000 .0997827 .2658948 girlsch | .1684616 .0321361 5383 0.000 .1072672 .2302701 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .6356412 .0142819 5037 .6086803 .664869 ------------------------------------------------------------------------------ . . . . . * 2.4 Fitting school effects as fixed parameters . . . . . . . . . . . . .32 . . tab school, gen(s) School ID | Freq. Percent Cum. ------------+----------------------------------- 1 | 73 1.80 1.80 2 | 55 1.36 3.15 3 | 52 1.28 4.43 4 | 79 1.95 6.38 5 | 35 0.86 7.24 6 | 80 1.97 9.21 7 | 88 2.17 11.38 8 | 102 2.51 13.90 9 | 34 0.84 14.73 10 | 50 1.23 15.96 11 | 62 1.53 17.49 12 | 47 1.16 18.65 13 | 64 1.58 20.23 14 | 198 4.88 25.10 15 | 91 2.24 27.35 16 | 88 2.17 29.51 17 | 126 3.10 32.62 18 | 120 2.96 35.58 19 | 55 1.36 36.93 20 | 39 0.96 37.89 21 | 73 1.80 39.69 22 | 90 2.22 41.91 23 | 28 0.69 42.60 24 | 37 0.91 43.51 25 | 73 1.80 45.31 26 | 75 1.85 47.15 27 | 39 0.96 48.12 28 | 57 1.40 49.52 29 | 79 1.95 51.47 30 | 42 1.03 52.50 31 | 49 1.21 53.71 32 | 42 1.03 54.74 33 | 77 1.90 56.64 34 | 26 0.64 57.28 35 | 38 0.94 58.22 36 | 70 1.72 59.94 37 | 22 0.54 60.48 38 | 54 1.33 61.81 39 | 48 1.18 63.00 40 | 71 1.75 64.75 41 | 60 1.48 66.22 42 | 58 1.43 67.65 43 | 61 1.50 69.15 44 | 29 0.71 69.87 45 | 53 1.31 71.18 46 | 83 2.04 73.22 47 | 82 2.02 75.24 48 | 2 0.05 75.29 49 | 113 2.78 78.07 50 | 73 1.80 79.87 51 | 58 1.43 81.30 52 | 61 1.50 82.80 53 | 70 1.72 84.53 54 | 8 0.20 84.73 55 | 51 1.26 85.98 56 | 38 0.94 86.92 57 | 63 1.55 88.47 58 | 37 0.91 89.38 59 | 47 1.16 90.54 60 | 80 1.97 92.51 61 | 64 1.58 94.09 62 | 71 1.75 95.84 63 | 30 0.74 96.58 64 | 59 1.45 98.03 65 | 80 1.97 100.00 ------------+----------------------------------- Total | 4,059 100.00 . . quietly runmlwin normexam cons standlrt girl s2-s65, /// > level2(school:) /// > level1(student: cons) /// > nopause . . runmlwin normexam cons standlrt girl s2-s65, /// > level2(school:) /// > level1(student: cons) /// > mcmc(on) initsprevious nopause MLwiN 3.05 multilevel model Number of obs = 4059 Normal response model (hierarchical) Estimation algorithm: MCMC ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ school | 65 2 62.4 198 ----------------------------------------------------------- Burnin = 500 Chain = 5000 Thinning = 1 Run time (seconds) = 15.6 Deviance (dbar) = 9183.16 Deviance (thetabar) = 9115.38 Effective no. of pars (pd) = 67.79 Bayesian DIC = 9250.95 ------------------------------------------------------------------------------ normexam | Mean Std. Dev. ESS P [95% Cred. Interval] -------------+---------------------------------------------------------------- cons | .3447642 .0875207 5289 0.000 .1705693 .5172783 standlrt | .5557744 .0123611 5016 0.000 .5312549 .5799571 girl | .1698498 .0343003 4820 0.000 .1019981 .2389705 s2 | .0494644 .134034 4928 0.360 -.2081764 .3151397 s3 | .1497186 .1350018 5138 0.138 -.1134219 .4084463 s4 | -.3937226 .1203355 4674 0.001 -.6291269 -.1534497 s5 | -.1547165 .1527173 5118 0.161 -.4496558 .142098 s6 | .0756664 .1227124 5276 0.269 -.1643685 .322382 s7 | -.1055076 .1190389 5353 0.189 -.3384708 .1295252 s8 | -.5412934 .1161289 4866 0.000 -.7705857 -.3100875 s9 | -.570336 .1554425 4956 0.000 -.8813762 -.2708668 s10 | -.7834914 .1383163 5340 0.000 -1.05715 -.514297 s11 | -.1407697 .1301238 5399 0.139 -.3927467 .1110808 s12 | -.5014367 .1407536 5010 0.000 -.7711125 -.2252275 s13 | -.6090245 .1262811 4954 0.000 -.8575571 -.3681398 s14 | -.602579 .1015323 5184 0.000 -.7979188 -.4007426 s15 | -.6190598 .1166953 5019 0.000 -.8485399 -.3884226 s16 | -.9486257 .1198447 5457 0.000 -1.181789 -.7167122 s17 | -.6539022 .1114243 5211 0.000 -.8684787 -.4352381 s18 | -.6021683 .1126148 5166 0.000 -.8214454 -.3814467 s19 | -.4205193 .1324154 5111 0.001 -.6821501 -.1593955 s20 | -.1698405 .1467336 4846 0.128 -.4588654 .109314 s21 | -.2459042 .1247843 5135 0.024 -.4900899 -.0023105 s22 | -.8882096 .1196185 5516 0.000 -1.123277 -.6530232 s23 | -1.05124 .1661341 4956 0.000 -1.368438 -.7234571 s24 | -.102903 .1523395 4707 0.258 -.4061451 .186048 s25 | -.7675343 .1257367 4956 0.000 -1.013127 -.5136774 s26 | -.4427277 .1235634 4953 0.000 -.6836937 -.2049862 s27 | -.3202908 .1474223 4952 0.013 -.6146728 -.0398035 s28 | -1.098718 .1331896 4987 0.000 -1.364633 -.8468661 s29 | -.2530859 .1230793 5160 0.020 -.4905374 -.0109291 s30 | -.325837 .1442369 5766 0.015 -.6112659 -.0393982 s31 | -.4766373 .1400805 5088 0.001 -.7562365 -.1999463 s32 | -.4169266 .1449346 5162 0.002 -.6993586 -.1330185 s33 | -.3827026 .120199 5272 0.001 -.6218811 -.1461733 s34 | -.5684394 .1702156 4862 0.001 -.9035637 -.2383537 s35 | -.3645687 .149365 5270 0.008 -.6539497 -.0672045 s36 | -.5405558 .1225877 5070 0.000 -.7764096 -.3029791 s37 | -.5891654 .1823432 4813 0.001 -.9422132 -.2280815 s38 | -.5858156 .1340282 5661 0.000 -.8531295 -.3161542 s39 | -.3684377 .1405473 5366 0.005 -.636011 -.0873136 s40 | -.5959872 .1251672 4942 0.000 -.8361845 -.3513176 s41 | -.2803063 .131127 4740 0.014 -.5346485 -.0253611 s42 | -.3086284 .1316099 5799 0.010 -.5667779 -.0539933 s43 | -.6015499 .1294763 4946 0.000 -.8545887 -.3479749 s44 | -.642269 .1622909 5427 0.000 -.9591648 -.3280903 s45 | -.6213009 .13539 5177 0.000 -.8848954 -.3508024 s46 | -.796307 .1199204 5269 0.000 -1.030307 -.5576372 s47 | -.3907401 .1204658 5404 0.001 -.6333745 -.1581976 s48 | -.6972801 .5446455 4764 0.102 -1.747823 .3988393 s49 | -.4671745 .114052 5003 0.000 -.6887934 -.2480077 s50 | -.7580137 .1241223 5308 0.000 -.9972637 -.5147264 s51 | -.498235 .1316424 4629 0.000 -.7514078 -.2362239 s52 | .0804773 .1307115 5161 0.268 -.1696293 .3408672 s53 | .2791548 .1278595 5263 0.015 .026861 .5268683 s54 | -1.392492 .280981 4943 0.000 -1.934521 -.8408051 s55 | .1404529 .1354092 5131 0.153 -.1200374 .4121006 s56 | -.4275011 .1504954 4941 0.001 -.727041 -.1338853 s57 | -.3073557 .130321 6016 0.007 -.553365 -.0539101 s58 | -.3467497 .1518177 5543 0.013 -.6381066 -.0481592 s59 | -1.152588 .14012 4889 0.000 -1.427207 -.8813631 s60 | -.2703683 .1227506 5090 0.014 -.5086202 -.0313548 s61 | -.4595796 .1277192 4885 0.001 -.7103895 -.2095879 s62 | -.4644638 .1264942 5992 0.000 -.7078328 -.2150071 s63 | .2089916 .1618289 5449 0.103 -.1010651 .5256909 s64 | -.2376926 .131937 5225 0.037 -.4999084 .0231287 s65 | -.6936765 .1224885 4904 0.000 -.933907 -.4521208 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Mean Std. Dev. ESS [95% Cred. Int] -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .5628155 .0125953 5134 .5385854 .5875409 ------------------------------------------------------------------------------ . . . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . . 33 . . . . . . **************************************************************************** . exit end of do-file