3
$\begingroup$

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,
                    family = poisson(link = "log")
                     )


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


    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)
$\endgroup$
3
  • $\begingroup$ What if you include the offset in glmer? $\endgroup$ Commented Apr 18, 2019 at 14:54
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Apr 18, 2019 at 14:57
  • 1
    $\begingroup$ Glad I could help. You could answer your own question to "close" it. $\endgroup$ Commented Apr 18, 2019 at 14:58

1 Answer 1

1
$\begingroup$

The apparent differences came from a simple oversight in the glmer formula. We had to add an offset term! I am editing the question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.