Alternative Goodness-of-fit Measure (Reading: Faraway (2006), section 2.9)
We now use the Bliss insect data studied in the previous lab, to demonstrate how to calculate the Perason's X2 statistic:
> bliss <- read.table("bliss.txt")
> modl <- glm(cbind(dead,alive) ~ conc, family=binomial, data=bliss)
The Perason's X2 statistic is typically close in size to the deviance:
As can be seen, there is little difference here between the X2 and the deviance.
For the Bliss insect data, the generalized R2 can be calculated by:
the generalized R2 is very close to 1, which indicates this is a very good fit.
in the calculation of the generalized R2, we have use K=150 as there are 5 covariate classes (i.e., k=5) each with 30 Bernoulli observations (i.e., ni=30 for i=1,...,k).