I am trying to understand how to test for the goodness of fit in GLM regression. I am using an example from the book Davison and Hinkley (1997). In R
, they fit the following model:
data(cane) # this dataset is available by default
cane.glm <- glm(y ~ block+var,family=binomial,data=cane)
summary(cane.glm)
Then they write that "for an adequate fit, the deviance would roughly be distributed according to a $\chi^2_{132}$ (where $132$ is the residual degrees of freedom of the regression); in fact, it is 1142.8; This indicates overdispersion relative to the model." They, however, miss to provide more details on how to proceed.
I think I need to compute the deviance deviance(cane.glm)
and use pachisq
function to test whether the observed value is far away from the theoretical distribution. I don't understand, however, the exact testing procedure. Any example in R
would be much appreciated.
In addition, this reference (p.8) suggest that this type of "goodness of fit" test "does not actually work very well." Why not? What else should I use?