How to validate & diagnose a gamma GLM in R? I am fitting a generalized linear model in R with the log link and I need to validate and diagnose my model. I have never worked with the GLM in the past. 


*

*Is there an article or any references I can look for that would help me learn how to diagnose the model?  

*Does anyone have any tips for me on how to do this or even just how to get started?

*What is the difference between the deviance and $r^2$?  

*Can we calculate the SS error in the GLM?  


(The best way for me to understand is to give formulas and explain what they are used for.)
 A: -Look at Chapter 6 or Section 6.3.4 in the book "Statistical Models in S" by Chambers and Hastie.  Also you many want to check the package boot and function "glm.diag.plots" (Diagnostics plots for generalized linear models). Here are some code with gamma family and the plots from the help file.
library(boot)
data(leuk, package = "MASS")
leuk.mod <- glm(time ~ ag-1+log10(wbc), family = Gamma(log), data = leuk)
leuk.diag <- glm.diag(leuk.mod)
glm.diag.plots(leuk.mod, leuk.diag)


 These plots are (upper left: residual vs linear predictor, upper right: normal scores plots of standardized deviance residuals, Lower left: approximate Cook statistics against leverage, Lower right: the plot of Cook statistic)
- See Introduction to Generalized Linear Models
- Have a look at the above reference, pages 42 and 44 to see the difference of deviance and $r^2$.
- The following code shows how to find SSE (but normally you don't need it!)
#Create a data set
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
#Fitting poisson GLM
glm.D93 <- glm(counts ~ outcome + treatment, family=poisson())
summary(glm.D93)
# In the following, resid(glm.D93) extracts residuals of the fitted model glm.D93 
SSE=sum(resid(glm.D93))^2
SSE
[1] 0.04638682

