- #1

Deimantas

- 41

- 0

## Homework Statement

Hello, I've stumbled upon an interesting analysis of GLM's in R (http://www.magesblog.com/2015/08/generalised-linear-models-in-r.html).

However it's only a graphical analysis so I wanted to make sure the models are fitting by using an actual statistics test. The test, however, shows that the models do not fit at all - despite the models looking good when plotted in graphs.

icecream <- data.frame(

temp=c(11.9, 14.2, 15.2, 16.4, 17.2, 18.1,

18.5, 19.4, 22.1, 22.6, 23.4, 25.1),

units=c(185L, 215L, 332L, 325L, 408L, 421L,

406L, 412L, 522L, 445L, 544L, 614L)

)

pois.mod <- glm(units ~ temp, data=icecream,

family=poisson(link="log"))

bin.glm <- glm(cbind(units, opportunity) ~ temp, data=icecream,

family=binomial(link = "logit"))

## Homework Equations

## The Attempt at a Solution

R commands and results:

1-pchisq(summary(pois.mod)$deviance, summary(pois.mod)$df.residual)

[1] 3.59619e-09

1-pchisq(summary(bin.glm)$deviance, summary(bin.glm)$df.residual)

[1] 6.850076e-14

Since both results are <0.05, it would seem that both the Poisson and binomial models do not fit at all? Am I doing something wrong? The models look good when plotted.