Lecture 3-Logistic Reg Model-II
Lecture 3-Logistic Reg Model-II
data(wcgs)
str(wcgs)
No 91.9%
Yes 8.1%
Call:
glm(formula = chd ~ height + cigs, family = binomial, data = wcgs)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.0041 -0.4425 -0.3630 -0.3499 2.4357
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -4.50161 1.84186 -2.444 0.0145 *
height 0.02521 0.02633 0.957 0.3383
cigs 0.02313 0.00404 5.724 1.04e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> drop1(lmod,test="Chi")
Single term deletions
Model:
chd ~ height + cigs
Df Deviance AIC LRT Pr(>Chi)
<none> 1749.0 1755.0
height 1 1750.0 1754.0 0.9202 0.3374
cigs 1 1780.1 1784.1 31.0695 2.49e-08 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
0.4
0.2
0.0
60 65 70 75
Height
1.0
Question: how to interpret this plot?
0.8
0.6
Heart Disease
0.4
0.2
0.0
0 20 40 60 80 100
Cigarette Use
Logistic regression model II - Dr. Dungang Liu 12
Variable (Model) Selection
summary(lmod.full)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -20.940481 16.069445 -1.303 0.19253
age 0.061621 0.012397 4.970 6.68e-07 ***
height 0.121465 0.228779 0.531 0.59547
weight -0.014153 0.045136 -0.314 0.75385
bmi 0.159691 0.315675 0.506 0.61295
sdp 0.018227 0.006415 2.841 0.00449 **
dbp -0.001139 0.010884 -0.105 0.91662
chol 0.010736 0.001532 7.007 2.44e-12 ***
dibepB 0.658080 0.145958 4.509 6.52e-06 ***
cigs 0.020985 0.004292 4.890 1.01e-06 ***
arcuspresent 0.209634 0.143874 1.457 0.14510
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> round(cor(sdp,dbp),1)
[1] 0.8
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.926461 0.497037 -11.924 < 2e-16 ***
sdp 0.026671 0.003671 7.265 3.73e-13 ***
---
AIC: 1736.4
> summary(glm(chd~dbp,family=binomial))
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -5.221713 0.511646 -10.206 < 2e-16 ***
dbp 0.033560 0.005981 5.611 2.01e-08 ***
---
AIC: 1755.7
summary(lmod.full2)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -15.677176 2.269985 -6.906 4.97e-12 ***
age 0.064941 0.012302 5.279 1.30e-07 ***
height 0.049734 0.027660 1.798 0.07217 .
bmi 0.062367 0.027357 2.280 0.02262 *
dbp 0.022086 0.007095 3.113 0.00185 **
chol 0.010760 0.001518 7.088 1.36e-12 ***
dibepB 0.662243 0.145689 4.546 5.48e-06 ***
cigs 0.022206 0.004255 5.219 1.80e-07 ***
arcuspresent 0.209776 0.143572 1.461 0.14398
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Model:
chd ~ age + height + bmi + dbp + chol + dibep + cigs + arcus
Df Deviance AIC LRT Pr(>Chi)
<none> 1577.2 1595.2
age 1 1605.0 1621.0 27.814 1.336e-07 ***
height 1 1580.5 1596.5 3.259 0.071013 .
bmi 1 1582.3 1598.3 5.130 0.023516 *
dbp 1 1586.6 1602.6 9.416 0.002151 **
chol 1 1628.7 1644.7 51.533 7.041e-13 ***
dibep 1 1598.9 1614.9 21.696 3.194e-06 ***
cigs 1 1603.4 1619.4 26.222 3.044e-07 ***
arcus 1 1579.3 1595.3 2.110 0.146365
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Call:
glm(formula = chd ~ age + height + bmi + dbp + chol + dibep +
cigs, family = binomial, data = wcgs)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -16.070539 2.259732 -7.112 1.15e-12 ***
age 0.067982 0.012016 5.658 1.53e-08 ***
height 0.054814 0.027516 1.992 0.04636 *
bmi 0.057231 0.027295 2.097 0.03601 *
dbp 0.022378 0.007034 3.181 0.00147 **
chol 0.011107 0.001510 7.357 1.87e-13 ***
dibepB 0.658159 0.144974 4.540 5.63e-06 ***
cigs 0.022112 0.004239 5.216 1.83e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Please try:
model.AIC<-step(lmod.0,trace=0)
summary(model.AIC)
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -16.070539 2.259732 -7.112 1.15e-12 ***
age 0.067982 0.012016 5.658 1.53e-08 ***
height 0.054814 0.027516 1.992 0.04636 *
bmi 0.057231 0.027295 2.097 0.03601 *
dbp 0.022378 0.007034 3.181 0.00147 **
chol 0.011107 0.001510 7.357 1.87e-13 ***
dibepB 0.658159 0.144974 4.540 5.63e-06 ***
cigs 0.022112 0.004239 5.216 1.83e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -15.957599 2.286076 -6.980 2.94e-12 ***
age 0.061590 0.012397 4.968 6.76e-07 ***
height 0.050161 0.027824 1.803 0.0714 .
bmi 0.060385 0.026599 2.270 0.0232 *
sdp 0.017728 0.004155 4.267 1.98e-05 ***
chol 0.010709 0.001529 7.006 2.45e-12 ***
dibepB 0.657616 0.145898 4.507 6.56e-06 ***
cigs 0.021041 0.004262 4.936 7.96e-07 ***
arcuspresent 0.210998 0.143718 1.468 0.1421
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Specificity: 2880/(2880+5)=99.8%
Sensitivity: 2/(2+253)=0.8%
par(mfrow=c(1,2))
matplot(thresh,cbind(sensitivity,specificity),type="l",xlab="Thr
eshold",ylab="Proportion",lty=1:2)
plot(1-specificity,sensitivity,type="l");abline(0,1,lty=2)
Logistic regression model II - Dr. Dungang Liu 32
1.0
1.0
0.8
0.8
0.6
0.6
Proportion
sensitivity
0.4
0.4
0.2
0.2
0.0
0.0
0.0 0.1 0.2 0.3 0.4 0.5 0.0 0.2 0.4 0.6 0.8 1.0
Threshold 1 - specificity
$se.fit
[1] 0.1156408
> predict(lmod.0,newdata=new.ind,type="response",se=T)
$fit
1
0.09182058
$se.fit
1
0.009643238