------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\11.3.smcl log type: smcl opened on: 27 Mar 2020, 18:22:30 . **************************************************************************** . * Module 11: Three and Higher-Level Models - Stata Practical . * . * P11.3: Adding Predictor Variables . * . * 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/ . **************************************************************************** . . * P11.3.1 Adding student level predictor variables . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/11.3.dta", clear . . runmlwin postthks cons prethks, /// > level3(schoolid: cons) /// > level2(classid: cons) /// > level1(studentid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 1600 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 28 18 57.1 137 classid | 135 1 11.9 28 ----------------------------------------------------------- Run time (seconds) = 0.59 Number of iterations = 4 Log likelihood = -2687.0135 Deviance = 5374.0271 ------------------------------------------------------------------------------ postthks | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 2.042644 .0888765 22.98 0.000 1.868449 2.216838 prethks | .2999536 .0259609 11.55 0.000 .2490712 .3508361 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: schoolid | var(cons) | .0870039 .0375698 .0133685 .1606393 -----------------------------+------------------------------------------------ Level 2: classid | var(cons) | .069991 .0290376 .0130784 .1269037 -----------------------------+------------------------------------------------ Level 1: studentid | var(cons) | 1.59851 .0587908 1.483282 1.713738 ------------------------------------------------------------------------------ . . estimates store model2 . . lrtest model1 model2 Likelihood-ratio test LR chi2(1) = 127.95 (Assumption: model1 nested in model2) Prob > chi2 = 0.0000 . . . . * P11.3.2 Adding school level predictor variables . . runmlwin postthks cons prethks cc tv ccXtv, /// > level3(schoolid: cons) /// > level2(classid: cons) /// > level1(studentid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 1600 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 28 18 57.1 137 classid | 135 1 11.9 28 ----------------------------------------------------------- Run time (seconds) = 0.59 Number of iterations = 4 Log likelihood = -2678.6793 Deviance = 5357.3587 ------------------------------------------------------------------------------ postthks | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 1.696998 .1166491 14.55 0.000 1.46837 1.925626 prethks | .3072034 .0258415 11.89 0.000 .256555 .3578518 cc | .6391942 .1472018 4.34 0.000 .350684 .9277043 tv | .178109 .1436378 1.24 0.215 -.1034158 .4596338 ccXtv | -.3204167 .2054958 -1.56 0.119 -.723181 .0823476 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: schoolid | var(cons) | .0257421 .0196797 -.0128294 .0643137 -----------------------------+------------------------------------------------ Level 2: classid | var(cons) | .0635716 .0276561 .0093667 .1177765 -----------------------------+------------------------------------------------ Level 1: studentid | var(cons) | 1.602023 .0588889 1.486602 1.717443 ------------------------------------------------------------------------------ . . estimates store model3 . . lrtest model2 model3 Likelihood-ratio test LR chi2(3) = 16.67 (Assumption: model2 nested in model3) Prob > chi2 = 0.0008 . . test cc tv ccXtv ( 1) [FP1]cc = 0 ( 2) [FP1]tv = 0 ( 3) [FP1]ccXtv = 0 chi2( 3) = 23.84 Prob > chi2 = 0.0000 . . lincom cc ( 1) [FP1]cc = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .6391942 .1472018 4.34 0.000 .350684 .9277043 ------------------------------------------------------------------------------ . . lincom cc + ccXtv ( 1) [FP1]cc + [FP1]ccXtv = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .3187775 .1434432 2.22 0.026 .037634 .599921 ------------------------------------------------------------------------------ . . lincom tv ( 1) [FP1]tv = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .178109 .1436378 1.24 0.215 -.1034158 .4596338 ------------------------------------------------------------------------------ . . lincom tv + ccXtv ( 1) [FP1]tv + [FP1]ccXtv = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -.1423077 .1469771 -0.97 0.333 -.4303776 .1457621 ------------------------------------------------------------------------------ . . runmlwin postthks cons cc tv ccXtv, /// > level3(schoolid: cons) /// > level2(classid: cons) /// > level1(studentid: cons) /// > nopause MLwiN 3.05 multilevel model Number of obs = 1600 Normal response model (hierarchical) Estimation algorithm: IGLS ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ schoolid | 28 18 57.1 137 classid | 135 1 11.9 28 ----------------------------------------------------------- Run time (seconds) = 0.59 Number of iterations = 4 Log likelihood = -2745.5166 Deviance = 5491.0333 ------------------------------------------------------------------------------ postthks | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 2.355375 .1278323 18.43 0.000 2.104829 2.605922 cc | .6149607 .1824178 3.37 0.001 .2574284 .972493 tv | .1715648 .1785742 0.96 0.337 -.1784342 .5215639 ccXtv | -.3507844 .2546337 -1.38 0.168 -.8498573 .1482885 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 3: schoolid | var(cons) | .0565933 .0302939 -.0027817 .1159683 -----------------------------+------------------------------------------------ Level 2: classid | var(cons) | .0790121 .0316927 .0168955 .1411288 -----------------------------+------------------------------------------------ Level 1: studentid | var(cons) | 1.726533 .0634965 1.602082 1.850984 ------------------------------------------------------------------------------ . . estimates store model4 . . lincom cc ( 1) [FP1]cc = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .6149607 .1824178 3.37 0.001 .2574284 .972493 ------------------------------------------------------------------------------ . . lincom cc + ccXtv ( 1) [FP1]cc + [FP1]ccXtv = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .2641763 .1776572 1.49 0.137 -.0840253 .612378 ------------------------------------------------------------------------------ . . lincom tv ( 1) [FP1]tv = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .1715648 .1785742 0.96 0.337 -.1784342 .5215639 ------------------------------------------------------------------------------ . . lincom tv + ccXtv ( 1) [FP1]tv + [FP1]ccXtv = 0 ------------------------------------------------------------------------------ | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -.1792195 .1815202 -0.99 0.323 -.5349925 .1765534 ------------------------------------------------------------------------------ . end of do-file