I have been trying to sharpen my GLMM knowledge by working through some problems in Foundations of Linear and Generalized Linear Models. I am stuck on problem 9.36 which gives some homicide data then states "fit a Poisson GLMM. Interpret estimates. Show that the deviance decreases by 116.6 compared with the Poisson GLM, and intercept"
This is what I did
library(lme4) homi <- read.table("http://www.stat.ufl.edu/~aa/glm/data/Homicides.dat", header = TRUE) fit1 <- glm(count~race, family=poisson(link = log),data=homi) fit2 <- glmer(count~1+(1|race), family=poisson(link = log),data=homi) summary(fit1) summary(fit2)
For fit1
Call: glm(formula = count ~ race, family = poisson(link = log), data = homi) Deviance Residuals: Min 1Q Median 3Q Max -1.0218 -0.4295 -0.4295 -0.4295 6.1874 Coefficients: Estimate Std. Error z value Pr(>|z|) (Intercept) -2.38321 0.09713 -24.54 <2e-16 *** race 1.73314 0.14657 11.82 <2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 (Dispersion parameter for poisson family taken to be 1) Null deviance: 962.80 on 1307 degrees of freedom Residual deviance: 844.71 on 1306 degrees of freedom AIC: 1122 Number of Fisher Scoring iterations: 6
and for fit2
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: poisson ( log ) Formula: count ~ 1 + (1 | race) Data: homi AIC BIC logLik deviance df.resid 1132.5 1142.8 -564.2 1128.5 1306 Scaled residuals: Min 1Q Median 3Q Max -0.7174 -0.3054 -0.3054 -0.3054 19.3426 Random effects: Groups Name Variance Std.Dev. race (Intercept) 0.739 0.8596 Number of obs: 1308, groups: race, 2 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.5235 0.6122 -2.489 0.0128 *
It seems like the deviance for the GLMM is 1128.5
while the deviance for the GLM is 844.71
. This is shows the GLM is fitting better than the GLMM which I think is the exact opposite solution from what question implied. I am not sure if I am looking at the correct output or if I setup the problem wrong.
Best Answer
There is probably something wrong with the question. The deviance for fit1
can be computed with
deviance(fit1) # same as sum(resid(fit1)^2)
But for the GLMM, the lme4
packages uses another method documented in ?llikAIC
, which gives 1128 – higher than for the GLM.
Perhaps the question actually wants to test for the decrease in deviance when adding the single fixed effect, because it comes out as 118, close to your 116.6:
fit1 <- glm(count~race, family=poisson(link = log),data=homi) fit0 <- glm(count~1, family=poisson(link = log),data=homi) > anova(fit0, fit1) Analysis of Deviance Table Model 1: count ~ 1 Model 2: count ~ race Resid. Df Resid. Dev Df Deviance 1 1307 962.80 2 1306 844.71 1 118.09
Similar Posts:
- Solved – Intraclass correlation with count data
- Solved – Poisson generalized linear model (glm) sample size
- Solved – Poisson generalized linear model (glm) sample size
- Solved – Quasi-Poisson GLM, can’t make sense of the p-values for Goodness-of-fit
- Solved – GLM – which probability distribution to use for abundance data