options(contrasts=c("contr.treatment", "contr.poly")) acc.glm <- glm(nacc ~ road + time + log(volume), data=accident, family=poisson) summary(acc.glm) anova(acc.glm, test="Chisq") hod.glm <- glm(y~h+r, data=hodgkins, family=poisson) summary(hod.glm) anova(hod.glm, test="Chisq") u <- resid(hod.glm, type="pearson") # The Pearson residuals are saved in u v <- resid(hod.glm, type="deviance") # The deviance residuals are saved in v sum(u^2) # The result is the Pearson X^2 statistic sum(v^2) # The result is the scaled deviance