Professional Documents
Culture Documents
HW 6.8,6.12
HW 6.8,6.12
> data<-read.csv(file="sorethroat.csv")
>
> data$T.fac<-factor(data$T,levels=c("0","1"))
> data$Y.fac<-factor(data$Y,levels=c("0","1"))
>
> model<-glm(data$Y.fac~data$T.fac+data$D,family="binomial")
> summary(model,cor=T)
Call:
Deviance Residuals:
Coefficients:
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
AIC: 36.138
Number of Fisher Scoring iterations: 5
Correlation of Coefficients:
(Intercept) data$T.fac1
data$T.fac1 -0.25
>
[1] 16.04187
>
+ trace=T,scale=1,direction="both")
Start: AIC=36.14
Df Deviance AIC
Coefficients:
>
>
> # 6.12
> yes<-c(512,89,353,17,120,202,138,131,53,94,22,24)
> no<-c(313,19,207,8,205,391,279,244,138,299,351,317)
> table.6.7<-cbind(expand.grid(gender=c("male","female"),
+ dept=c("A","B","C","D","E","F")),
+ prop=yes/(yes+no))
> table.6.7
1 male A 0.62060606
2 female A 0.82407407
3 male B 0.63035714
4 female B 0.68000000
5 male C 0.36923077
6 female C 0.34064081
7 male D 0.33093525
8 female D 0.34933333
9 male E 0.27748691
10 female E 0.23918575
11 male F 0.05898123
12 female F 0.07038123
> summary(res.gradadmit)
Call:
Coefficients:
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
AIC: 102.68
> res.gradadmit$deviance
[1] 21.73551
[1] 19.93841
11 12
-0.6197526 0.6197526