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)

> sum(residuals(modl,type="pearson")^2)

[1] 0.3672674

The Perason's X2 statistic is typically close in size to the deviance:

> deviance(modl)

[1] 0.3787483

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:

> (1-exp((modl$dev-modl$null)/150))/(1-exp(-modl$null/150))

[1] 0.9953178

Notice that