I have a 3x3 contingency table, and I tried fitting Poisson GLM in R and calculated the Pearson residuals from it then I cross checked the value by calculating the same manually.
Here the fitted value from the model is the same as the expected value which we get from marginals, but Pearson residual differs.
data<-c(0,1,2,2,0,8,8,13,16) out<-gl(3,1,9) treat<-gl(3,3) model<-glm(data~out+treat,family=poisson()) model$fitted.values  0.6 0.84 1.56 2 2.8 5.2 7.4 10.36 19.24 resid(model,type="pearson")
The result of Pearson residual from the above code is different from the results obtained when using the formula
(O-E)^2/E from the table.
Why is the difference occurs when the fitted value is same as expected value?
Please clarify my doubt.. Is fitted value is same as expected value?
Thanks in Advance