donner <- read.delim("../../data/donner.txt")
Female <- 1*(donner$Sex=="Female")
fit <- glm(Status~Age*Sex,donner,family="binomial")
fit2 <- glm(Status~Age*Female,donner,family="binomial")
df <- data.frame(donner,Leverage=hatvalues(fit),Cook=cooks.distance(fit),db1=dfbeta(fit)[,"Age"],db2=dfbeta(fit2)[,"Age"],pi=fit$fitted.values,d=rstudent(fit))
xyplot(Leverage~Age|Sex,df,type="h",lwd=2,ylim=c(-0.02,max(df$Leverage)+.02))
xyplot(Cook~Age|Sex,df,type="h",lwd=2,group=Status,auto.key=list(columns=2,points=FALSE,lines=TRUE),ylab="Cook's distance")
xyplot(db1~Age,df,subset=(Sex=="Female"),main="Female",type="h",lwd=2,group=Status,auto.key=list(columns=2,points=FALSE,lines=TRUE),ylab=expression(Delta[beta]))
xyplot(db2~Age,df,subset=(Sex=="Male"),main="Male",type="h",lwd=2,group=Status,auto.key=list(columns=2,points=FALSE,lines=TRUE),ylab=expression(Delta[beta]),ylim=range(df$db1))
plot(fit$fitted.values,rstudent(fit),pch=19,cex=2*infl$hat/max(infl$hat),xlab=expression(pi),ylab=expression(d*"(Studentized deleted)"),col=col)
plot(fit$fitted.values,rstudent(fit)^2,pch=19,cex=2*infl$hat/max(infl$hat),xlab=expression(pi),ylab=expression(d^2*"(Studentized deleted)"),col=col)
