------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\6.6.smcl log type: smcl opened on: 27 Mar 2020, 18:21:55 . **************************************************************************** . * Module 6: Regression Models for Binary Responses Stata Practicals . * . * P6.6: Adding Further Predictors in the Analysis of Antenatal Care . * . * 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/6.6.dta", clear . . . . * P6.6.1 Extending the logit model . . generate wealth2 = wealth==2 . . generate wealth3 = wealth==3 . . generate wealth4 = wealth==4 . . generate wealth5 = wealth==5 . . runmlwin antemed cons meduc2 meduc3 magec magecsq /// > urban wealth2 wealth3 wealth4 wealth5, /// > level1(womid:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > nopause MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.69 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -1.436242 .0815004 -17.62 0.000 -1.59598 -1.276504 meduc2 | .451149 .0771444 5.85 0.000 .2999489 .6023492 meduc3 | 1.175547 .0872951 13.47 0.000 1.004451 1.346642 magec | -.0036639 .0060086 -0.61 0.542 -.0154405 .0081128 magecsq | -.0012959 .0006384 -2.03 0.042 -.0025472 -.0000446 urban | .7945408 .0742339 10.70 0.000 .649045 .9400366 wealth2 | .4756747 .0970571 4.90 0.000 .2854462 .6659032 wealth3 | .6938627 .0979617 7.08 0.000 .5018613 .885864 wealth4 | 1.047921 .1015562 10.32 0.000 .8488741 1.246967 wealth5 | 1.699858 .1163803 14.61 0.000 1.471757 1.92796 ------------------------------------------------------------------------------ . . test magec magecsq ( 1) [FP1]magec = 0 ( 2) [FP1]magecsq = 0 chi2( 2) = 7.42 Prob > chi2 = 0.0245 . . runmlwin antemed cons meduc2 meduc3 magec magecsq urban wealth, /// > level1(womid:) /// > discrete(distribution(binomial) link(logit) denominator(cons)) /// > nopause MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.62 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -1.831606 .0834644 -21.94 0.000 -1.995193 -1.668019 meduc2 | .446414 .0770185 5.80 0.000 .2954605 .5973676 meduc3 | 1.183254 .0871427 13.58 0.000 1.012457 1.354051 magec | -.0029384 .0059994 -0.49 0.624 -.0146969 .0088202 magecsq | -.001305 .0006386 -2.04 0.041 -.0025566 -.0000534 urban | .8390504 .0721181 11.63 0.000 .6977015 .9803993 wealth | .3865604 .0253496 15.25 0.000 .3368762 .4362447 ------------------------------------------------------------------------------ . . . . * P6.6.2 Model interpretation . . runmlwin, or MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.62 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .1601561 .0133673 -21.94 0.000 .1359874 .1886203 meduc2 | 1.562698 .1203567 5.80 0.000 1.343745 1.817328 meduc3 | 3.264981 .2845194 13.58 0.000 2.752356 3.873082 magec | .9970659 .0059818 -0.49 0.624 .9854106 1.008859 magecsq | .9986958 .0006378 -2.04 0.041 .9974466 .9999466 urban | 2.314168 .1668935 11.63 0.000 2.009129 2.66552 wealth | 1.471909 .0373123 15.25 0.000 1.400566 1.546887 ------------------------------------------------------------------------------ . . summarize meduc2 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- meduc2 | 5,366 .3073053 .46142 0 1 . . replace meduc2 = 0.307 variable meduc2 was byte now float (5,366 real changes made) . . summarize meduc3 Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- meduc3 | 5,366 .3449497 .4753962 0 1 . . replace meduc3 = 0.345 variable meduc3 was byte now float (5,366 real changes made) . . summarize urban Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- urban | 5,366 .3138278 .4640906 0 1 . . replace urban = 0.314 variable urban was byte now float (5,366 real changes made) . . summarize wealth Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- wealth | 5,366 3.0082 1.463163 1 5 . . replace wealth = 3.008 variable wealth was byte now float (5,366 real changes made) . . predict predxb . . generate predprob = invlogit(predxb) . . line predprob mage if inrange(mage,15,45), sort . end of do-file