------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\3.2.smcl log type: smcl opened on: 27 Mar 2020, 18:21:14 . **************************************************************************** . * Module 3: Multiple Regression Stata Practicals . * . * P3.2: Comparing Groups: Regression with a Single Categorical . * Explanatory Variable . * . * 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/ . **************************************************************************** . . * P3.2.1 Comparing attainment for girls and boys . . use "http://www.bristol.ac.uk/cmm/media/runmlwin/3.2.dta", clear . . table female, contents(freq mean score sd score) row ------------------------------------------------- Female | Freq. mean(score) sd(score) ----------+-------------------------------------- 0 | 16,055 29.82523 17.30544 1 | 17,933 32.23108 17.24374 | Total | 33,988 31.09462 17.31437 ------------------------------------------------- . . runmlwin score cons female, /// > level1(caseid: cons) /// > mlwinsettings(optimat) nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS Run time (seconds) = 0.68 Number of iterations = 2 Log likelihood = -145062.44 Deviance = 290124.89 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 29.82523 .1363163 218.79 0.000 29.55805 30.0924 female | 2.405857 .1876653 12.82 0.000 2.038039 2.773674 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 298.3361 2.288537 293.8506 302.8215 ------------------------------------------------------------------------------ . . . . * P3.2.2 Attainment by parental social class . . table sclass, contents(freq mean score sd score) row ------------------------------------------------- Social | class | Freq. mean(score) sd(score) ----------+-------------------------------------- 1 | 11,173 39.24524 15.23131 2 | 9,994 31.87142 16.09893 3 | 9,486 24.10183 16.2501 4 | 3,335 21.35052 17.08918 | Total | 33,988 31.09462 17.31437 ------------------------------------------------- . . list caseid sclass in 1/10 +-----------------+ | caseid sclass | |-----------------| 1. | 339 2 | 2. | 340 3 | 3. | 345 4 | 4. | 346 3 | 5. | 352 3 | |-----------------| 6. | 353 2 | 7. | 354 3 | 8. | 361 2 | 9. | 362 3 | 10. | 363 1 | +-----------------+ . . generate sclass1 = sclass==1 . . generate sclass2 = sclass==2 . . generate sclass3 = sclass==3 . . generate sclass4 = sclass==4 . . list caseid sclass sclass1 sclass2 sclass3 sclass4 in 1/10 +---------------------------------------------------------+ | caseid sclass sclass1 sclass2 sclass3 sclass4 | |---------------------------------------------------------| 1. | 339 2 0 1 0 0 | 2. | 340 3 0 0 1 0 | 3. | 345 4 0 0 0 1 | 4. | 346 3 0 0 1 0 | 5. | 352 3 0 0 1 0 | |---------------------------------------------------------| 6. | 353 2 0 1 0 0 | 7. | 354 3 0 0 1 0 | 8. | 361 2 0 1 0 0 | 9. | 362 3 0 0 1 0 | 10. | 363 1 1 0 0 0 | +---------------------------------------------------------+ . . runmlwin score cons sclass1 sclass2 sclass4, /// > level1(caseid: cons) /// > mlwinsettings(optimat) nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS Run time (seconds) = 0.68 Number of iterations = 2 Log likelihood = -142381.68 Deviance = 284763.36 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 24.10183 .1638917 147.06 0.000 23.78061 24.42306 sclass1 | 15.1434 .2228572 67.95 0.000 14.70661 15.58019 sclass2 | 7.769589 .2288135 33.96 0.000 7.321122 8.218055 sclass4 | -2.75131 .3213438 -8.56 0.000 -3.381132 -2.121487 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 254.7985 1.95456 250.9676 258.6293 ------------------------------------------------------------------------------ . . . . * P3.2.3 Fitting a non-linear relationship to attainment and cohort . . tabulate cohort90 Cohort | Freq. Percent Cum. ------------+----------------------------------- -6 | 6,478 19.06 19.06 -4 | 6,325 18.61 37.67 -2 | 5,245 15.43 53.10 0 | 4,371 12.86 65.96 6 | 4,244 12.49 78.45 8 | 7,325 21.55 100.00 ------------+----------------------------------- Total | 33,988 100.00 . . generate cohort90yr84 = cohort90==-6 . . generate cohort90yr86 = cohort90==-4 . . generate cohort90yr88 = cohort90==-2 . . generate cohort90yr90 = cohort90==0 . . generate cohort90yr96 = cohort90==6 . . generate cohort90yr98 = cohort90==8 . . runmlwin score cons cohort90yr84 cohort90yr86 cohort90yr90 cohort90yr96 cohor > t90yr98, /// > level1(caseid: cons) /// > mlwinsettings(optimat) nopause MLwiN 3.05 multilevel model Number of obs = 33988 Normal response model (hierarchical) Estimation algorithm: IGLS Run time (seconds) = 0.72 Number of iterations = 2 Log likelihood = -141990.19 Deviance = 283980.37 ------------------------------------------------------------------------------ score | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | 28.5245 .2178829 130.92 0.000 28.09746 28.95154 cohort90yr84 | -4.86905 .2931043 -16.61 0.000 -5.443524 -4.294577 cohort90yr86 | -3.751851 .2946861 -12.73 0.000 -4.329425 -3.174277 cohort90yr90 | .5759352 .3231693 1.78 0.075 -.0574649 1.209335 cohort90yr96 | 10.91023 .325796 33.49 0.000 10.27168 11.54878 cohort90yr98 | 12.80615 .2854217 44.87 0.000 12.24673 13.36557 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 1: caseid | var(cons) | 248.9957 1.910047 245.2521 252.7394 ------------------------------------------------------------------------------ . end of do-file