Table 8.2, page 266.
use mammog.dta, clear (Hosmer and Lemeshow - modified from appendix 6) tab2 me hist -> tabulation of me by hist | hist me | 0 1 | Total -----------+----------------------+---------- 0 | 220 14 | 234 1 | 85 19 | 104 2 | 63 11 | 74 -----------+----------------------+---------- Total | 368 44 | 412
NOTE: The text just above this table (on page 266) shows how the odds ratios were calculated.
Table 8.3, page 267.
mlogit me hist Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -396.214 Iteration 2: log likelihood = -396.17 Iteration 3: log likelihood = -396.16997 Multinomial regression Number of obs = 412 LR chi2(2) = 12.86 Prob > chi2 = 0.0016 Log likelihood = -396.16997 Pseudo R2 = 0.0160 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | hist | 1.256358 .3746603 3.35 0.001 .5220372 1.990679 _cons | -.9509763 .1277112 -7.45 0.000 -1.201286 -.7006669 -------------+---------------------------------------------------------------- 2 | hist | 1.009331 .4274998 2.36 0.018 .1714466 1.847215 _cons | -1.250493 .1428932 -8.75 0.000 -1.530558 -.9704273 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.4, page 269. Estimated covariance matrix for the fitted model in Table 8.3.
* Stata 8 code. vce * Stata 9 code and output. estat vce Covariance matrix of coefficients of mlogit model | 1 | 2 e(V) | hist _cons | hist _cons -------------+------------------------+------------------------ 1 | | hist | .14037035 | _cons | -.01631016 .01631016 | -------------+------------------------+------------------------ 2 | | hist | .07597403 -.00454545 | .18275604 _cons | -.00454545 .00454545 | -.02041847 .02041847
Table 8.5, page 271.
tab2 me detc -> tabulation of me by detc | detc me | 1 2 3 | Total -----------+---------------------------------+---------- 0 | 13 77 144 | 234 1 | 1 12 91 | 104 2 | 4 16 54 | 74 -----------+---------------------------------+---------- Total | 18 105 289 | 412
Table 8.6, page 271.
xi: mlogit me i.detc i.detc _Idetc_1-3 (naturally coded; _Idetc_1 omitted) Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -389.76354 Iteration 2: log likelihood = -389.21625 Iteration 3: log likelihood = -389.20061 Iteration 4: log likelihood = -389.20054 Multinomial regression Number of obs = 412 LR chi2(4) = 26.80 Prob > chi2 = 0.0000 Log likelihood = -389.20054 Pseudo R2 = 0.0333 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | _Idetc_2 | .7060506 1.083136 0.65 0.514 -1.416856 2.828958 _Idetc_3 | 2.105996 1.046325 2.01 0.044 .0552361 4.156755 _cons | -2.564949 1.03772 -2.47 0.013 -4.598843 -.5310556 -------------+---------------------------------------------------------------- 2 | _Idetc_2 | -.3925617 .6343589 -0.62 0.536 -1.635882 .850759 _Idetc_3 | .1978257 .5936221 0.33 0.739 -.9656522 1.361304 _cons | -1.178655 .5717729 -2.06 0.039 -2.299309 -.0580007 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group) xi: mlogit me i.detc, rrr i.detc _Idetc_1-3 (naturally coded; _Idetc_1 omitted) Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -389.76354 Iteration 2: log likelihood = -389.21625 Iteration 3: log likelihood = -389.20061 Iteration 4: log likelihood = -389.20054 Multinomial regression Number of obs = 412 LR chi2(4) = 26.80 Prob > chi2 = 0.0000 Log likelihood = -389.20054 Pseudo R2 = 0.0333 ------------------------------------------------------------------------------ me | RRR Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | _Idetc_2 | 2.025974 2.194405 0.65 0.514 .2424751 16.92781 _Idetc_3 | 8.215278 8.595851 2.01 0.044 1.05679 63.86395 -------------+---------------------------------------------------------------- 2 | _Idetc_2 | .6753247 .4283982 -0.62 0.536 .1947804 2.341423 _Idetc_3 | 1.21875 .7234769 0.33 0.739 .3807348 3.901276 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.7, page 274.
xi: mlogit me i.sympt pb hist bse i.detc i.sympt _Isympt_1-4 (naturally coded; _Isympt_1 omitted) i.detc _Idetc_1-3 (naturally coded; _Idetc_1 omitted) Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -351.59713 Iteration 2: log likelihood = -347.26545 Iteration 3: log likelihood = -346.95451 Iteration 4: log likelihood = -346.95096 Iteration 5: log likelihood = -346.95096 Multinomial regression Number of obs = 412 LR chi2(16) = 111.30 Prob > chi2 = 0.0000 Log likelihood = -346.95096 Pseudo R2 = 0.1382 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | _Isympt_2 | .1100372 .9227608 0.12 0.905 -1.698541 1.918615 _Isympt_3 | 1.924708 .7775975 2.48 0.013 .4006449 3.448771 _Isympt_4 | 2.456993 .7753323 3.17 0.002 .9373693 3.976616 pb | -.2194368 .0755139 -2.91 0.004 -.3674414 -.0714323 hist | 1.366239 .4375196 3.12 0.002 .5087163 2.223762 bse | 1.291666 .529891 2.44 0.015 .2530992 2.330234 _Idetc_2 | .0170207 1.161896 0.01 0.988 -2.260254 2.294296 _Idetc_3 | .9041379 1.126822 0.80 0.422 -1.304393 3.112668 _cons | -2.99875 1.53922 -1.95 0.051 -6.015566 .0180663 -------------+---------------------------------------------------------------- 2 | _Isympt_2 | -.2900833 .6440636 -0.45 0.652 -1.552425 .9722582 _Isympt_3 | .8173136 .5397922 1.51 0.130 -.2406596 1.875287 _Isympt_4 | 1.132239 .5476704 2.07 0.039 .0588252 2.205654 pb | -.1482068 .0763686 -1.94 0.052 -.2978866 .0014729 hist | 1.065436 .459396 2.32 0.020 .1650366 1.965836 bse | 1.052144 .5149894 2.04 0.041 .0427838 2.061505 _Idetc_2 | -.9243928 .7137382 -1.30 0.195 -2.323294 .4745083 _Idetc_3 | -.6905329 .6871078 -1.00 0.315 -2.037239 .6561736 _cons | -.9860915 1.111832 -0.89 0.375 -3.165242 1.193059 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.8, page 275.
gen symptd = . (412 missing values generated) replace symptd = 0 if sympt == 1 | sympt == 2 (113 real changes made) replace symptd = 1 if sympt == 3| sympt == 4 (299 real changes made) xi: mlogit me symptd pb hist bse i.detc i.detc _Idetc_1-3 (naturally coded; _Idetc_1 omitted) Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -353.37799 Iteration 2: log likelihood = -349.07042 Iteration 3: log likelihood = -348.75167 Iteration 4: log likelihood = -348.74797 Iteration 5: log likelihood = -348.74797 Multinomial regression Number of obs = 412 LR chi2(12) = 107.70 Prob > chi2 = 0.0000 Log likelihood = -348.74797 Pseudo R2 = 0.1338 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 2.095341 .4573977 4.58 0.000 1.198858 2.991824 pb | -.2510121 .0729327 -3.44 0.001 -.3939575 -.1080667 hist | 1.293281 .4335351 2.98 0.003 .4435676 2.142994 bse | 1.243974 .5263057 2.36 0.018 .212434 2.275514 _Idetc_2 | .0902755 1.161025 0.08 0.938 -2.185291 2.365842 _Idetc_3 | .9728148 1.126271 0.86 0.388 -1.234636 3.180266 _cons | -2.70375 1.434414 -1.88 0.059 -5.51515 .1076495 -------------+---------------------------------------------------------------- 2 | symptd | 1.121365 .3571979 3.14 0.002 .4212698 1.82146 pb | -.1681062 .0741724 -2.27 0.023 -.3134815 -.022731 hist | 1.014055 .4538042 2.23 0.025 .1246154 1.903495 bse | 1.02859 .5139737 2.00 0.045 .0212205 2.035961 _Idetc_2 | -.9021325 .7146177 -1.26 0.207 -2.302758 .4984924 _Idetc_3 | -.6698221 .687579 -0.97 0.330 -2.017452 .6778079 _cons | -.9987682 1.071963 -0.93 0.351 -3.099778 1.102242 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.9, page 276.
mlogit me symptd pb hist bse Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -356.82062 Iteration 2: log likelihood = -353.22809 Iteration 3: log likelihood = -353.02058 Iteration 4: log likelihood = -353.01904 Iteration 5: log likelihood = -353.01904 Multinomial regression Number of obs = 412 LR chi2(8) = 99.16 Prob > chi2 = 0.0000 Log likelihood = -353.01904 Pseudo R2 = 0.1231 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 2.230432 .451959 4.94 0.000 1.344609 3.116255 pb | -.2825439 .0713491 -3.96 0.000 -.4223855 -.1427024 hist | 1.29663 .4293033 3.02 0.003 .4552113 2.138049 bse | 1.220961 .5210422 2.34 0.019 .1997369 2.242185 _cons | -1.788769 .8470723 -2.11 0.035 -3.449 -.1285377 -------------+---------------------------------------------------------------- 2 | symptd | 1.153122 .3513753 3.28 0.001 .4644391 1.841805 pb | -.1577922 .0711783 -2.22 0.027 -.297299 -.0182853 hist | 1.061324 .4526774 2.34 0.019 .1740929 1.948556 bse | .9603822 .5072023 1.89 0.058 -.0337161 1.95448 _cons | -1.74214 .8086823 -2.15 0.031 -3.327128 -.1571521 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.10, page 277.
rename _Idetc_3 detcd mlogit me symptd pb hist bse detcd Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -354.2052 Iteration 2: log likelihood = -349.86452 Iteration 3: log likelihood = -349.56908 Iteration 4: log likelihood = -349.5663 Iteration 5: log likelihood = -349.5663 Multinomial regression Number of obs = 412 LR chi2(10) = 106.07 Prob > chi2 = 0.0000 Log likelihood = -349.5663 Pseudo R2 = 0.1317 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 2.09475 .4574302 4.58 0.000 1.198203 2.991297 pb | -.2494746 .072579 -3.44 0.001 -.3917269 -.1072224 hist | 1.309864 .4336022 3.02 0.003 .4600195 2.159709 bse | 1.237011 .5254241 2.35 0.019 .207199 2.266824 detcd | .8851839 .3562379 2.48 0.013 .1869705 1.583397 _cons | -2.623759 .9263964 -2.83 0.005 -4.439462 -.8080551 -------------+---------------------------------------------------------------- 2 | symptd | 1.127417 .3563621 3.16 0.002 .4289603 1.825874 pb | -.1543182 .0726206 -2.12 0.034 -.296652 -.0119845 hist | 1.063179 .4528412 2.35 0.019 .1756263 1.950731 bse | .9560104 .5073366 1.88 0.060 -.0383511 1.950372 detcd | .1141572 .3182122 0.36 0.720 -.5095272 .7378416 _cons | -1.823882 .8550928 -2.13 0.033 -3.499833 -.1479306 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Figure 8.1, page 278.
preserve clear input elogit1 elogit2 percb 0 0 5 -.1592353 -.3348183 6.5 -.6278501 -.5585917 8.5 -1.482975 -.8304334 13.5 end graph twoway scatter elogit1 elogit2 percb, /// xlabel(5 6.5 8.5 13.5) ylabel(-1.5(.5)0) connect(l l)
restore
Table 8.11, page 280.
NOTE: This gives the values for the columns labeled MLE.
mlogit me symptd pb hist bse detcd Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -354.2052 Iteration 2: log likelihood = -349.86452 Iteration 3: log likelihood = -349.56908 Iteration 4: log likelihood = -349.5663 Iteration 5: log likelihood = -349.5663 Multinomial regression Number of obs = 412 LR chi2(10) = 106.07 Prob > chi2 = 0.0000 Log likelihood = -349.5663 Pseudo R2 = 0.1317 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 2.09475 .4574302 4.58 0.000 1.198203 2.991297 pb | -.2494746 .072579 -3.44 0.001 -.3917269 -.1072224 hist | 1.309864 .4336022 3.02 0.003 .4600195 2.159709 bse | 1.237011 .5254241 2.35 0.019 .207199 2.266824 detcd | .8851839 .3562379 2.48 0.013 .1869705 1.583397 _cons | -2.623759 .9263964 -2.83 0.005 -4.439462 -.8080551 -------------+---------------------------------------------------------------- 2 | symptd | 1.127417 .3563621 3.16 0.002 .4289603 1.825874 pb | -.1543182 .0726206 -2.12 0.034 -.296652 -.0119845 hist | 1.063179 .4528412 2.35 0.019 .1756263 1.950731 bse | .9560104 .5073366 1.88 0.060 -.0383511 1.950372 detcd | .1141572 .3182122 0.36 0.720 -.5095272 .7378416 _cons | -1.823882 .8550928 -2.13 0.033 -3.499833 -.1479306 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
NOTE: This gives the values for the columns labeled ILR.
mlogit me symptd pb hist bse detcd if me != 2 Iteration 0: log likelihood = -208.62772 Iteration 1: log likelihood = -167.49587 Iteration 2: log likelihood = -162.26366 Iteration 3: log likelihood = -161.78826 Iteration 4: log likelihood = -161.78146 Iteration 5: log likelihood = -161.78145 Multinomial regression Number of obs = 338 LR chi2(5) = 93.69 Prob > chi2 = 0.0000 Log likelihood = -161.78145 Pseudo R2 = 0.2245 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 2.091002 .4651287 4.50 0.000 1.179366 3.002638 pb | -.2426146 .073756 -3.29 0.001 -.3871737 -.0980554 hist | 1.385025 .4682596 2.96 0.003 .4672527 2.302796 bse | 1.363308 .5338994 2.55 0.011 .3168847 2.409732 detcd | .852694 .3654564 2.33 0.020 .1364125 1.568975 _cons | -2.765088 .9421802 -2.93 0.003 -4.611727 -.9184483 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group) mlogit me symptd pb hist bse detcd if me != 1 Iteration 0: log likelihood = -169.82478 Iteration 1: log likelihood = -154.48353 Iteration 2: log likelihood = -153.48912 Iteration 3: log likelihood = -153.47233 Iteration 4: log likelihood = -153.47232 Multinomial regression Number of obs = 308 LR chi2(5) = 32.70 Prob > chi2 = 0.0000 Log likelihood = -153.47232 Pseudo R2 = 0.0963 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 2 | symptd | 1.15299 .3565788 3.23 0.001 .4541082 1.851871 pb | -.1537696 .0726013 -2.12 0.034 -.2960655 -.0114736 hist | 1.097696 .4593413 2.39 0.017 .1974035 1.997988 bse | .9534998 .5097419 1.87 0.061 -.0455759 1.952576 detcd | .0987046 .3190788 0.31 0.757 -.5266785 .7240876 _cons | -1.8381 .860046 -2.14 0.033 -3.52376 -.1524412 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.12, page 281.
logit me symptd pb hist bse detcd if me != 2 Iteration 0: log likelihood = -208.62772 Iteration 1: log likelihood = -167.49587 Iteration 2: log likelihood = -162.26366 Iteration 3: log likelihood = -161.78826 Iteration 4: log likelihood = -161.78146 Iteration 5: log likelihood = -161.78145 Logit estimates Number of obs = 338 LR chi2(5) = 93.69 Prob > chi2 = 0.0000 Log likelihood = -161.78145 Pseudo R2 = 0.2245 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- symptd | 2.091002 .4651287 4.50 0.000 1.179366 3.002638 pb | -.2426146 .073756 -3.29 0.001 -.3871737 -.0980554 hist | 1.385025 .4682596 2.96 0.003 .4672527 2.302796 bse | 1.363308 .5338994 2.55 0.011 .3168847 2.409732 detcd | .852694 .3654564 2.33 0.020 .1364125 1.568975 _cons | -2.765088 .9421802 -2.93 0.003 -4.611727 -.9184483 ------------------------------------------------------------------------------ * Stata 8 code. lfit, group(10) * Stata 9 code and output. estat gof, group(10) Logistic model for me, goodness-of-fit test (Table collapsed on quantiles of estimated probabilities) number of observations = 338 number of groups = 10 Hosmer-Lemeshow chi2(8) = 12.20 Prob > chi2 = 0.1424 * Stata 8 code. lfit * Stata 9 code and output. estat gof Logistic model for me, goodness-of-fit test number of observations = 338 number of covariate patterns = 74 Pearson chi2(68) = 67.84 Prob > chi2 = 0.4828 * We thank Silvano Andorno for providing the following code for the Stukel test generate me1=0 replace me1=1 if me==1 replace me1=. if me==2 generate me2=0 replace me2=1 if me==2 replace me2=. if me==1 quietly logit me1 symptd pb hist bse detcd predict p1 generate g1=ln(p1/(1-p1)) generate z11=0.5*g1^2 replace z11=0 if p1<0.5 generate z12=-0.5*g1^2 replace z12=0 if p1>=0.5 quietly logit me1 symptd pb hist bse detcd estimates store reduced quietly logit me1 symptd pb hist bse detcd z11 z12 estimates store full lrtest reduced full
Likelihood-ratio test LR chi2(2) = 1.02 (Assumption: reduced nested in full) Prob > chi2 = 0.6006
logit me symptd pb hist bse detcd if me != 1 Iteration 0: log likelihood = -169.82478 Iteration 1: log likelihood = -154.48353 Iteration 2: log likelihood = -153.48912 Iteration 3: log likelihood = -153.47233 Iteration 4: log likelihood = -153.47232 Logit estimates Number of obs = 308 LR chi2(5) = 32.70 Prob > chi2 = 0.0000 Log likelihood = -153.47232 Pseudo R2 = 0.0963 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- symptd | 1.15299 .3565788 3.23 0.001 .4541082 1.851871 pb | -.1537696 .0726013 -2.12 0.034 -.2960655 -.0114736 hist | 1.097696 .4593413 2.39 0.017 .1974035 1.997988 bse | .9534998 .5097419 1.87 0.061 -.0455759 1.952576 detcd | .0987046 .3190788 0.31 0.757 -.5266785 .7240876 _cons | -1.8381 .860046 -2.14 0.033 -3.52376 -.1524412 ------------------------------------------------------------------------------ * Stata 8 code. lfit, group(10) * Stata 9 code and output. estat gof, group(10) Logistic model for me, goodness-of-fit test (Table collapsed on quantiles of estimated probabilities) number of observations = 308 number of groups = 10 Hosmer-Lemeshow chi2(8) = 9.62 Prob > chi2 = 0.2929 * Stata 8 code. lfit * Stata 9 code and output. estat gof Logistic model for me, goodness-of-fit test number of observations = 308 number of covariate patterns = 75 Pearson chi2(69) = 63.83 Prob > chi2 = 0.6535
* We thank Silvano Andorno for providing the following code for the Stukel test quietly logit me2 symptd pb hist bse detcd predict p2 generate g2=ln(p2/(1-p2)) generate z21=0.5*g2^2 replace z21=0 if p2<0.5 generate z22=-0.5*g2^2 replace z22=0 if p2>=0.5 quietly logit me2 symptd pb hist bse detcd estimates store reduced quietly logit me2 symptd pb hist bse detcd z21 z22 estimates store full lrtest reduced full
Likelihood-ratio test LR chi2(2) = 1.86 (Assumption: reduced nested in full) Prob > chi2 = 0.3937
Table 8.13, page 283.
NOTE: mj = the number of observation that share the pattern.
logit me symptd pb hist bse detcd if me != 2 Iteration 0: log likelihood = -208.62772 Iteration 1: log likelihood = -167.49587 Iteration 2: log likelihood = -162.26366 Iteration 3: log likelihood = -161.78826 Iteration 4: log likelihood = -161.78146 Iteration 5: log likelihood = -161.78145 Logit estimates Number of obs = 338 LR chi2(5) = 93.69 Prob > chi2 = 0.0000 Log likelihood = -161.78145 Pseudo R2 = 0.2245 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- symptd | 2.091002 .4651287 4.50 0.000 1.179366 3.002638 pb | -.2426146 .073756 -3.29 0.001 -.3871737 -.0980554 hist | 1.385025 .4682596 2.96 0.003 .4672527 2.302796 bse | 1.363308 .5338994 2.55 0.011 .3168847 2.409732 detcd | .852694 .3654564 2.33 0.020 .1364125 1.568975 _cons | -2.765088 .9421802 -2.93 0.003 -4.611727 -.9184483 ------------------------------------------------------------------------------ predict p1 (option p assumed; Pr(me)) predict dx1, dx2 (74 missing values generated) predict db1, db (74 missing values generated) predict dd1, dd (74 missing values generated) predict h1, h (74 missing values generated) predict n1, n (74 missing values generated) format n1 symptd pb hist bse detcd %2.0f list n1 symptd pb hist bse detcd p1 db1 dx1 dd1 h1 if n1 == 4 | n1 == 63 n1 sym~d pb hist bse detcd p1 db1 dx1 dd1 h1 319. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 320. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 321. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 322. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 323. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 324. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 325. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 326. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 327. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 328. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 329. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 330. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 331. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 332. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 333. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 334. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 335. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 336. 63 1 9 0 1 1 .3448817 1.732725 7.037074 6.585556 .1975787 337. 4 0 6 0 0 0 .0144747 .5432962 33.5851 5.819932 .0159192 338. 4 0 6 0 0 0 .0144747 .5432962 33.5851 5.819932 .0159192 logit me symptd pb hist bse detcd if me != 1 Iteration 0: log likelihood = -169.82478 Iteration 1: log likelihood = -154.48353 Iteration 2: log likelihood = -153.48912 Iteration 3: log likelihood = -153.47233 Iteration 4: log likelihood = -153.47232 Logit estimates Number of obs = 308 LR chi2(5) = 32.70 Prob > chi2 = 0.0000 Log likelihood = -153.47232 Pseudo R2 = 0.0963 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- symptd | 1.15299 .3565788 3.23 0.001 .4541082 1.851871 pb | -.1537696 .0726013 -2.12 0.034 -.2960655 -.0114736 hist | 1.097696 .4593413 2.39 0.017 .1974035 1.997988 bse | .9534998 .5097419 1.87 0.061 -.0455759 1.952576 detcd | .0987046 .3190788 0.31 0.757 -.5266785 .7240876 _cons | -1.8381 .860046 -2.14 0.033 -3.52376 -.1524412 ------------------------------------------------------------------------------ predict p2 (option p assumed; Pr(me)) predict dx2, dx2 (104 missing values generated) predict db2, db (104 missing values generated) predict dd2, dd (104 missing values generated) predict h2, h (104 missing values generated) predict n2, n (104 missing values generated) list n2 symptd pb hist bse detcd p2 db2 dx2 dd2 h2 if n2 == 62 | n2 == 63 | n2 == 66 n2 sym~d pb hist bse detcd p2 db2 dx2 dd2 h2 237. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 238. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 239. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 240. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 241. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 242. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 243. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 244. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 245. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 247. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 248. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 249. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 251. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 253. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 254. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 255. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 256. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 347. 62 1 9 1 1 0 .4955399 .9564146 3.818863 5.26768 .2002846 360. 62 1 9 1 1 0 .4955399 .9564146 3.818863 5.26768 .2002846 363. 63 1 10 0 0 0 .0977211 .2639904 9.490052 4.780663 .0270647 365. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 371. 66 1 10 0 1 1 .2367462 .9990091 2.53433 3.013997 .282738 399. 62 1 9 1 1 0 .4955399 .9564146 3.818863 5.26768 .2002846
Table 8.14, page 285.
mlogit me symptd pb hist bse detcd if n2 != 62 & n1 != 63 & n2 != 66 Iteration 0: log likelihood = -365.25083 Iteration 1: log likelihood = -318.11909 Iteration 2: log likelihood = -314.01421 Iteration 3: log likelihood = -313.74957 Iteration 4: log likelihood = -313.74728 Iteration 5: log likelihood = -313.74728 Multinomial regression Number of obs = 372 LR chi2(10) = 103.01 Prob > chi2 = 0.0000 Log likelihood = -313.74728 Pseudo R2 = 0.1410 ------------------------------------------------------------------------------ me | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 2.124646 .4633131 4.59 0.000 1.216569 3.032723 pb | -.2162733 .0854258 -2.53 0.011 -.3837048 -.0488418 hist | 1.243508 .4417728 2.81 0.005 .3776495 2.109367 bse | 1.271312 .531037 2.39 0.017 .2304986 2.312125 detcd | .883019 .3691392 2.39 0.017 .1595194 1.606519 _cons | -2.891975 1.041649 -2.78 0.005 -4.933569 -.8503814 -------------+---------------------------------------------------------------- 2 | symptd | 1.190628 .3609934 3.30 0.001 .4830943 1.898162 pb | -.0803882 .078619 -1.02 0.307 -.2344787 .0737023 hist | .6058955 .4952242 1.22 0.221 -.3647261 1.576517 bse | 1.081212 .5122946 2.11 0.035 .0771333 2.085291 detcd | .4767587 .3403687 1.40 0.161 -.1903518 1.143869 _cons | -2.663662 .9556489 -2.79 0.005 -4.536699 -.7906244 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group)
Table 8.15, page 286.
mlogit me symptd pb hist bse detcd, rrr Iteration 0: log likelihood = -402.59901 Iteration 1: log likelihood = -354.2052 Iteration 2: log likelihood = -349.86452 Iteration 3: log likelihood = -349.56908 Iteration 4: log likelihood = -349.5663 Iteration 5: log likelihood = -349.5663 Multinomial regression Number of obs = 412 LR chi2(10) = 106.07 Prob > chi2 = 0.0000 Log likelihood = -349.5663 Pseudo R2 = 0.1317 ------------------------------------------------------------------------------ me | RRR Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | symptd | 8.123411 3.715893 4.58 0.000 3.314157 19.91149 pb | .7792101 .0565543 -3.44 0.001 .6758887 .8983259 hist | 3.705671 1.606787 3.02 0.003 1.584105 8.668614 bse | 3.445301 1.810244 2.35 0.019 1.230227 9.648703 detcd | 2.42343 .8633175 2.48 0.013 1.205592 4.871477 -------------+---------------------------------------------------------------- 2 | symptd | 3.087671 1.100329 3.16 0.002 1.53566 6.208219 pb | .8569993 .0622358 -2.12 0.034 .7433027 .9880871 hist | 2.89556 1.311229 2.35 0.019 1.191993 7.033828 bse | 2.601298 1.319734 1.88 0.060 .962375 7.031302 detcd | 1.120928 .3566931 0.36 0.720 .6007795 2.091417 ------------------------------------------------------------------------------ (Outcome me==0 is the comparison group) lincom [1]pb*-2, rrr ( 1) - 2.0 [1]pb = 0.0 ------------------------------------------------------------------------------ me | RRR Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 1.64699 .2390738 3.44 0.001 1.239174 2.189019 ------------------------------------------------------------------------------ lincom [2]pb*-2, rrr ( 1) - 2.0 [2]pb = 0.0 ------------------------------------------------------------------------------ me | RRR Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | 1.361567 .1977557 2.12 0.034 1.024258 1.809959 ------------------------------------------------------------------------------
Table 8.16, page 293.
use lowbwt.dta, clear (Hosmer and Lemeshow - from appendix 1) gen bwt4 = 0 replace bwt4 = 1 if 3000 > bwt | bwt<=3500 (143 real changes made) replace bwt4 = 2 if 2500 > bwt | bwt<=3000 (97 real changes made) replace bwt4 = 3 if bwt<=2500 (59 real changes made) tab2 bwt4 smoke -> tabulation of bwt4 by smoke | smoke bwt4 | 0 1 | Total -----------+----------------------+---------- 0 | 35 11 | 46 1 | 29 17 | 46 2 | 22 16 | 38 3 | 29 30 | 59 -----------+----------------------+---------- Total | 115 74 | 189
Middle of page.
logistic bwt4 smoke if bwt4 == 0 | bwt4 == 1 Logit estimates Number of obs = 92 LR chi2(1) = 1.86 Prob > chi2 = 0.1727 Log likelihood = -62.840008 Pseudo R2 = 0.0146 ------------------------------------------------------------------------------ bwt4 | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | 1.865204 .8603962 1.35 0.177 .7552265 4.606546 ------------------------------------------------------------------------------ logistic bwt4 smoke if bwt4 == 0 | bwt4 == 2 Logit estimates Number of obs = 84 LR chi2(1) = 3.16 Prob > chi2 = 0.0755 Log likelihood = -56.263134 Pseudo R2 = 0.0273 ------------------------------------------------------------------------------ bwt4 | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | 2.31405 1.103574 1.76 0.079 .9087269 5.892667 ------------------------------------------------------------------------------ logistic bwt4 smoke if bwt4 == 0 | bwt4 == 3 Logit estimates Number of obs = 105 LR chi2(1) = 8.10 Prob > chi2 = 0.0044 Log likelihood = -67.923441 Pseudo R2 = 0.0563 ------------------------------------------------------------------------------ bwt4 | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | 3.291536 1.424504 2.75 0.006 1.409346 7.687404 ------------------------------------------------------------------------------ * Stata 8 code. mlogit bwt4 smoke, basecategory(0) rrr * Stata 9 code and output. mlogit bwt4 smoke, baseoutcome(0) rrr Iteration 0: log likelihood = -259.65219 Iteration 1: log likelihood = -255.53804 Iteration 2: log likelihood = -255.48595 Iteration 3: log likelihood = -255.48592 Multinomial regression Number of obs = 189 LR chi2(3) = 8.33 Prob > chi2 = 0.0396 Log likelihood = -255.48592 Pseudo R2 = 0.0160 ------------------------------------------------------------------------------ bwt4 | RRR Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | smoke | 1.865204 .8603963 1.35 0.177 .7552264 4.606546 -------------+---------------------------------------------------------------- 2 | smoke | 2.31405 1.103573 1.76 0.079 .908727 5.892667 -------------+---------------------------------------------------------------- 3 | smoke | 3.291536 1.424503 2.75 0.006 1.409346 7.687402 ------------------------------------------------------------------------------ (Outcome bwt4==0 is the comparison group)
Table 8.17, page 294.
* Stata 8 code. mlogit bwt4 smoke, basecategory(0) rrr * Stata 9 code and output. mlogit bwt4 smoke, baseoutcome(0) rrr Iteration 0: log likelihood = -259.65219 Iteration 1: log likelihood = -255.53804 Iteration 2: log likelihood = -255.48595 Iteration 3: log likelihood = -255.48592 Multinomial regression Number of obs = 189 LR chi2(3) = 8.33 Prob > chi2 = 0.0396 Log likelihood = -255.48592 Pseudo R2 = 0.0160 ------------------------------------------------------------------------------ bwt4 | RRR Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | smoke | 1.865204 .8603963 1.35 0.177 .7552264 4.606546 -------------+---------------------------------------------------------------- 2 | smoke | 2.31405 1.103573 1.76 0.079 .908727 5.892667 -------------+---------------------------------------------------------------- 3 | smoke | 3.291536 1.424503 2.75 0.006 1.409346 7.687402 ------------------------------------------------------------------------------ (Outcome bwt4==0 is the comparison group) constraint define 1 [2]smoke=2*[1]smoke constraint define 2 [3]smoke=3*[1]smoke * Stata 8 code. mlogit bwt4 smoke, constraint(1 2) basecategory(0) * Stata 9 code and outcome. mlogit bwt4 smoke, constraint(1 2) baseoutcome(0) ( 1) - 2.0 [1]smoke + [2]smoke = 0.0 ( 2) - 3.0 [1]smoke + [3]smoke = 0.0 Iteration 0: log likelihood = -259.65219 Iteration 1: log likelihood = -255.67704 Iteration 2: log likelihood = -255.65281 Iteration 3: log likelihood = -255.65281 Multinomial regression Number of obs = 189 LR chi2(1) = 8.00 Prob > chi2 = 0.0047 Log likelihood = -255.65281 Pseudo R2 = 0.0154 ------------------------------------------------------------------------------ bwt4 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- 1 | smoke | .3695792 .1332141 2.77 0.006 .1084844 .630674 _cons | -.1099797 .2106498 -0.52 0.602 -.5228458 .3028864 -------------+---------------------------------------------------------------- 2 | smoke | .7391584 .2664281 2.77 0.006 .2169689 1.261348 _cons | -.4414182 .2333447 -1.89 0.059 -.8987655 .015929 -------------+---------------------------------------------------------------- 3 | smoke | 1.108738 .3996422 2.77 0.006 .3254533 1.892022 _cons | -.1750312 .2494677 -0.70 0.483 -.6639789 .3139164 ------------------------------------------------------------------------------ (Outcome bwt4==0 is the comparison group)
Middle of page 295.
display exp(.3695792) 1.4471255
lrtest in middle of page 295
* Stata 8 code. quietly mlogit bwt4 smoke, basecategory(0) * Stata 9 code. quietly mlogit bwt4 smoke, baseoutcome(0) lrtest, saving(0) * Stata 8 code. quietly mlogit bwt4 smoke, constraint(1 2) basecategory(0) * Stata 9 code. quietly mlogit bwt4 smoke, constraint(1 2) baseoutcome(0) lrtest, using(0) Mlogit: likelihood-ratio test chi2(2) = 0.33 Prob > chi2 = 0.8463
Table 8.18, page 296.
NOTE: Logit 1:
logit bwt4 smoke if bwt4 == 0 | bwt4 == 1 Iteration 0: log likelihood = -63.769541 Iteration 1: log likelihood = -62.840162 Iteration 2: log likelihood = -62.840008 Logit estimates Number of obs = 92 LR chi2(1) = 1.86 Prob > chi2 = 0.1727 Log likelihood = -62.840008 Pseudo R2 = 0.0146 ------------------------------------------------------------------------------ bwt4 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | .6233703 .461288 1.35 0.177 -.2807376 1.527478 _cons | -.1880522 .2511059 -0.75 0.454 -.6802108 .3041063 ------------------------------------------------------------------------------
NOTE: Logit 2:
gen bwc2 = . (189 missing values generated) replace bwc2 = 0 if bwt4 == 0 | bwt4 == 1 (92 real changes made) replace bwc2 = 1 if bwt4 == 2 (38 real changes made) logit bwc2 smoke Iteration 0: log likelihood = -78.546655 Iteration 1: log likelihood = -77.746128 Iteration 2: log likelihood = -77.743614 Logit estimates Number of obs = 130 LR chi2(1) = 1.61 Prob > chi2 = 0.2050 Log likelihood = -77.743614 Pseudo R2 = 0.0102 ------------------------------------------------------------------------------ bwc2 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | .5082248 .399114 1.27 0.203 -.2740243 1.290474 _cons | -1.067841 .247142 -4.32 0.000 -1.55223 -.5834512 ------------------------------------------------------------------------------ gen bwc3 = 0 replace bwc3 = 1 if bwt4 == 3 (59 real changes made) logit bwc3 smoke Iteration 0: log likelihood = -117.336 Iteration 1: log likelihood = -114.9123 Iteration 2: log likelihood = -114.9023 Logit estimates Number of obs = 189 LR chi2(1) = 4.87 Prob > chi2 = 0.0274 Log likelihood = -114.9023 Pseudo R2 = 0.0207 ------------------------------------------------------------------------------ bwc3 | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | .7040592 .3196386 2.20 0.028 .0775791 1.330539 _cons | -1.087051 .2147299 -5.06 0.000 -1.507914 -.6661886 ------------------------------------------------------------------------------
Table 8.19, page 297.
NOTE: In order to get the result using Wolfe’s program ocratio mentioned in the book on page 290, we need to recode the variable in reverse order. The Stata program ocratio can be downloaded from the internet (see How can I use the search command to search for programs and get additional help? for more information about using search).
gen bwt4_rec = bwt4 recode bwt4_rec 0 = 3 1 = 2 2 = 1 3 = 0 (189 changes made) ocratio bwt4_rec smoke
Continuation-ratio logit Estimates Number of obs = 411 chi2(1) = 8.19 Prob > chi2 = 0.0042 Log Likelihood = -255.5594 Pseudo R2 = 0.0158 ------------------------------------------------------------------------------ bwc3_rec | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | -.6265962 .2192267 -2.86 0.004 -1.056273 -.1969197 ------------------------------------------------------------------------------ _cut1 | -1.052336 .1862181 (Ancillary parameters) _cut2 | -1.113813 .2129495 _cut3 | -.1890080 .2204464 -----------------------------------------------------------------------------
Table 8.20, page 303.
gen bwt4n = 0 replace bwt4n = 1 if 2500 < bwt & bwt <=3000 (38 real changes made) replace bwt4n = 2 if 3000 < bwt & bwt <=3500 (46 real changes made) replace bwt4n = 3 if bwt > 3500 (46 real changes made) ologit bwt4n lwt Iteration 0: log likelihood = -259.65219 Iteration 1: log likelihood = -255.15519 Iteration 2: log likelihood = -255.14768 Ordered logit estimates Number of obs = 189 LR chi2(1) = 9.01 Prob > chi2 = 0.0027 Log likelihood = -255.14768 Pseudo R2 = 0.0173 ------------------------------------------------------------------------------ bwt4n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lwt | .0127375 .0043168 2.95 0.003 .0042767 .0211982 -------------+---------------------------------------------------------------- _cut1 | .8316033 .5686351 (Ancillary parameters) _cut2 | 1.70695 .5781657 _cut3 | 2.831112 .602725 ------------------------------------------------------------------------------
Table 8.21, page 304.
ologit bwt4n smoke Iteration 0: log likelihood = -259.65219 Iteration 1: log likelihood = -255.67803 Iteration 2: log likelihood = -255.6725 Ordered logit estimates Number of obs = 189 LR chi2(1) = 7.96 Prob > chi2 = 0.0048 Log likelihood = -255.6725 Pseudo R2 = 0.0153 ------------------------------------------------------------------------------ bwt4n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- smoke | -.7607847 .2718672 -2.80 0.005 -1.293635 -.2279348 -------------+---------------------------------------------------------------- _cut1 | -1.116297 .1984448 (Ancillary parameters) _cut2 | -.2476773 .1819248 _cut3 | .8667339 .1937335 ------------------------------------------------------------------------------
Table 8.22, page 306.
gen ptd = 1 replace ptd = 0 if ptl == 0 (159 real changes made) xi: ologit bwt4n age lwt i.race smoke ht ui ptd i.race _Irace_1-3 (naturally coded; _Irace_1 omitted) Iteration 0: log likelihood = -259.65219 Iteration 1: log likelihood = -235.91069 Iteration 2: log likelihood = -235.65121 Iteration 3: log likelihood = -235.65042 Ordered logit estimates Number of obs = 189 LR chi2(8) = 48.00 Prob > chi2 = 0.0000 Log likelihood = -235.65042 Pseudo R2 = 0.0924 ------------------------------------------------------------------------------ bwt4n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .0006257 .0274693 0.02 0.982 -.0532131 .0544645 lwt | .0128958 .0048733 2.65 0.008 .0033442 .0224473 _Irace_2 | -1.470897 .4346912 -3.38 0.001 -2.322876 -.6189183 _Irace_3 | -.869222 .3344913 -2.60 0.009 -1.524813 -.2136312 smoke | -.9877202 .3149779 -3.14 0.002 -1.605066 -.3703748 ht | -1.194 .6122466 -1.95 0.051 -2.393982 .0059809 ui | -.9129658 .4044862 -2.26 0.024 -1.705744 -.1201874 ptd | -.8219579 .4173644 -1.97 0.049 -1.639977 -.0039387 -------------+---------------------------------------------------------------- _cut1 | -.4952642 .87984 (Ancillary parameters) _cut2 | .5160991 .8816949 _cut3 | 1.803489 .8913835 ------------------------------------------------------------------------------ lincom age*10 ( 1) 10.0 age = 0.0 ------------------------------------------------------------------------------ bwt4n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .006257 .2746928 0.02 0.982 -.532131 .544645 ------------------------------------------------------------------------------ lincom lwt*10 ( 1) 10.0 lwt = 0.0 ------------------------------------------------------------------------------ bwt4n | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .1289576 .0487331 2.65 0.008 .0334424 .2244728 ------------------------------------------------------------------------------
Table 8.23, page 307.
di exp(-.006257) .99376253 di exp(-.1289576) .87901123 di exp(1.470897) 4.3531382 di exp(.869222) 2.3850546 di exp(.9877202) 2.685106 di exp(1.194) 3.3002559 di exp(.9129658) 2.4917015 di exp(.8219579) 2.2749496
Table 8.24, page 319.
use clslowbwt.dta, clear list id smoke race age lwt bwt low if id == 1 | id == 2 |id == 43 Observation 1 id 1 smoke 1 race 3 age 28 lwt 120 bwt 2865 low 0 Observation 2 id 1 smoke 1 race 3 age 33 lwt 141 bwt 2609 low 0 Observation 3 id 2 smoke 0 race 1 age 29 lwt 130 bwt 2613 low 0 Observation 4 id 2 smoke 0 race 1 age 34 lwt 151 bwt 3125 low 0 Observation 5 id 2 smoke 0 race 1 age 37 lwt 144 bwt 2481 low 1 Observation 109 id 43 smoke 1 race 2 age 24 lwt 105 bwt 2679 low 0 Observation 110 id 43 smoke 1 race 2 age 30 lwt 131 bwt 2240 low 1 Observation 111 id 43 smoke 1 race 2 age 35 lwt 121 bwt 2172 low 1 Observation 112 id 43 smoke 1 race 2 age 41 lwt 141 bwt 1853 low 1
Table 8.25, page 320.
NOTE: See text at the bottom of page 319.
xtlogit low age lwt smoke, i(id) pa robust Iteration 1: tolerance = .09292774 Iteration 2: tolerance = .00535895 Iteration 3: tolerance = .00003964 Iteration 4: tolerance = 9.801e-07 GEE population-averaged model Number of obs = 488 Group variable: id Number of groups = 188 Link: logit Obs per group: min = 2 Family: binomial avg = 2.6 Correlation: exchangeable max = 4 Wald chi2(3) = 13.46 Scale parameter: 1 Prob > chi2 = 0.0037 (standard errors adjusted for clustering on id) ------------------------------------------------------------------------------ | Semi-robust low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .0583975 .0195492 2.99 0.003 .0200818 .0967132 lwt | -.0091427 .0040935 -2.23 0.026 -.0171658 -.0011196 smoke | .7017452 .2829116 2.48 0.013 .1472486 1.256242 _cons | -1.342052 .5895171 -2.28 0.023 -2.497484 -.1866194 ------------------------------------------------------------------------------
Table 8.26, page 321.
NOTE: The computation of rho has been changed in Stata 7 as of April 6, 2001.
xtlogit low age lwt smoke, i(id) re Fitting comparison model: Iteration 0: log likelihood = -301.89672 Iteration 1: log likelihood = -288.88873 Iteration 2: log likelihood = -288.76222 Iteration 3: log likelihood = -288.76218 Fitting full model: rho = 0.0 log likelihood = -288.76218 rho = 0.1 log likelihood = -283.8448 rho = 0.2 log likelihood = -278.75435 rho = 0.3 log likelihood = -273.49059 rho = 0.4 log likelihood = -268.05351 rho = 0.5 log likelihood = -262.44808 rho = 0.6 log likelihood = -256.69965 rho = 0.7 log likelihood = -250.90472 rho = 0.8 log likelihood = -245.44398 Iteration 0: log likelihood = -250.90472 Iteration 1: log likelihood = -244.98109 Iteration 2: log likelihood = -236.66884 Iteration 3: log likelihood = -233.69517 Iteration 4: log likelihood = -233.03016 Iteration 5: log likelihood = -232.98816 Iteration 6: log likelihood = -232.98805 Random-effects logit Number of obs = 488 Group variable (i) : id Number of groups = 188 Random effects u_i ~ Gaussian Obs per group: min = 2 avg = 2.6 max = 4 Wald chi2(3) = 13.77 Log likelihood = -232.98805 Prob > chi2 = 0.0032 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .1409224 .0493303 2.86 0.004 .0442368 .2376079 lwt | -.0152739 .00824 -1.85 0.064 -.0314241 .0008762 smoke | 1.860842 .6391547 2.91 0.004 .608122 3.113562 _cons | -4.642465 1.677828 -2.77 0.006 -7.930948 -1.353982 -------------+---------------------------------------------------------------- /lnsig2u | 2.775743 .3674805 2.055495 3.495992 -------------+---------------------------------------------------------------- sigma_u | 4.006314 .7361212 2.794763 5.743081 rho | .8298968 .0157686 .7036307 .9093022 ------------------------------------------------------------------------------ Likelihood ratio test of rho=0: chibar2(01) = 111.55 Prob >= chibar2 = 0.000
Table 8.27, page 322.
NOTE: The values in this table are given in the two outputs above and with the above equation (on page 317).
Bottom of page 320.
loneway low id One-way Analysis of Variance for low: Number of obs = 488 R-squared = 0.7571 Source SS df MS F Prob > F ------------------------------------------------------------------------- Between id 78.943306 187 .42215672 5.00 0.0000 Within id 25.333333 300 .08444444 ------------------------------------------------------------------------- Total 104.27664 487 .21412041 Intraclass Asy. correlation S.E. [95% Conf. Interval] ------------------------------------------------ 0.60648 0.03975 0.52856 0.68439 Estimated SD of id effect .3607527 Estimated SD within id .2905933 Est. reliability of a id mean .799969 (evaluated at n=2.59)
Table 8.28, page 322.
quietly xtlogit low age lwt smoke, i(id) re lincom age*5 ( 1) 5.0 [low]age = 0.0 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .704612 .2466513 2.86 0.004 .2211842 1.18804 ------------------------------------------------------------------------------ lincom lwt*10 ( 1) 10.0 [low]lwt = 0.0 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -.1527394 .0824004 -1.85 0.064 -.3142413 .0087624 ------------------------------------------------------------------------------ quietly xtlogit low age lwt smoke, i(id) pa robust lincom age*5 ( 1) 5.0 age = 0.0 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | .2919875 .0977459 2.99 0.003 .1004091 .483566 ------------------------------------------------------------------------------ lincom lwt*10 ( 1) 10.0 lwt = 0.0 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- (1) | -.0914273 .0409349 -2.23 0.026 -.1716582 -.0111964 ------------------------------------------------------------------------------ di exp(.704612) 2.0230616 di exp(-.1527394) .85835338 di exp(1.861) 6.4301637 di exp(.2919875) 1.3390863 di exp(-.0914273) .91262766 di exp(.702) 2.0177842
Table 8.29, page 326.
xtlogit low age lwt smoke, i(id) Fitting comparison model: Iteration 0: log likelihood = -301.89672 Iteration 1: log likelihood = -288.88873 Iteration 2: log likelihood = -288.76222 Iteration 3: log likelihood = -288.76218 Fitting full model: tau = 0.0 log likelihood = -288.76218 tau = 0.1 log likelihood = -283.8448 tau = 0.2 log likelihood = -278.75435 tau = 0.3 log likelihood = -273.49059 tau = 0.4 log likelihood = -268.05351 tau = 0.5 log likelihood = -262.44808 tau = 0.6 log likelihood = -256.69965 tau = 0.7 log likelihood = -250.90472 tau = 0.8 log likelihood = -245.44398 Iteration 0: log likelihood = -250.90472 Iteration 1: log likelihood = -244.98109 Iteration 2: log likelihood = -236.66884 Iteration 3: log likelihood = -233.69517 Iteration 4: log likelihood = -233.03016 Iteration 5: log likelihood = -232.98816 Iteration 6: log likelihood = -232.98805 Random-effects logistic regression Number of obs = 488 Group variable (i): id Number of groups = 188 Random effects u_i ~ Gaussian Obs per group: min = 2 avg = 2.6 max = 4 Wald chi2(3) = 13.77 Log likelihood = -232.98805 Prob > chi2 = 0.0032 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .1409224 .0493303 2.86 0.004 .0442368 .2376079 lwt | -.0152739 .00824 -1.85 0.064 -.0314241 .0008762 smoke | 1.860842 .6391547 2.91 0.004 .608122 3.113562 _cons | -4.642465 1.677828 -2.77 0.006 -7.930948 -1.353982 -------------+---------------------------------------------------------------- /lnsig2u | 2.775743 .3674805 2.055495 3.495992 -------------+---------------------------------------------------------------- sigma_u | 4.006314 .7361212 2.794763 5.743081 rho | .8298968 .0518765 .7036307 .9093022 ------------------------------------------------------------------------------ Likelihood-ratio test of rho=0: chibar2(01) = 111.55 Prob >= chibar2 = 0.000
Table 8.30, page 329.
tsset id birth panel variable: id, 1 to 188 time variable: birth, 1 to 4 gen prevlow = l.low (188 missing values generated) logit low age lwt smoke prevlow Iteration 0: log likelihood = -189.53785 Iteration 1: log likelihood = -118.72848 Iteration 2: log likelihood = -114.25647 Iteration 3: log likelihood = -113.99221 Iteration 4: log likelihood = -113.99062 Logit estimates Number of obs = 300 LR chi2(4) = 151.09 Prob > chi2 = 0.0000 Log likelihood = -113.99062 Pseudo R2 = 0.3986 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- age | .0801916 .0337502 2.38 0.017 .0140425 .1463408 lwt | -.0166757 .0065635 -2.54 0.011 -.02954 -.0038113 smoke | 1.687073 .3612794 4.67 0.000 .9789783 2.395167 prevlow | 3.414563 .3892281 8.77 0.000 2.651689 4.177436 _cons | -2.490903 1.259569 -1.98 0.048 -4.959614 -.0221929 ------------------------------------------------------------------------------
Table 8.31, page 333.
use lowbwt.dta, clear (Hosmer and Lemeshow - from appendix 1)
tab2 low ptl if age >=30 -> tabulation of low by ptl if age >=30 | history of premature | labor < 2500g | 0 1 | Total -----------+----------------------+---------- 0 | 19 4 | 23 1 | 2 2 | 4 -----------+----------------------+---------- Total | 21 6 | 27
Table 8.32, page 334. We thank Silvano Andorno for providing the code for this example.
quietly: exlogistic low ptl if age >=30, saving(distrib) use distrib, clear egen sum1=total(_f_) generate p = _f_/ sum1 list ptl _f_ p, noobs sum(_f_ p)
+------------------------+ | ptl _f_ p | |------------------------| | 0 5985 .3410257 | | 1 7980 .4547009 | | 2 3150 .1794872 | | 3 420 .0239316 | | 4 15 .0008547 | |------------------------| Sum | 17550 1 | +------------------------+
Table 8.33, page 335.
MLE:
logit low ptl if age >=30 Iteration 0: log likelihood = -11.326051 Iteration 1: log likelihood = -10.547126 Iteration 2: log likelihood = -10.423619 Iteration 3: log likelihood = -10.423421 Logit estimates Number of obs = 27 LR chi2(1) = 1.81 Prob > chi2 = 0.1791 Log likelihood = -10.423421 Pseudo R2 = 0.0797 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ptl | 1.558145 1.141323 1.37 0.172 -.6788077 3.795097 _cons | -2.251292 .7433911 -3.03 0.002 -3.708312 -.7942721 ------------------------------------------------------------------------------
Table 8.34, page 336.
tab2 low smoke if age >=30 -> tabulation of low by smoke if age >=30 | smoke < 2500g | 0 1 | Total -----------+----------------------+---------- 0 | 17 6 | 23 1 | 0 4 | 4 -----------+----------------------+---------- Total | 17 10 | 27
Table 8.35, page 336.
NOTE: LogExact is needed to make this table.
Table 8.36, page 338.
gen ptd = 1 replace ptd = 0 if ptl == 0
logit low lwt smoke ptd if age >=25
Iteration 0: log likelihood = -40.607858 Iteration 1: log likelihood = -35.561288 Iteration 2: log likelihood = -35.277974 Iteration 3: log likelihood = -35.276275 Iteration 4: log likelihood = -35.276275 Logistic regression Number of obs = 69 LR chi2(3) = 10.66 Prob > chi2 = 0.0137 Log likelihood = -35.276275 Pseudo R2 = 0.1313 ------------------------------------------------------------------------------ low | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- lwt | -.0193155 .011657 -1.66 0.098 -.0421628 .0035318 smoke | .2489932 .6086556 0.41 0.682 -.9439498 1.441936 ptd | 1.392705 .6687296 2.08 0.037 .0820189 2.703391 _cons | 1.096696 1.559898 0.70 0.482 -1.960647 4.15404 ------------------------------------------------------------------------------
exlogistic low lwt smoke ptd if age>=25, mem(1000m) coef
Enumerating sample-space combinations: observation 1: enumerations = 2 observation 2: enumerations = 4 observation 3: enumerations = 8 observation 4: enumerations = 16 observation 5: enumerations = 32 observation 6: enumerations = 64 ... observation 65: enumerations = 969120 observation 66: enumerations = 813626 observation 67: enumerations = 639700 observation 68: enumerations = 479915 observation 69: enumerations = 250420 Exact logistic regression Number of obs = 69 Model score = 10.29496 Pr >= score = 0.0130 --------------------------------------------------------------------------- low | Coef. Suff. 2*Pr(Suff.) [95% Conf. Interval] -------------+------------------------------------------------------------- lwt | -.0184291 2309 0.0833 -.04257 .0021023 smoke | .2563555 9 0.8825 -1.111262 1.567583 pt101 | 1.310344 8 0.0806 -.13651 2.798213 ---------------------------------------------------------------------------
Table 8.37, page 344.
use uis.dta, clear gen ages = (age-32)/6 gen ndrugtxs = (ndrugtx-5)/5 logit dfree ages ndrugtxs ivhx2 ivhx3 race treat Iteration 0: log likelihood = -326.86446 Iteration 1: log likelihood = -310.42821 Iteration 2: log likelihood = -309.86176 Iteration 3: log likelihood = -309.8567 Iteration 4: log likelihood = -309.8567 Logit estimates Number of obs = 575 LR chi2(6) = 34.02 Prob > chi2 = 0.0000 Log likelihood = -309.8567 Pseudo R2 = 0.0520 ------------------------------------------------------------------------------ dfree | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- ages | .305763 .1038541 2.94 0.003 .1022126 .5093134 ndrugtxs | -.3159991 .1282624 -2.46 0.014 -.5673889 -.0646094 ivhx2 | -.5928725 .2864333 -2.07 0.038 -1.154272 -.0314735 ivhx3 | -.7600441 .2489941 -3.05 0.002 -1.248064 -.2720245 race | .2081089 .221453 0.94 0.347 -.2259309 .6421488 treat | .438959 .1991429 2.20 0.028 .0486461 .829272 _cons | -1.041049 .2097129 -4.96 0.000 -1.452079 -.6300195 ------------------------------------------------------------------------------