------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\7.2.smcl log type: smcl opened on: 27 Mar 2020, 18:22:05 . **************************************************************************** . * Module 7: Multilevel Models for Binary Responses Stata Practicals . * . * P7.2: Latent Variable Representation of a Random Intercept Model . * . * 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/7.2.dta", clear . . . . * P7.2.1 Comparison of a single-level and multilevel threshold model . . summarize wealth Variable | Obs Mean Std. Dev. Min Max -------------+--------------------------------------------------------- wealth | 5,366 3.0082 1.463163 1 5 . . generate wealthc = wealth - 3.008 . . runmlwin antemed cons magec magecsq meduc2 meduc3 wealthc, /// > level2(comm: cons) /// > level1(womid:) /// > discrete(distribution(binomial) link(logit) denominator(cons) pql2) / > // > nopause MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, PQL2 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ comm | 361 3 14.9 25 ----------------------------------------------------------- Run time (seconds) = 0.79 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.4547629 .0827272 -5.50 0.000 -.6169051 -.2926207 magec | -.0003881 .006554 -0.06 0.953 -.0132337 .0124574 magecsq | -.0010068 .0006828 -1.47 0.140 -.002345 .0003314 meduc2 | .5478987 .0845976 6.48 0.000 .3820905 .7137069 meduc3 | 1.309241 .0977836 13.39 0.000 1.117589 1.500893 wealthc | .3977514 .029586 13.44 0.000 .3397638 .4557389 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: comm | var(cons) | .8538518 .0935791 .6704402 1.037263 ------------------------------------------------------------------------------ . . bysort comm: egen wealthmean = mean(wealth) . . egen pickone = tag(comm) . . histogram wealthmean if pickone==1, width(0.2) start(0) frequency (bin=25, start=0, width=.2) . . estimates store multilevel . . runmlwin antemed cons magec magecsq meduc2 meduc3 wealthc, /// > 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.63 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.3686811 .0593235 -6.21 0.000 -.4849531 -.2524091 magec | -.0046213 .0059102 -0.78 0.434 -.0162051 .0069625 magecsq | -.0013503 .0006307 -2.14 0.032 -.0025864 -.0001143 meduc2 | .3968979 .0757902 5.24 0.000 .2483519 .5454439 meduc3 | 1.072526 .0849994 12.62 0.000 .9059304 1.239122 wealthc | .4819517 .0239126 20.15 0.000 .4350839 .5288194 ------------------------------------------------------------------------------ . . . . * P7.2.2 Variance Partition Coefficient . . estimates replay multilevel, variance ------------------------------------------------------------------------------- Model multilevel ------------------------------------------------------------------------------- MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, PQL2 ----------------------------------------------------------- | No. of Observations per Group Level Variable | Groups Minimum Average Maximum ----------------+------------------------------------------ comm | 361 3 14.9 25 ----------------------------------------------------------- Run time (seconds) = 0.79 Number of iterations = 5 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.4547629 .0827272 -5.50 0.000 -.6169051 -.2926207 magec | -.0003881 .006554 -0.06 0.953 -.0132337 .0124574 magecsq | -.0010068 .0006828 -1.47 0.140 -.002345 .0003314 meduc2 | .5478987 .0845976 6.48 0.000 .3820905 .7137069 meduc3 | 1.309241 .0977836 13.39 0.000 1.117589 1.500893 wealthc | .3977514 .029586 13.44 0.000 .3397638 .4557389 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval] -----------------------------+------------------------------------------------ Level 2: comm | var(cons) | .8538518 .0935791 .6704402 1.037263 ------------------------------------------------------------------------------ . end of do-file