----------------------------------------------------------------- name: log: C:\vhm812-data\l5a_log_reg_dx2017.txt log type: text opened on: 5 Feb 2018, 15:12:10 . . * open the Nocardia dataset . use nocardia.dta, clear . sum dcpct Variable | Obs Mean Std. Dev. Min > Max -------------+--------------------------------------------------- > ------ dcpct | 108 75.56481 37.3964 0 > 100 . tab dcpct Pcnt. of | cows dry | treated | Freq. Percent Cum. ------------+----------------------------------- 0 | 7 6.48 6.48 1 | 2 1.85 8.33 3 | 1 0.93 9.26 5 | 3 2.78 12.04 7 | 1 0.93 12.96 10 | 1 0.93 13.89 14 | 1 0.93 14.81 20 | 2 1.85 16.67 25 | 3 2.78 19.44 30 | 2 1.85 21.30 40 | 1 0.93 22.22 50 | 7 6.48 28.70 75 | 4 3.70 32.41 80 | 1 0.93 33.33 83 | 1 0.93 34.26 90 | 1 0.93 35.19 95 | 1 0.93 36.11 99 | 3 2.78 38.89 100 | 66 61.11 100.00 ------------+----------------------------------- Total | 108 100.00 . egen dcpct3=cut(dcpct), at(0,50,100,1000) . tab dcpct3 dcpct3 | Freq. Percent Cum. ------------+----------------------------------- 0 | 24 22.22 22.22 50 | 18 16.67 38.89 100 | 66 61.11 100.00 ------------+----------------------------------- Total | 108 100.00 . . * residuals one per covariate pattern . * fitting a logistic model . logit casecont dneo##dclox i.dcpct3 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 | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.19238 .8361783 3.82 0.000 1.553 > 5 > 4.831259 | dclox | yes | .4529145 1.026657 0.44 0.659 -1.55929 > 6 > 2.465125 | dneo#dclox | yes#yes | -2.532558 1.207714 -2.10 0.036 -4.89963 > 4 > -.1654829 | dcpct3 | 50 | 1.361002 .819178 1.66 0.097 -.244557 > 9 > 2.966561 100 | 2.026562 .6855237 2.96 0.003 .682960 > 4 > 3.370164 | _cons | -3.531226 .9364287 -3.77 0.000 -5.36659 > 3 > -1.69586 ----------------------------------------------------------------- > ------------- . . * examining the covariate patterns . predict cov, num . predict pv, p . sort cov . * generate a count of the number of obs. in each cov. pattern . quietly by cov: gen cnt=_N . br cov cnt dcpct dneo dclox pv casecont . . * examining Pearson residuals . predict pear, res /*one per covariate pattern*/ . format pv pear %5.3f . sort pear . summ pear Variable | Obs Mean Std. Dev. Min > Max -------------+--------------------------------------------------- > ------ pear | 108 .1413821 .5669692 -.5835651 2. > 359985 . list cov cnt dcpct dneo dclox pv casecont pear if abs(pear)>2, > noobs sep(4) +-------------------------------------------------------------+ | cov cnt dcpct dneo dclox pv casecont pear | |-------------------------------------------------------------| | 4 1 83 no yes 0.152 yes 2.360 | +-------------------------------------------------------------+ . . * Goodness-of-fit tests . * Pearson GOF . **stata post estimation command . estat gof Logistic model for casecont, goodness-of-fit test number of observations = 108 number of covariate patterns = 11 Pearson chi2(5) = 8.22 Prob > chi2 = 0.1444 . * Hosmer - Lemeshow Test . estat gof, g(10) table Logistic model for casecont, goodness-of-fit test (Table collapsed on quantiles of estimated probabilities) (There are only 7 distinct quantiles because of ties) +--------------------------------------------------------+ | Group | Prob | Obs_1 | Exp_1 | Obs_0 | Exp_0 | Total | |-------+--------+-------+-------+-------+-------+-------| | 1 | 0.0284 | 1 | 0.3 | 11 | 11.7 | 12 | | 2 | 0.1817 | 2 | 1.9 | 10 | 10.1 | 12 | | 3 | 0.2589 | 3 | 4.1 | 13 | 11.9 | 16 | | 4 | 0.4033 | 4 | 3.6 | 5 | 5.4 | 9 | | 5 | 0.4161 | 4 | 4.6 | 7 | 6.4 | 11 | |-------+--------+-------+-------+-------+-------+-------| | 6 | 0.7354 | 7 | 7.4 | 3 | 2.6 | 10 | | 10 | 0.8439 | 33 | 32.1 | 5 | 5.9 | 38 | +--------------------------------------------------------+ number of observations = 108 number of groups = 7 Hosmer-Lemeshow chi2(5) = 2.16 Prob > chi2 = 0.8262 . . * Evaluating Important Observations in a Logistic Model . * fitting a logistic model . logit casecont i.dneo##dclox i.dcpct3 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 | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.19238 .8361783 3.82 0.000 1.553 > 5 > 4.831259 | dclox | yes | .4529145 1.026657 0.44 0.659 -1.55929 > 6 > 2.465125 | dneo#dclox | yes#yes | -2.532558 1.207714 -2.10 0.036 -4.89963 > 4 > -.1654829 | dcpct3 | 50 | 1.361002 .819178 1.66 0.097 -.244557 > 9 > 2.966561 100 | 2.026562 .6855237 2.96 0.003 .682960 > 4 > 3.370164 | _cons | -3.531226 .9364287 -3.77 0.000 -5.36659 > 3 > -1.69586 ----------------------------------------------------------------- > ------------- . * predicting residuals and influential statistics . capture drop cov . capture drop pv . capture drop cnt . capture drop lev . capture drop pear_std . capture drop dx2 . capture drop db . predict pv, p . predict pear_std, rstandard . predict lev, hat . predict dx2, dx2 . predict db, dbeta . predict cov, num . . **additional variables for listings and formatting . bysort cov: gen cnt=_N . bysort cov:gen wcov=_n . bysort cov: egen opr=mean(casecont) . *format all the listed variables to 3 decimals . foreach var in opr pv pear_std lev dx2 db { 2. format `var' %4.3f 3. } . . * Identifying highest leverage points . summ lev, d leverage ------------------------------------------------------------- Percentiles Smallest 1% .1063734 .0550704 5% .2907239 .1063734 10% .2907239 .1662458 Obs 108 25% .7028956 .1662458 Sum of Wgt. 108 50% .8515815 Mean .729414 Largest Std. Dev. .2256387 75% .8515815 .9453593 90% .9453593 .9453593 Variance .0509128 95% .9453593 .9453593 Skewness -1.434562 99% .9453593 .9453593 Kurtosis 3.850434 . * graph of stand. resid. vs leverage . scatter lev pv, mlabel(cov) xline(0.1 0.9) xlabel(0(0.1)1) . scatter pear_std lev , mlabel(cov) yline(-2 2) . sort lev pv . list cov cnt dcpct3 dneo dclox opr pv pear_std lev if pv>0.1 & > pv<0.9 & wcov==1, noobs +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 4 | 1 | 50 | no | yes | 1.000 | 0.152 | |---------------------------------------------------| | pear_std | lev | | 2.496 | 0.106 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 2 | 2 | 50 | no | no | 0.000 | 0.102 | |---------------------------------------------------| | pear_std | lev | | -0.523 | 0.166 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 10 | 5 | 50 | yes | yes | 0.200 | 0.258 | |---------------------------------------------------| | pear_std | lev | | -0.416 | 0.496 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 7 | 10 | 50 | yes | no | 0.700 | 0.735 | |---------------------------------------------------| | pear_std | lev | | -0.465 | 0.703 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 3 | 8 | 100 | no | no | 0.125 | 0.182 | |---------------------------------------------------| | pear_std | lev | | -0.801 | 0.730 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 11 | 9 | 100 | yes | yes | 0.444 | 0.403 | |---------------------------------------------------| | pear_std | lev | | 0.518 | 0.764 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 8 | 38 | 100 | yes | no | 0.868 | 0.844 | |---------------------------------------------------| | pear_std | lev | | 1.080 | 0.852 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 6 | 11 | 0 | yes | no | 0.364 | 0.416 | |---------------------------------------------------| | pear_std | lev | | -1.073 | 0.892 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 5 | 11 | 100 | no | yes | 0.182 | 0.259 | |---------------------------------------------------| | pear_std | lev | | -2.496 | 0.945 | +---------------------------------------------------+ . . * residual . sort pear_std . twoway (scatter pear_std cov [aweight=cnt], msymbol(Oh) mlcolor > (black) mlwidth(medium)) /// > (scatter pear_std cov, msize(vtiny) mlabel(cov) > ), legend(off) yline( -2 2) . list cov cnt dcpct3 dneo dclox opr pv pear_std if wcov==1 & abs > (pear_std)>2 ,noobs +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 5 | 11 | 100 | no | yes | 0.182 | 0.259 | |---------------------------------------------------| | pear_std | | -2.496 | +---------------------------------------------------+ +---------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | opr | pv | | 4 | 1 | 50 | no | yes | 1.000 | 0.152 | |---------------------------------------------------| | pear_std | | 2.496 | +---------------------------------------------------+ . . * evaluating delta chisq . scatter dx2 pv, mlabel(cov) yline(3.84) /*delta chi2*/ . sort dx2 . list cov cnt dcpct3 dneo dclox pv dx2 lev pear if dx2>3.84 & wc > ov==1, noobs +-----------------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | pv | dx2 | lev | | 4 | 1 | 50 | no | yes | 0.152 | 6.232 | 0.106 | |-----------------------------------------------------------| | pear | | 2.360 | +-----------------------------------------------------------+ +-----------------------------------------------------------+ | cov | cnt | dcpct3 | dneo | dclox | pv | dx2 | lev | | 5 | 11 | 100 | no | yes | 0.259 | 6.232 | 0.945 | |-----------------------------------------------------------| | pear | | -0.584 | +-----------------------------------------------------------+ . . * evaluating delta betas . sort db . summ db, d Pregibon's dbeta ------------------------------------------------------------- Percentiles Smallest 1% .0545994 .0054927 5% .1701865 .0545994 10% .5125833 .0545994 Obs 108 25% .7564373 .1701865 Sum of Wgt. 108 50% 6.69328 Mean 14.65434 Largest Std. Dev. 31.68869 75% 6.69328 107.8308 90% 107.8308 107.8308 Variance 1004.173 95% 107.8308 107.8308 Skewness 2.581599 99% 107.8308 107.8308 Kurtosis 7.77457 . scatter db pv, ml(cov) yline(1) . scatter db lev, ml(cov) yline(1) . scatter dx2 pv [aweight=db], msymbol(Oh) || scatter dx2 pv, ml > (cov) yline(3.84) legend(off) /// > ytitle("Delta Chi2") . sort db . l cov cnt dcpct dneo dclox opr pv lev dx2 db if db > abs(1) & w > cov==1, noobs +----------------------------------------------------------+ | cov | cnt | dcpct | dneo | dclox | opr | pv | lev | | 3 | 8 | 100 | no | no | 0.125 | 0.182 | 0.730 | |----------------------------------------------------------| | dx2 | db | | 0.642 | 1.739 | +----------------------------------------------------------+ +----------------------------------------------------------+ | cov | cnt | dcpct | dneo | dclox | opr | pv | lev | | 8 | 38 | 100 | yes | no | 0.868 | 0.844 | 0.852 | |----------------------------------------------------------| | dx2 | db | | 1.167 | 6.693 | +----------------------------------------------------------+ +----------------------------------------------------------+ | cov | cnt | dcpct | dneo | dclox | opr | pv | lev | | 6 | 11 | 30 | yes | no | 0.364 | 0.416 | 0.892 | |----------------------------------------------------------| | dx2 | db | | 1.152 | 9.504 | +----------------------------------------------------------+ +----------------------------------------------------------+ | cov | cnt | dcpct | dneo | dclox | opr | pv | lev | | 5 | 11 | 100 | no | yes | 0.182 | 0.259 | 0.945 | |----------------------------------------------------------| | dx2 | db | | 6.232 | 107.831 | +----------------------------------------------------------+ . br cov cnt dcpct dneo dclox opr pv lev dx2 db . . * dropping the highest db covariate pattern and refitting the m > odel . logit casecont dneo##dclox i.dcpct3 if cov~=5, asis Iteration 0: log likelihood = -66.98248 Iteration 1: log likelihood = -44.531702 Iteration 2: log likelihood = -44.212331 Iteration 3: log likelihood = -44.194711 Iteration 4: log likelihood = -44.190532 Iteration 5: log likelihood = -44.189712 Iteration 6: log likelihood = -44.189579 Iteration 7: log likelihood = -44.189547 Iteration 8: log likelihood = -44.18954 Iteration 9: log likelihood = -44.189538 Logistic regression Number of obs > = 97 LR chi2(5) > = 45.59 Prob > chi2 > = 0.0000 Log likelihood = -44.189538 Pseudo R2 > = 0.3403 ----------------------------------------------------------------- > ------------- casecont | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.24781 .8455337 3.84 0.000 1.59059 > 4 > 4.905025 | dclox | yes | 17.32151 1658.542 0.01 0.992 -3233.3 > 6 > 3268.003 | dneo#dclox | yes#yes | -19.40303 1658.542 -0.01 0.991 -3270.08 > 5 > 3231.279 | dcpct3 | 50 | 1.086567 .8180393 1.33 0.184 -.516760 > 7 > 2.689894 100 | 2.132465 .6950524 3.07 0.002 .770187 > 6 > 3.494743 | _cons | -3.580685 .9466216 -3.78 0.000 -5.43602 > 9 > -1.725341 ----------------------------------------------------------------- > ------------- . * no interaction cov 5 only cov with dneo=no and dclox=yes with > cases and controls . * the other cov with this patterns is 4 but only has one case. . table casecont dneo dclox ------------------------------------ | Cloxacillin used on farm |and Neomycin used on farm Case - | --- no --- --- yes -- Control | no yes no yes ----------+------------------------- no | 20 15 9 10 yes | 2 44 3 5 ------------------------------------ . table casecont dneo dclox if cov~=5 ------------------------------------ | Cloxacillin used on farm |and Neomycin used on farm Case - | --- no --- --- yes -- Control | no yes no yes ----------+------------------------- no | 20 15 10 yes | 2 44 1 5 ------------------------------------ . . * refitting and comparing the models . logit casecont dneo##dclox i.dcpct3 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 | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.19238 .8361783 3.82 0.000 1.553 > 5 > 4.831259 | dclox | yes | .4529145 1.026657 0.44 0.659 -1.55929 > 6 > 2.465125 | dneo#dclox | yes#yes | -2.532558 1.207714 -2.10 0.036 -4.89963 > 4 > -.1654829 | dcpct3 | 50 | 1.361002 .819178 1.66 0.097 -.244557 > 9 > 2.966561 100 | 2.026562 .6855237 2.96 0.003 .682960 > 4 > 3.370164 | _cons | -3.531226 .9364287 -3.77 0.000 -5.36659 > 3 > -1.69586 ----------------------------------------------------------------- > ------------- . estimate store final . * without cov pattern 5 . logit casecont dneo##dclox i.dcpct3 if cov~=5, asis Iteration 0: log likelihood = -66.98248 Iteration 1: log likelihood = -44.531702 Iteration 2: log likelihood = -44.212331 Iteration 3: log likelihood = -44.194711 Iteration 4: log likelihood = -44.190532 Iteration 5: log likelihood = -44.189712 Iteration 6: log likelihood = -44.189579 Iteration 7: log likelihood = -44.189547 Iteration 8: log likelihood = -44.18954 Iteration 9: log likelihood = -44.189538 Logistic regression Number of obs > = 97 LR chi2(5) > = 45.59 Prob > chi2 > = 0.0000 Log likelihood = -44.189538 Pseudo R2 > = 0.3403 ----------------------------------------------------------------- > ------------- casecont | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.24781 .8455337 3.84 0.000 1.59059 > 4 > 4.905025 | dclox | yes | 17.32151 1658.542 0.01 0.992 -3233.3 > 6 > 3268.003 | dneo#dclox | yes#yes | -19.40303 1658.542 -0.01 0.991 -3270.08 > 5 > 3231.279 | dcpct3 | 50 | 1.086567 .8180393 1.33 0.184 -.516760 > 7 > 2.689894 100 | 2.132465 .6950524 3.07 0.002 .770187 > 6 > 3.494743 | _cons | -3.580685 .9466216 -3.78 0.000 -5.43602 > 9 > -1.725341 ----------------------------------------------------------------- > ------------- . estimates store wocov5 . * without cov pattern 6 . logit casecont dneo##dclox i.dcpct3 if cov~=6 Iteration 0: log likelihood = -67.188877 Iteration 1: log likelihood = -44.268414 Iteration 2: log likelihood = -43.951293 Iteration 3: log likelihood = -43.949794 Iteration 4: log likelihood = -43.949794 Logistic regression Number of obs > = 97 LR chi2(5) > = 46.48 Prob > chi2 > = 0.0000 Log likelihood = -43.949794 Pseudo R2 > = 0.3459 ----------------------------------------------------------------- > ------------- casecont | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.639127 .99651 3.65 0.000 1.68600 > 3 > 5.592251 | dclox | yes | .8080203 1.132313 0.71 0.475 -1.41127 > 2 > 3.027313 | dneo#dclox | yes#yes | -3.018298 1.34906 -2.24 0.025 -5.66240 > 8 > -.3741881 | dcpct3 | 50 | .1199465 1.407715 0.09 0.932 -2.63912 > 4 > 2.879017 100 | .8134231 1.299859 0.63 0.531 -1.73425 > 5 > 3.361101 | _cons | -2.671599 1.073272 -2.49 0.013 -4.77517 > 4 > -.5680239 ----------------------------------------------------------------- > ------------- . estimates store wocov6 . * without cov pattern 8 . logit casecont dneo##dclox i.dcpct3 if cov~=8 Iteration 0: log likelihood = -42.760501 Iteration 1: log likelihood = -36.670668 Iteration 2: log likelihood = -36.284326 Iteration 3: log likelihood = -36.280224 Iteration 4: log likelihood = -36.280224 Logistic regression Number of obs > = 70 LR chi2(5) > = 12.96 Prob > chi2 > = 0.0238 Log likelihood = -36.280224 Pseudo R2 > = 0.1515 ----------------------------------------------------------------- > ------------- casecont | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 2.518415 .9964233 2.53 0.011 .565461 > 1 > 4.471369 | dclox | yes | .7045019 1.065468 0.66 0.508 -1.38377 > 6 > 2.79278 | dneo#dclox | yes#yes | -2.05333 1.255048 -1.64 0.102 -4.5131 > 8 > .4065195 | dcpct3 | 50 | 1.173495 .7931855 1.48 0.139 -.381119 > 5 > 2.72811 100 | 1.168346 1.025769 1.14 0.255 -.84212 > 5 > 3.178817 | _cons | -2.97189 .9807858 -3.03 0.002 -4.89419 > 4 > -1.049585 ----------------------------------------------------------------- > ------------- . estimates store wocov8 . estimates table final wocov5 wocov6 wocov8 , b(%5.3f) stats(N) > star( .05 .01 .001) ----------------------------------------------------- Variable | final wocov5 wocov6 -------------+--------------------------------------- dneo | yes | 3.192*** 3.248*** 3.639*** | dclox | yes | 0.453 17.322 0.808 | dneo#dclox | yes#yes | -2.533* -19.403 -3.018* | dcpct3 | 50 | 1.361 1.087 0.120 100 | 2.027** 2.132** 0.813 | _cons | -3.531*** -3.581*** -2.672* -------------+--------------------------------------- N | 108 97 97 ----------------------------------------------------- legend: * p<.05; ** p<.01; *** p<.001 --------------------------- Variable | wocov8 -------------+------------- | dneo | yes | 2.518* | dclox | yes | 0.705 | dneo#dclox | yes#yes | -2.053 | dcpct3 | 50 | 1.173 100 | 1.168 | _cons | -2.972** -------------+------------- N | 70 --------------------------- legend: * p<.05; ** p<.01; *** p<.001 . . *Predictive ability of the model . * sensitivity and specificty of logistic model . logit casecont dneo##dclox i.dcpct3 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 | Coef. Std. Err. z P>|z| [95% Co > n > f. Interval] -------------+--------------------------------------------------- > ------------- dneo | yes | 3.19238 .8361783 3.82 0.000 1.553 > 5 > 4.831259 | dclox | yes | .4529145 1.026657 0.44 0.659 -1.55929 > 6 > 2.465125 | dneo#dclox | yes#yes | -2.532558 1.207714 -2.10 0.036 -4.89963 > 4 > -.1654829 | dcpct3 | 50 | 1.361002 .819178 1.66 0.097 -.244557 > 9 > 2.966561 100 | 2.026562 .6855237 2.96 0.003 .682960 > 4 > 3.370164 | _cons | -3.531226 .9364287 -3.77 0.000 -5.36659 > 3 > -1.69586 ----------------------------------------------------------------- > ------------- . estat class Logistic model for casecont -------- True -------- Classified | D ~D | Total -----------+--------------------------+----------- + | 40 8 | 48 - | 14 46 | 60 -----------+--------------------------+----------- Total | 54 54 | 108 Classified + if predicted Pr(D) >= .5 True D defined as casecont != 0 -------------------------------------------------- Sensitivity Pr( +| D) 74.07% Specificity Pr( -|~D) 85.19% Positive predictive value Pr( D| +) 83.33% Negative predictive value Pr(~D| -) 76.67% -------------------------------------------------- False + rate for true ~D Pr( +|~D) 14.81% False - rate for true D Pr( -| D) 25.93% False + rate for classified + Pr(~D| +) 16.67% False - rate for classified - Pr( D| -) 23.33% -------------------------------------------------- Correctly classified 79.63% -------------------------------------------------- . * two graph ROC . lsens, lpattern(solid dash) . * changing the cutpoint and producing an ROC curve and LR tabl > e . egen pv_cat=cut(pv), at(0(.05)1) . roctab casecont pv_cat, graph sum detail Detailed report of sensitivity and specificity ----------------------------------------------------------------- > ------------- Correctly Cutpoint Sensitivity Specificity Classified LR+ > LR- ----------------------------------------------------------------- > ------------- ( >= 0 ) 100.00% 0.00% 50.00% 1.0000 > ( >= .05 ) 98.15% 20.37% 59.26% 1.2326 > 0.0909 ( >= .1 ) 98.15% 22.22% 60.19% 1.2619 > 0.0833 ( >= .15 ) 98.15% 25.93% 62.04% 1.3250 > 0.0714 ( >= .25 ) 94.44% 38.89% 66.67% 1.5455 > 0.1429 ( >= .4 ) 88.89% 62.96% 75.93% 2.4000 > 0.1765 ( >= .7 ) 74.07% 85.19% 79.63% 5.0000 > 0.3043 ( >= .8 ) 61.11% 90.74% 75.93% 6.6000 > 0.4286 ( > .8 ) 0.00% 100.00% 50.00% > 1.0000 ----------------------------------------------------------------- > ------------- ROC -Asymptotic Normal-- Obs Area Std. Err. [95% Conf. Interval] ------------------------------------------------------------ 108 0.8488 0.0370 0.77621 0.92132 . estat class, cut(0.25) // no in the notes - change cutpoint to > 0.25 Logistic model for casecont -------- True -------- Classified | D ~D | Total -----------+--------------------------+----------- + | 51 33 | 84 - | 3 21 | 24 -----------+--------------------------+----------- Total | 54 54 | 108 Classified + if predicted Pr(D) >= .25 True D defined as casecont != 0 -------------------------------------------------- Sensitivity Pr( +| D) 94.44% Specificity Pr( -|~D) 38.89% Positive predictive value Pr( D| +) 60.71% Negative predictive value Pr(~D| -) 87.50% -------------------------------------------------- False + rate for true ~D Pr( +|~D) 61.11% False - rate for true D Pr( -| D) 5.56% False + rate for classified + Pr(~D| +) 39.29% False - rate for classified - Pr( D| -) 12.50% -------------------------------------------------- Correctly classified 66.67% -------------------------------------------------- . // increase Se and de > crease Sp . *ROC plot and AUC after command . lroc Logistic model for casecont number of observations = 108 area under ROC curve = 0.8460 . end of do-file . log close name: log: C:\vhm812-data\l5a_log_reg_dx2017.txt log type: text closed on: 5 Feb 2018, 15:12:29 -----------------------------------------------------------------