------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\5.2.smcl log type: smcl opened on: 27 Mar 2020, 18:21:30 . **************************************************************************** . * Module 5: Introduction to Multilevel Modelling Stata Practicals . * . * P5.2: Adding Student-level Explanatory Variables: Random Intercept . * Models . * . * 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.2.dta", clear . . runmlwin score cons cohort90, /// > level2(schoolid: cons) /// > 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) = 0.88 Number of iterations = 5 Log likelihood = -140456.79 Deviance = 280913.58 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 30.55914 .322513 94.75 0.000 29.92703 31.19125 cohort90 | 1.214956 .0155293 78.24 0.000 1.184519 1.245393 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: schoolid | var(cons) | 45.97869 3.255724 39.59759 52.35979 -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 219.2885 1.694483 215.9673 222.6096 ------------------------------------------------------------------------------ . . predict predscore . . egen pickone = tag(schoolid cohort90) . . sort schoolid cohort90 . . twoway connected predscore cohort90 if pickone==1, connect(ascending) . . generate multiplecohorts = pickone . . bysort schoolid (cohort90): replace multiplecohorts = 0 /// > if cohort90[_N]==cohort90[1] (32 real changes made) . . twoway connected predscore cohort90 if multiplecohorts==1, connect(ascending) . end of do-file