# Why do I get so different estimations with glm and glmer?

I am using the glmer function (lme4 package) to get estimations in a Poisson regression model (generalized linear model). I wanted to compare the estimations for the fixed effects with those obtained with the glm function. I was surprised to see big differences ! I know that glmer includes random effect; but that does not suffice to explain theses differences.

Could someone explain to me what I missed in my approach ?

EDIT and ANSWER : Put an offset term in both glmand glmer

library(surrosurv)
library(survival)
library(lme4)

data(colon)
colon1 = subset(colon, etype == 1)
# Poissonization

don_pois = poissonize(colon1, interval.width = 365.25, factors = c ('surg', 'rx'), compress = FALSE)
names(don_pois)[3] = 'trt'; names(don_pois)[4] = 'trialref'

fitpoi_glmer   <- glmer(
formula = event ~ -1 + interval + ( 1 | trialref ),
data = don_pois,
)

fitpoi_glm <- glm(
formula = event ~ -1+ interval + offset(log(time)),
data = don_pois,
)

summary(fitpoi_glmer)$$coefficients summary(fitpoi_glm)$$coefficients

# Survival graphics

fixed.coef.glmer = summary(fitpoi_glmer)$$coefficients[,'Estimate'] risks0 = exp(fixed.coef.glmer[grep("(?!.*:)interval.*", names(fixed.coef.glmer), perl = T)]) * 365.25 surv0 <- c(1,exp(-cumsum(risks0))) x = seq(0, max(colon1$$time), length.out = length(surv0))
plot(x, surv0, type ='l', col = 'blue', lwd = 2)

risks3 = exp(coef(fitpoi_glm)[grep("(?!.*:)interval.*", names(coef(fitpoi_glm)), perl = T)]) * 365.25
surv3 <- c(1,exp(-cumsum(risks3)))
lines(x, surv3, type ='l', col = 'pink', lwd = 2)

# Comparison with survfit
lines(survfit(Surv(time, status)~1, data = colon1 ), lty = 2, conf.int= FALSE)
• What if you include the offset in glmer? Commented Apr 18, 2019 at 14:54
• It seems you are right ! With adding the offset term, the two estimates are similar. Thanks a lot for your help, I was on this problem, my all day. Commented Apr 18, 2019 at 14:57
• Glad I could help. You could answer your own question to "close" it. Commented Apr 18, 2019 at 14:58