------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\6.7.smcl log type: smcl opened on: 27 Mar 2020, 18:21:57 . **************************************************************************** . * Module 6: Regression Models for Binary Responses Stata Practicals . * . * P6.7: Interaction Effects . * . * 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.7.dta", clear . . generate meduc2Xwealth = meduc2*wealth . . generate meduc3Xwealth = meduc3*wealth . . runmlwin antemed cons meduc2 meduc3 magec magecsq urban wealth /// > meduc2Xwealth meduc3Xwealth, /// > 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.67 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -1.634818 .110752 -14.76 0.000 -1.851888 -1.417748 meduc2 | .435767 .1663563 2.62 0.009 .1097146 .7618194 meduc3 | .2281815 .2126319 1.07 0.283 -.1885694 .6449323 magec | -.0055244 .0060311 -0.92 0.360 -.0173452 .0062963 magecsq | -.0010804 .0006364 -1.70 0.090 -.0023278 .0001669 urban | .8222581 .0726825 11.31 0.000 .6798031 .9647131 wealth | .3046837 .0402222 7.58 0.000 .2258497 .3835177 meduc2Xwea~h | .0153239 .0558998 0.27 0.784 -.0942376 .1248855 meduc3Xwea~h | .2928905 .0621556 4.71 0.000 .1710678 .4147131 ------------------------------------------------------------------------------ . . replace magec = 0 (5,366 real changes made) . . replace magecsq = 0 (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) . . predict predxb . . generate predprob = invlogit(predxb) . . twoway (line predprob wealth if meduc==1, sort lpattern(solid)) /// > (line predprob wealth if meduc==2, sort lpattern(dash)) /// > (line predprob wealth if meduc==3, sort lpattern(dot)), /// > legend(order(1 "None" 2 "Primary" 3 "Secondary or higher")) . . end of do-file