------------------------------------------------------------------------------- name: log: Q:\C-modelling\runmlwin\website\logfiles\2020-03-27\16\6.5.smcl log type: smcl opened on: 27 Mar 2020, 18:21:53 . **************************************************************************** . * Module 6: Regression Models for Binary Responses Stata Practicals . * . * P6.5: Application of Logit and Probit Models in Analyses of Antenatal . * Care Uptake . * . * 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.5.dta", clear . . . . * P6.5.1 Probabilities, odds and odds ratios . . tabulate antemed meduc, column +-------------------+ | Key | |-------------------| | frequency | | column percentage | +-------------------+ Antenatal | from | qualified | Maternal education medic | 1 2 3 | Total -----------+---------------------------------+---------- 0 | 1,272 856 485 | 2,613 | 68.17 51.91 26.20 | 48.70 -----------+---------------------------------+---------- 1 | 594 793 1,366 | 2,753 | 31.83 48.09 73.80 | 51.30 -----------+---------------------------------+---------- Total | 1,866 1,649 1,851 | 5,366 | 100.00 100.00 100.00 | 100.00 . . display 594/1272 .46698113 . . display (793/856)/(594/1272) 1.9838101 . . . . * P6.5.2 Interpretation of a logit model . . runmlwin antemed cons meduc2 meduc3, /// > 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.59 Number of iterations = 4 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.7614664 .0496955 -15.32 0.000 -.8588679 -.664065 meduc2 | .6850193 .0699922 9.79 0.000 .5478371 .8222014 meduc3 | 1.79696 .0725498 24.77 0.000 1.654765 1.939155 ------------------------------------------------------------------------------ . . display exp(-0.761) .46719899 . . display exp(0.685) 1.9837718 . . display exp(1.797) 6.0315257 . . runmlwin, or MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.59 Number of iterations = 4 ------------------------------------------------------------------------------ antemed | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .4669811 .0232069 -15.32 0.000 .4236414 .5147546 meduc2 | 1.98381 .1388512 9.79 0.000 1.729508 2.275504 meduc3 | 6.031282 .4375685 24.77 0.000 5.231848 6.952871 ------------------------------------------------------------------------------ . . display invlogit(-0.761 + 0.685) .48100914 . . predict predxb . . generate predprob = invlogit(predxb) . . tabstat predprob, by(meduc) Summary for variables: predprob by categories of: meduc (Maternal education) meduc | mean ---------+---------- 1 | .318328 2 | .4808975 3 | .7379795 ---------+---------- Total | .5130451 -------------------- . . . . * P6.5.3 Comparison of probit and logit coefficients . . runmlwin antemed cons meduc2 meduc3, /// > level1(womid:) /// > discrete(distribution(binomial) link(probit) denominator(cons)) /// > nopause MLwiN 3.05 multilevel model Number of obs = 5366 Binomial probit response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.54 Number of iterations = 4 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.4723795 .030221 -15.63 0.000 -.5316115 -.4131475 meduc2 | .4244783 .043205 9.82 0.000 .3397981 .5091586 meduc3 | 1.109508 .0435698 25.47 0.000 1.024113 1.194903 ------------------------------------------------------------------------------ . . . * P6.5.4 Interpretation of a probit model . . display normal(-0.472 + 0.424) .48085812 . . drop predxb predprob . . predict predxb . . generate predprob = normal(predxb) . . tabstat predprob, by(meduc) Summary for variables: predprob by categories of: meduc (Maternal education) meduc | mean ---------+---------- 1 | .318328 2 | .4808975 3 | .7379795 ---------+---------- Total | .5130451 -------------------- . . . . * P6.5.5 Significance testing and confidence intervals . . runmlwin antemed cons meduc2 meduc3, /// > 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.55 Number of iterations = 4 ------------------------------------------------------------------------------ antemed | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | -.7614664 .0496955 -15.32 0.000 -.8588679 -.664065 meduc2 | .6850193 .0699922 9.79 0.000 .5478371 .8222014 meduc3 | 1.79696 .0725498 24.77 0.000 1.654765 1.939155 ------------------------------------------------------------------------------ . . runmlwin, or MLwiN 3.05 multilevel model Number of obs = 5366 Binomial logit response model (hierarchical) Estimation algorithm: IGLS, MQL1 Run time (seconds) = 0.55 Number of iterations = 4 ------------------------------------------------------------------------------ antemed | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- cons | .4669811 .0232069 -15.32 0.000 .4236414 .5147546 meduc2 | 1.98381 .1388512 9.79 0.000 1.729508 2.275504 meduc3 | 6.031282 .4375685 24.77 0.000 5.231848 6.952871 ------------------------------------------------------------------------------ . . test meduc2 meduc3 ( 1) [FP1]meduc2 = 0 ( 2) [FP1]meduc3 = 0 chi2( 2) = 620.17 Prob > chi2 = 0.0000 . . test meduc2 ( 1) [FP1]meduc2 = 0 chi2( 1) = 95.79 Prob > chi2 = 0.0000 . . test meduc3 ( 1) [FP1]meduc3 = 0 chi2( 1) = 613.48 Prob > chi2 = 0.0000 . . test meduc2=meduc3 ( 1) [FP1]meduc2 - [FP1]meduc3 = 0 chi2( 1) = 236.72 Prob > chi2 = 0.0000 . end of do-file