#MARR 8.6
data(turtle, package="faraway")
t<-turtle
T.t<-t$male + t$female
Temp<-t$temp
P.male<-t$male/T.t
dat = data.frame(Temp,T.t, P.male)
log = glm(P.male ~ Temp, family =binomial, weights = T.t, data= dat)
summary(log)
## 
## Call:
## glm(formula = P.male ~ Temp, family = binomial, data = dat, weights = T.t)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0721  -1.0292  -0.2714   0.8087   2.5550  
## 
## Coefficients:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept) -61.3183    12.0224  -5.100 3.39e-07 ***
## Temp          2.2110     0.4309   5.132 2.87e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 74.508  on 14  degrees of freedom
## Residual deviance: 24.942  on 13  degrees of freedom
## AIC: 53.836
## 
## Number of Fisher Scoring iterations: 5
plot(P.male ~ Temp, pch=16)
curve(predict(log, data.frame(Temp=x), type="resp"), add=T)
points(t$temp, fitted(log), pch=20)