. * do-file for lecture 5a of VHM 812/802, Winter 2025 . version 18 /* works also with versions 14-17 */ . set more off . set scheme stcolor_alt . cd "r:\" r:\ . . use nocardia.dta, clear . keep id casecont dcpct dneo dclox /* drop variables not needed for now */ . . * multiple logistic regression model . logit casecont dcpct i.dneo##i.dclox Iteration 0: Log likelihood = -74.859896 Iteration 1: Log likelihood = -52.23958 Iteration 2: Log likelihood = -51.712191 Iteration 3: Log likelihood = -51.70842 Iteration 4: Log likelihood = -51.708419 Logistic regression Number of obs = 108 LR chi2(4) = 46.30 Prob > chi2 = 0.0000 Log likelihood = -51.708419 Pseudo R2 = 0.3093 ------------------------------------------------------------------------------ casecont | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- dcpct | .0226175 .0077233 2.93 0.003 .0074802 .0377549 | dneo | yes | 3.184002 .8372021 3.80 0.000 1.543116 4.824888 | dclox | yes | .4457043 1.026029 0.43 0.664 -1.565275 2.456683 | dneo#dclox | yes#yes | -2.551997 1.205077 -2.12 0.034 -4.913904 -.190089 | _cons | -3.776896 .9932539 -3.80 0.000 -5.723638 -1.830154 ------------------------------------------------------------------------------ . estat ic Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 108 -74.8599 -51.70842 5 113.4168 126.8275 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] IC note. . . * covariate patterns . predict cov, number . codebook cov, c Variable Obs Unique Mean Min Max Label --------------------------------------------------------------------------------------------------------------------------------------------- > --------------------------------- cov 108 30 22.2037 1 30 covariate pattern --------------------------------------------------------------------------------------------------------------------------------------------- > --------------------------------- . bysort cov: egen ncov=count(id) . by cov: egen propcas=mean(casecont) . by cov: gen within=_n . order id cov ncov dcpct dneo dclox . br cov ncov dcpct dneo dclox propcas if within==1 . . * Pearson residuals . predict pv /* predicted probabilities */ (option pr assumed; Pr(casecont)) . predict pearson, residual . gen pearson_ind=(casecont-pv)/sqrt(pv*(1-pv)) . /* individual Pearson residuals also from: > glm casecont dcpct i.dneo##i.dclox, fam(bin) > predict pearson_ind, pearson > */ . list id cov ncov dcpct dneo dclox propcas pv pearson pearson_ind if cov==9 /* VER 16.6 */ +------------------------------------------------------------------------------------+ | id cov ncov dcpct dneo dclox propcas pv pearson pearson~d | |------------------------------------------------------------------------------------| 17. | 22 9 2 20 yes no .5 .4649217 .0994614 -.9321402 | 18. | 86 9 2 20 yes no .5 .4649217 .0994614 1.0728 | +------------------------------------------------------------------------------------+ . . * goodness-of-fit tests . * Pearson goodness-of-fit test . estat gof Goodness-of-fit test after logistic model Variable: casecont Number of observations = 108 Number of covariate patterns = 30 Pearson chi2(25) = 53.49 Prob > chi2 = 0.0008 . /* demonstrate test=sum of Pearson residuals^2 across covariate patterns > generate pearson2=pearson^2 > total pearson2 if within==1 */ . * Hosmer-Lemeshow test . estat gof, group(10) table /* VER 16.7 */ note: obs collapsed on 10 quantiles of estimated probabilities. Goodness-of-fit test after logistic model Variable: casecont Table collapsed on quantiles of estimated probabilities +--------------------------------------------------------+ | Group | Prob | Obs_1 | Exp_1 | Obs_0 | Exp_0 | Total | |-------+--------+-------+-------+-------+-------+-------| | 1 | 0.0387 | 1 | 0.3 | 10 | 10.7 | 11 | | 2 | 0.1802 | 2 | 2.2 | 12 | 11.8 | 14 | | 3 | 0.2555 | 3 | 3.0 | 9 | 9.0 | 12 | | 4 | 0.3823 | 1 | 2.5 | 6 | 4.5 | 7 | | 5 | 0.4119 | 4 | 3.9 | 6 | 6.1 | 10 | |-------+--------+-------+-------+-------+-------+-------| | 6 | 0.7509 | 8 | 8.5 | 6 | 5.5 | 14 | | 10 | 0.8414 | 35 | 33.6 | 5 | 6.4 | 40 | +--------------------------------------------------------+ Number of observations = 108 Number of groups = 7 Hosmer–Lemeshow chi2(5) = 3.85 Prob > chi2 = 0.5715 Warning: There are only 7 distinct quantiles because of ties. . /* demonstration of calculation of expected values > tab pv > total pv if pv<0.0388 > total pv if pv>0.0388 & pv<0.182 > */ . * calculation of the deviance chi-square statistic . estimates store red . logit casecont i.cov, asis Iteration 0: Log likelihood = -74.859896 Iteration 1: Log likelihood = -38.990447 Iteration 2: Log likelihood = -37.404488 Iteration 3: Log likelihood = -37.080184 Iteration 4: Log likelihood = -37.021569 Iteration 5: Log likelihood = -37.007145 Iteration 6: Log likelihood = -37.004043 Iteration 7: Log likelihood = -37.003335 Iteration 8: Log likelihood = -37.003217 Iteration 9: Log likelihood = -37.003204 Iteration 10: Log likelihood = -37.003202 Logistic regression Number of obs = 108 LR chi2(29) = 75.71 Prob > chi2 = 0.0000 Log likelihood = -37.003202 Pseudo R2 = 0.5057 ------------------------------------------------------------------------------ casecont | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- cov | 2 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 3 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 4 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 5 | -3.86e-09 4961.866 -0.00 1.000 -9725.079 9725.079 6 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 7 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 8 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 9 | 17.76101 2717.726 0.01 0.995 -5308.885 5344.407 10 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 11 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 12 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 13 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 14 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 15 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 16 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 17 | 18.85932 2717.726 0.01 0.994 -5307.786 5345.505 18 | 17.76101 2717.726 0.01 0.995 -5308.885 5344.407 19 | 17.76101 2717.726 0.01 0.995 -5308.885 5344.407 20 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 21 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 22 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 23 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 24 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 25 | 35.52202 7686.89 0.00 0.996 -15030.51 15101.55 26 | -3.86e-09 7686.89 -0.00 1.000 -15066.03 15066.03 27 | 15.81523 2717.726 0.01 0.995 -5310.83 5342.461 28 | 16.25719 2717.726 0.01 0.995 -5310.388 5342.903 29 | 19.64793 2717.726 0.01 0.994 -5306.997 5346.293 30 | 17.53795 2717.726 0.01 0.995 -5309.108 5344.183 | _cons | -17.76101 2717.726 -0.01 0.995 -5344.406 5308.884 ------------------------------------------------------------------------------ . lrtest red /* deviance statistic D */ Likelihood-ratio test Assumption: red nested within . LR chi2(25) = 29.41 Prob > chi2 = 0.2471 . . * predictive ability . logit casecont dcpct i.dneo##i.dclox Iteration 0: Log likelihood = -74.859896 Iteration 1: Log likelihood = -52.23958 Iteration 2: Log likelihood = -51.712191 Iteration 3: Log likelihood = -51.70842 Iteration 4: Log likelihood = -51.708419 Logistic regression Number of obs = 108 LR chi2(4) = 46.30 Prob > chi2 = 0.0000 Log likelihood = -51.708419 Pseudo R2 = 0.3093 ------------------------------------------------------------------------------ casecont | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- dcpct | .0226175 .0077233 2.93 0.003 .0074802 .0377549 | dneo | yes | 3.184002 .8372021 3.80 0.000 1.543116 4.824888 | dclox | yes | .4457043 1.026029 0.43 0.664 -1.565275 2.456683 | dneo#dclox | yes#yes | -2.551997 1.205077 -2.12 0.034 -4.913904 -.190089 | _cons | -3.776896 .9932539 -3.80 0.000 -5.723638 -1.830154 ------------------------------------------------------------------------------ . estat classification, cutoff(0.5) /* option not needed: the default is 0.5 */ Logistic model for casecont -------- True -------- Classified | D ~D | Total -----------+--------------------------+----------- + | 41 9 | 50 - | 13 45 | 58 -----------+--------------------------+----------- Total | 54 54 | 108 Classified + if predicted Pr(D) >= .5 True D defined as casecont != 0 -------------------------------------------------- Sensitivity Pr( +| D) 75.93% Specificity Pr( -|~D) 83.33% Positive predictive value Pr( D| +) 82.00% Negative predictive value Pr(~D| -) 77.59% -------------------------------------------------- False + rate for true ~D Pr( +|~D) 16.67% False - rate for true D Pr( -| D) 24.07% False + rate for classified + Pr(~D| +) 18.00% False - rate for classified - Pr( D| -) 22.41% -------------------------------------------------- Correctly classified 79.63% -------------------------------------------------- . lsens /* two-curve ROC */ . lroc /* one-curve ROC, with AUC */ Logistic model for casecont Number of observations = 108 Area under ROC curve = 0.8503 . . * manual coding of leave-one-out cross-validation . * note: code requires all observations to be used in model . scalar cutoff=0.5 /* change if different cutoff is desired */ . generate obsno=_n /* id variable in data could be used as well */ . capture drop cvprob . generate cvprob=. (108 missing values generated) . * cross-validation loop . quietly forvalues i=1(1)`=_N'{ . generate estpos=cvprob>cutoff . table estpos casecont /* classification table */ ----------------------------- | Case - Control | no yes Total --------+-------------------- estpos | 0 | 45 13 58 1 | 9 41 50 Total | 54 54 108 ----------------------------- . diagt casecont estpos /* uses add-on command diagt */ Case - | estpos Control | Pos. Neg. | Total -----------+----------------------+---------- Abnormal | 41 13 | 54 Normal | 9 45 | 54 -----------+----------------------+---------- Total | 50 58 | 108 True abnormal diagnosis defined as casecont = 1 (labelled yes) [95% Confidence Interval] --------------------------------------------------------------------------- Prevalence Pr(A) 50% 40% 59.8% --------------------------------------------------------------------------- Sensitivity Pr(+|A) 75.9% 62.4% 86.5% Specificity Pr(-|N) 83.3% 70.7% 92.1% ROC area (Sens. + Spec.)/2 .796 .72 .873 --------------------------------------------------------------------------- Likelihood ratio (+) Pr(+|A)/Pr(+|N) 4.56 2.46 8.43 Likelihood ratio (-) Pr(-|A)/Pr(-|N) .289 .177 .471 Odds ratio LR(+)/LR(-) 15.8 6.16 40.3 Positive predictive value Pr(A|+) 82% 68.6% 91.4% Negative predictive value Pr(N|-) 77.6% 64.7% 87.5% --------------------------------------------------------------------------- . roctab casecont cvprob, sum ROC Asymptotic normal Obs area Std. err. [95% conf. interval] ------------------------------------------------------------ 108 0.7901 0.0482 0.69556 0.88469 . . * residuals . * reload data to work with clean dataset . use nocardia.dta, clear . keep id casecont dcpct dneo dclox /* drop variables not needed for now */ . logit casecont dcpct i.dneo##i.dclox Iteration 0: Log likelihood = -74.859896 Iteration 1: Log likelihood = -52.23958 Iteration 2: Log likelihood = -51.712191 Iteration 3: Log likelihood = -51.70842 Iteration 4: Log likelihood = -51.708419 Logistic regression Number of obs = 108 LR chi2(4) = 46.30 Prob > chi2 = 0.0000 Log likelihood = -51.708419 Pseudo R2 = 0.3093 ------------------------------------------------------------------------------ casecont | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- dcpct | .0226175 .0077233 2.93 0.003 .0074802 .0377549 | dneo | yes | 3.184002 .8372021 3.80 0.000 1.543116 4.824888 | dclox | yes | .4457043 1.026029 0.43 0.664 -1.565275 2.456683 | dneo#dclox | yes#yes | -2.551997 1.205077 -2.12 0.034 -4.913904 -.190089 | _cons | -3.776896 .9932539 -3.80 0.000 -5.723638 -1.830154 ------------------------------------------------------------------------------ . predict cov, number . bysort cov: egen ncov=count(id) . by cov: egen propcas=mean(casecont) . by cov: gen within=_n . predict pv (option pr assumed; Pr(casecont)) . predict pearson, residual . predict stdres, rstandard . predict devres, deviance . summarize pearson stdres devres, d Pearson residual ------------------------------------------------------------- Percentiles Smallest 1% -1.362611 -1.362611 5% -1.160254 -1.362611 10% -.7691103 -1.362611 Obs 108 25% -.4060664 -1.160254 Sum of wgt. 108 50% .3200594 Mean .0860838 Largest Std. dev. .8452258 75% .4556087 1.226159 90% .4919042 1.329946 Variance .7144067 95% 1.013823 2.068801 Skewness 2.901567 99% 2.068801 5.902408 Kurtosis 22.13769 standardized Pearson residual ------------------------------------------------------------- Percentiles Smallest 1% -2.145999 -2.145999 5% -2.145999 -2.145999 10% -2.145999 -2.145999 Obs 108 25% -.768505 -2.145999 Sum of wgt. 108 50% .5455669 Mean .1059213 Largest Std. dev. 1.238681 75% 1.007749 1.305849 90% 1.007749 1.393654 Variance 1.534332 95% 1.043455 2.145999 Skewness .4225766 99% 2.145999 5.975402 Kurtosis 6.280676 deviance residual ------------------------------------------------------------- Percentiles Smallest 1% -1.700145 -1.700145 5% -1.0772 -1.700145 10% -.9640501 -1.700145 Obs 108 25% -.5629362 -1.213984 Sum of wgt. 108 50% .3178885 Mean .0251858 Largest Std. dev. .7229696 75% .4669968 1.189092 90% .5064911 1.427164 Variance .522685 95% 1.058873 1.824234 Skewness .0948717 99% 1.824234 2.675452 Kurtosis 3.914117 . twoway (scatter stdres cov [aweight=ncov], msymbol(Oh)) (scatter stdres cov, mlabel(cov) msize(tiny)), legend(off) yline(0) /* VER 16.11 */ . twoway (scatter stdres pv [aweight=ncov], msymbol(Oh)) (scatter stdres pv, mlabel(cov) msize(tiny)), legend(off) yline(0) . * plot with individual Pearson residuals, for illustration only . gen pearson_ind=(casecont-pv)/sqrt(pv*(1-pv)) . scatter pearson_ind pv, yline(0) . . * diagnostics . predict lev, hat . predict dx2, dx2 . predict ddev, ddeviance . predict dbeta, dbeta . summarize lev dx2 ddev dbeta Variable | Obs Mean Std. dev. Min Max -------------+--------------------------------------------------------- lev | 108 .5231303 .3477705 .0202177 .9318134 dx2 | 108 1.531344 3.567081 .0113128 35.70543 ddev | 108 1.390318 1.521429 .011285 7.336179 dbeta | 108 8.024228 18.65432 .0005346 62.93452 . list cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta if cov==7 & within==1 +-------------------------------------------------------------------------------------------------------------+ | cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta | |-------------------------------------------------------------------------------------------------------------| 15. | 7 1 1 .027903 5.902408 5.975402 2.675452 .0242821 35.70543 7.336179 .8885792 | +-------------------------------------------------------------------------------------------------------------+ . list cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta if cov==28 & within==1 +------------------------------------------------------------------------------------------------------------------+ | cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta | |------------------------------------------------------------------------------------------------------------------| 51. | 28 11 .1818182 .2555094 -.5603756 -2.145999 -.5813009 .9318134 4.605314 4.955674 62.93452 | +------------------------------------------------------------------------------------------------------------------+ . * graphs for leverage . twoway (scatter lev pv [aweight=ncov], msymbol(Oh)) (scatter lev pv, mlabel(cov) msize(tiny)), legend(off) . twoway (scatter stdres lev[aweight=ncov], msymbol(Oh)) (scatter stdres lev, mlabel(cov) msize(tiny)), legend(off) yline(0) . * graphs for dx2 and ddev . twoway (scatter dx2 pv [aweight=ncov], msymbol(Oh)) (scatter dx2 pv, mlabel(cov) msize(tiny)), legend(off) . twoway (scatter dx2 lev [aweight=ncov], msymbol(Oh)) (scatter dx2 lev, mlabel(cov) msize(tiny)), legend(off) . twoway (scatter ddev pv [aweight=ncov], msymbol(Oh)) (scatter ddev pv, mlabel(cov) msize(tiny)), legend(off) . twoway (scatter ddev lev [aweight=ncov], msymbol(Oh)) (scatter ddev lev, mlabel(cov) msize(tiny)), legend(off) . * graphs for dbeta . twoway (scatter dbeta pv [aweight=ncov], msymbol(Oh)) (scatter dbeta pv, mlabel(cov) msize(tiny)), legend(off) . twoway (scatter dbeta lev [aweight=ncov], msymbol(Oh)) (scatter dbeta lev, mlabel(cov) msize(tiny)), legend(off) . * complete table of most extreme covariate patterns (VER 16.12) . list cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta if inlist(cov,7,27,28,29,30) & within==1 +------------------------------------------------------------------------------------------------------------------+ | cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta | |------------------------------------------------------------------------------------------------------------------| 15. | 7 1 1 .027903 5.902408 5.975402 2.675452 .0242821 35.70543 7.336179 .8885792 | 43. | 27 8 .125 .1801775 -.4060664 -.768505 -.4250261 .7208095 .5906 .6470392 1.524801 | 51. | 28 11 .1818182 .2555094 -.5603756 -2.145999 -.5813009 .9318134 4.605314 4.955674 62.93452 | 62. | 29 38 .8684211 .8414233 .4556087 1.007749 .4669968 .7956007 1.015558 1.06696 3.95294 | 100. | 30 9 .4444444 .3923522 .3200594 .567266 .3178885 .6816627 .3217908 .3174404 .6890578 | +------------------------------------------------------------------------------------------------------------------+ . . * analysis for grouped dcpct . use nocardia.dta, clear . egen dcpct3=cut(dcpct), at(0,50,100,1000) . tab dcpct dcpct3 Pcnt. of | cows dry | dcpct3 treated | 0 50 100 | Total -----------+---------------------------------+---------- 0 | 7 0 0 | 7 1 | 2 0 0 | 2 3 | 1 0 0 | 1 5 | 3 0 0 | 3 7 | 1 0 0 | 1 10 | 1 0 0 | 1 14 | 1 0 0 | 1 20 | 2 0 0 | 2 25 | 3 0 0 | 3 30 | 2 0 0 | 2 40 | 1 0 0 | 1 50 | 0 7 0 | 7 75 | 0 4 0 | 4 80 | 0 1 0 | 1 83 | 0 1 0 | 1 90 | 0 1 0 | 1 95 | 0 1 0 | 1 99 | 0 3 0 | 3 100 | 0 0 66 | 66 -----------+---------------------------------+---------- Total | 24 18 66 | 108 . logit casecont i.dcpct3 i.dneo##i.dclox Iteration 0: Log likelihood = -74.859896 Iteration 1: Log likelihood = -52.081216 Iteration 2: Log likelihood = -51.634967 Iteration 3: Log likelihood = -51.632242 Iteration 4: Log likelihood = -51.632242 Logistic regression Number of obs = 108 LR chi2(5) = 46.46 Prob > chi2 = 0.0000 Log likelihood = -51.632242 Pseudo R2 = 0.3103 ------------------------------------------------------------------------------ casecont | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- dcpct3 | 50 | 1.361002 .819178 1.66 0.097 -.2445579 2.966561 100 | 2.026562 .6855237 2.96 0.003 .6829604 3.370164 | dneo | yes | 3.19238 .8361783 3.82 0.000 1.5535 4.831259 | dclox | yes | .4529145 1.026657 0.44 0.659 -1.559296 2.465125 | dneo#dclox | yes#yes | -2.532558 1.207714 -2.10 0.036 -4.899634 -.1654829 | _cons | -3.531226 .9364287 -3.77 0.000 -5.366593 -1.69586 ------------------------------------------------------------------------------ . estimates store red . estat ic Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- red | 108 -74.8599 -51.63224 6 115.2645 131.3573 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] IC note. . estat gof Goodness-of-fit test after logistic model Variable: casecont Number of observations = 108 Number of covariate patterns = 11 Pearson chi2(5) = 8.22 Prob > chi2 = 0.1444 . * recompute residuals and diagnosticd . predict cov, number . bysort cov: egen ncov=count(id) . by cov: egen propcas=mean(casecont) . by cov: gen within=_n . list cov ncov propcas dneo dclox dcpct3 if within==1, sep(20) noobs +-----------------------------------------------+ | cov ncov propcas dneo dclox dcpct3 | |-----------------------------------------------| | 1 12 .0833333 no no 0 | | 2 11 .3636364 yes no 0 | | 3 1 0 yes yes 0 | | 4 2 0 no no 50 | | 5 1 1 no yes 50 | | 6 10 .7 yes no 50 | | 7 5 .2 yes yes 50 | | 8 8 .125 no no 100 | | 9 11 .1818182 no yes 100 | | 10 38 .8684211 yes no 100 | | 11 9 .4444444 yes yes 100 | +-----------------------------------------------+ . predict pv (option pr assumed; Pr(casecont)) . predict pearson, residual . predict stdres, rstandard . predict devres, deviance . predict lev, hat . predict dx2, dx2 . predict ddev, ddeviance . predict dbeta, dbeta . list cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta if within==1, noobs sep(20) +------------------------------------------------------------------------------------------------------------------+ | cov ncov propcas pv pearson stdres devres lev dx2 ddev dbeta | |------------------------------------------------------------------------------------------------------------------| | 1 12 .0833333 .0284367 1.144093 1.358481 .9331458 .2907239 1.845472 1.227676 .7564373 | | 2 11 .3636364 .4160897 -.3529414 -1.073387 -.355453 .8918833 1.152159 1.168615 9.504465 | | 3 1 0 .0817735 -.2984224 -.3069953 -.4130647 .0550704 .0942461 .1805663 .0054927 | | 4 2 0 .1024564 -.4778116 -.5232843 -.6575516 .1662458 .2738265 .5185871 .0545994 | | 5 1 1 .152218 2.359985 2.496497 1.940331 .1063734 6.232499 4.213039 .7418891 | | 6 10 .7 .7353922 -.2537148 -.4654696 -.2503426 .7028956 .2166619 .2109408 .5125833 | | 7 5 .2 .2577896 -.2954191 -.4160336 -.3036099 .4957797 .1730839 .1828149 .1701865 | | 8 8 .125 .1817309 -.4161044 -.8012637 -.4359247 .7303169 .6420236 .7046434 1.738636 | | 9 11 .1818182 .2588893 -.5835651 -2.496497 -.6060105 .9453593 6.232499 6.721155 107.8308 | | 10 38 .8684211 .8439235 .4160969 1.080066 .4256602 .8515815 1.166543 1.220782 6.69328 | | 11 9 .4444444 .4032532 .2519084 .5182928 .2506801 .76377 .2686274 .2660142 .8685164 | +------------------------------------------------------------------------------------------------------------------+ . logit casecont i.cov, asis Iteration 0: Log likelihood = -74.859896 Iteration 1: Log likelihood = -48.962127 Iteration 2: Log likelihood = -48.557744 Iteration 3: Log likelihood = -48.489928 Iteration 4: Log likelihood = -48.475495 Iteration 5: Log likelihood = -48.472329 Iteration 6: Log likelihood = -48.471744 Iteration 7: Log likelihood = -48.471685 Iteration 8: Log likelihood = -48.471673 Iteration 9: Log likelihood = -48.47167 Logistic regression Number of obs = 108 LR chi2(10) = 52.78 Prob > chi2 = 0.0000 Log likelihood = -48.47167 Pseudo R2 = 0.3525 ------------------------------------------------------------------------------ casecont | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- cov | 2 | 1.838154 1.218094 1.51 0.131 -.5492668 4.225576 3 | -13.21623 2457.868 -0.01 0.996 -4830.549 4804.117 4 | -13.21623 1737.975 -0.01 0.994 -3419.585 3393.153 5 | 18.01197 2457.868 0.01 0.994 -4799.321 4835.345 6 | 3.245334 1.251842 2.59 0.010 .7917691 5.698899 7 | 1.011361 1.530048 0.66 0.509 -1.987478 4.0102 8 | .4518912 1.494591 0.30 0.762 -2.477453 3.381236 9 | .8935955 1.304636 0.68 0.493 -1.663443 3.450634 10 | 4.285027 1.149436 3.73 0.000 2.032173 6.537881 11 | 2.174692 1.241325 1.75 0.080 -.2582602 4.607645 | _cons | -2.39787 1.044455 -2.30 0.022 -4.444964 -.3507759 ------------------------------------------------------------------------------ . lrtest red Likelihood-ratio test Assumption: red nested within . LR chi2(5) = 6.32 Prob > chi2 = 0.2762 .