I'm hoping someone can explain this bit of R code for me related to glm()
. I don't understand the diagnostic plot that has been suggested. It seems a more informative plot would be to plot against the fitted values, but maybe I don't understand something.
Here's the code:
result <- glm(survive~age, data=donner, family=binomial)
# Why is this plotted against the respondent index?
plot(residuals(result,type="pearson"), main="pearson residual plot")
Data to reproduce the above example:
> dput(donner)
structure(list(age = c(23L, 40L, 40L, 30L, 28L, 40L, 45L, 62L,
65L, 45L, 25L, 28L, 28L, 23L, 22L, 23L, 28L, 15L, 47L, 57L, 20L,
18L, 25L, 60L, 25L, 20L, 32L, 32L, 24L, 30L, 15L, 50L, 21L, 25L,
46L, 32L, 30L, 25L, 25L, 25L, 30L, 35L, 23L, 24L, 25L), sex = c(1L,
0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L,
0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L, 1L, 0L, 0L,
1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L), survive = c(0L,
1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 1L,
1L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 1L,
0L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L)), .Names = c("age",
"sex", "survive"), class = "data.frame", row.names = c(NA, -45L
))