------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\5.4.smcl log type: smcl opened on: 27 Mar 2020, 18:21:41 . **************************************************************************** . * Module 5: Introduction to Multilevel Modelling Stata Practicals . * . * P5.4: Adding Level 2 Explanatory Variables . * . * George Leckie . * Centre for Multilevel Modelling, 2010 . **************************************************************************** . * Stata do-file to replicate all analyses using runmlwin . * . * George Leckie . * Centre for Multilevel Modelling, 2013 . * http://www.bristol.ac.uk/cmm/software/runmlwin/ . **************************************************************************** . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/5.4.dta", clear . . egen pickone = tag(schoolid) . . tab1 schtype schurban schdenom if pickone==1 -> tabulation of schtype if pickone==1 School type | Freq. Percent Cum. ------------+----------------------------------- 0 | 456 89.76 89.76 1 | 52 10.24 100.00 ------------+----------------------------------- Total | 508 100.00 -> tabulation of schurban if pickone==1 School | urban-rural | classificat | ion | Freq. Percent Cum. ------------+----------------------------------- 0 | 163 32.09 32.09 1 | 345 67.91 100.00 ------------+----------------------------------- Total | 508 100.00 -> tabulation of schdenom if pickone==1 School | denominatio | n | Freq. Percent Cum. ------------+----------------------------------- 0 | 425 83.66 83.66 1 | 83 16.34 100.00 ------------+----------------------------------- Total | 508 100.00 . . runmlwin score cons cohort90 female sclass1 sclass2 sclass4, /// > level2(schoolid: cons cohort90) /// > level1(caseid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 508 1 66.9 190 ----------------------------------------------------------- Run time (seconds) = 1.02 Number of iterations = 6 Log likelihood = -138346.13 Deviance = 276692.25 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 24.60992 .2795386 88.04 0.000 24.06203 25.1578 cohort90 | 1.18287 .0243246 48.63 0.000 1.135194 1.230545 female | 1.961383 .1542814 12.71 0.000 1.658997 2.263769 sclass1 | 11.08587 .2063923 53.71 0.000 10.68135 11.49039 sclass2 | 5.875273 .2040509 28.79 0.000 5.47534 6.275205 sclass4 | -3.737811 .2845323 -13.14 0.000 -4.295484 -3.180138 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: schoolid | var(cons) | 22.49103 1.710975 19.13758 25.84448 cov(cons,cohort90) | -.5861301 .1249077 -.8309447 -.3413156 var(cohort90) | .1510657 .0172269 .1173016 .1848299 -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 192.9468 1.499537 190.0077 195.8858 ------------------------------------------------------------------------------ . . * P5.4.1 Contextual effects . runmlwin score cons cohort90 female sclass1 sclass2 sclass4 schtype, /// > level2(schoolid: cons cohort90) /// > level1(caseid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 508 1 66.9 190 ----------------------------------------------------------- Run time (seconds) = 1.15 Number of iterations = 7 Log likelihood = -138333.44 Deviance = 276666.89 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 24.27942 .278675 87.12 0.000 23.73323 24.82562 cohort90 | 1.184051 .0242124 48.90 0.000 1.136595 1.231506 female | 1.963789 .1542592 12.73 0.000 1.661447 2.266132 sclass1 | 11.03071 .2069527 53.30 0.000 10.62509 11.43633 sclass2 | 5.856466 .2041427 28.69 0.000 5.456354 6.256578 sclass4 | -3.750278 .2845447 -13.18 0.000 -4.307975 -3.19258 schtype | 4.246461 .8167042 5.20 0.000 2.645751 5.847172 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: schoolid | var(cons) | 20.56051 1.586186 17.45164 23.66938 cov(cons,cohort90) | -.4595609 .1184488 -.6917164 -.2274055 var(cohort90) | .1481818 .0170129 .1148372 .1815264 -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 192.995 1.499883 190.0553 195.9347 ------------------------------------------------------------------------------ . . runmlwin score cons cohort90 female sclass1 sclass2 sclass4 /// > schtype schurban, /// > level2(schoolid: cons cohort90) /// > level1(caseid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 508 1 66.9 190 ----------------------------------------------------------- Run time (seconds) = 1.12 Number of iterations = 6 Log likelihood = -138328.95 Deviance = 276657.91 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 25.26011 .4269906 59.16 0.000 24.42323 26.097 cohort90 | 1.181961 .0242326 48.78 0.000 1.134466 1.229456 female | 1.966733 .1542532 12.75 0.000 1.664402 2.269063 sclass1 | 11.03314 .206936 53.32 0.000 10.62756 11.43873 sclass2 | 5.847191 .2041843 28.64 0.000 5.446997 6.247385 sclass4 | -3.740059 .2845723 -13.14 0.000 -4.297811 -3.182308 schtype | 4.389665 .8088178 5.43 0.000 2.804411 5.974918 schurban | -1.436951 .4760291 -3.02 0.003 -2.369951 -.5039511 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: schoolid | var(cons) | 19.92894 1.542354 16.90598 22.9519 cov(cons,cohort90) | -.454542 .1168725 -.6836078 -.2254762 var(cohort90) | .1484335 .0170433 .1150291 .1818378 -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 193.013 1.50003 190.073 195.953 ------------------------------------------------------------------------------ . . runmlwin score cons cohort90 female sclass1 sclass2 sclass4 /// > schtype schurban schdenom, /// > level2(schoolid: cons cohort90) /// > level1(caseid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 508 1 66.9 190 ----------------------------------------------------------- Run time (seconds) = 1.26 Number of iterations = 7 Log likelihood = -138328.92 Deviance = 276657.83 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 25.24842 .4292799 58.82 0.000 24.40705 26.0898 cohort90 | 1.182039 .0242207 48.80 0.000 1.134567 1.229511 female | 1.966668 .1542537 12.75 0.000 1.664337 2.269 sclass1 | 11.03355 .2069607 53.31 0.000 10.62792 11.43919 sclass2 | 5.847287 .2041906 28.64 0.000 5.44708 6.247493 sclass4 | -3.740575 .2845783 -13.14 0.000 -4.298338 -3.182812 schtype | 4.397249 .8106765 5.42 0.000 2.808352 5.986146 schurban | -1.462213 .4848237 -3.02 0.003 -2.41245 -.5119756 schdenom | .1705971 .6013877 0.28 0.777 -1.008101 1.349295 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: schoolid | var(cons) | 19.95858 1.546467 16.92756 22.9896 cov(cons,cohort90) | -.4608159 .1169593 -.6900519 -.2315799 var(cohort90) | .1482434 .0170113 .1149019 .1815849 -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 193.0133 1.500011 190.0734 195.9533 ------------------------------------------------------------------------------ . . . * P5.4.2 Cross-level interactions . . generate cohort90Xschtype = cohort90*schtype . . runmlwin score cons cohort90 female sclass1 sclass2 sclass4 /// > schtype schurban cohort90Xschtype, /// > level2(schoolid: cons cohort90) /// > level1(caseid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 508 1 66.9 190 ----------------------------------------------------------- Run time (seconds) = 1.24 Number of iterations = 7 Log likelihood = -138312.52 Deviance = 276625.05 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 25.18705 .4319249 58.31 0.000 24.34049 26.0336 cohort90 | 1.213553 .0244255 49.68 0.000 1.16568 1.261426 female | 1.970276 .1541848 12.78 0.000 1.66808 2.272473 sclass1 | 11.01949 .2068684 53.27 0.000 10.61404 11.42495 sclass2 | 5.830787 .204108 28.57 0.000 5.430743 6.230831 sclass4 | -3.742871 .2844441 -13.16 0.000 -4.300371 -3.185371 schtype | 5.29107 .8305444 6.37 0.000 3.663233 6.918908 schurban | -1.403688 .4827234 -2.91 0.004 -2.349808 -.4575677 cohort90Xs~e | -.5993398 .1037983 -5.77 0.000 -.8027807 -.3958989 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: schoolid | var(cons) | 20.4027 1.574985 17.31579 23.48962 cov(cons,cohort90) | -.3916534 .1151193 -.617283 -.1660237 var(cohort90) | .1380648 .0162757 .1061649 .1699646 -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 192.8524 1.498749 189.9149 195.7899 ------------------------------------------------------------------------------ . end of do-file