------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\3_Residuals > .smcl log type: smcl opened on: 27 Mar 2020, 17:41:40 . **************************************************************************** . * MLwiN User Manual . * . * 3 Residuals 37 . * . * Rasbash, J., Steele, F., Browne, W. J. and Goldstein, H. (2012). . * A User’s Guide to 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/ . **************************************************************************** . . * 3.1 What are multilevel residuals? . . . . . . . . . . . . . . . . . . .37 . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial.dta", clear . . runmlwin normexam cons, /// > level2(school: cons, residuals(u)) /// > level1(student: cons, residuals(e)) /// > 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.72 Number of iterations = 3 Log likelihood = -5505.324 Deviance = 11010.648 ------------------------------------------------------------------------------ normexam | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.0131668 .0536254 -0.25 0.806 -.1182706 .091937 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: school | var(cons) | .168625 .0324466 .1050308 .2322193 -----------------------------+------------------------------------------------ Level 1: student | var(cons) | .8477613 .0189712 .8105785 .8849441 ------------------------------------------------------------------------------ . . . . * 3.2 Calculating residuals in MLwiN . . . . . . . . . . . . . . . . . . .40 . . egen pickone = tag(school) . . egen u0rank = rank(u0) if pickone==1 (3994 missing values generated) . . serrbar u0 u0se u0rank if pickone==1, scale(1.96) yline(0) . . . . * 3.3 Normal plots . . . . . . . . . . . . . . . . . . . . . . . . . . . .43 . . summarize e0 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- e0 | 4,059 -3.31e-18 .9141767 -3.634258 3.367905 . . generate e0std = (e0 - r(mean))/r(sd) . . egen e0rank = rank(e0) . . generate e0uniform = (e0rank - 0.5)/_N . . generate e0nscore = invnorm(e0uniform) . . scatter e0std e0nscore, /// > yline(0) xline(0) ylabel(-4(1)4) xlabel(-4(1)4) aspectratio(1) . . keep if pickone==1 (3,994 observations deleted) . . keep u0 u0rank . . summarize u0 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- u0 | 65 3.25e-17 .3930771 -.9358178 .9485863 . . generate u0std = (u0 - r(mean))/r(sd) . . generate u0uniform = (u0rank - 0.5)/_N . . generate u0nscore = invnorm(u0uniform) . . scatter u0std u0nscore, /// > yline(0) xline(0) ylabel(-3(1)3) xlabel(-3(1)3) aspectratio(1) . . save "tutorial3.dta", replace file tutorial3.dta saved . . . . * Chapter learning outcomes . . . . . . . . . . . . . . . . . . . . . . . 45 . . . . **************************************************************************** . exit end of do-file