Skip to content

Adjusting for random recording intervals in glmer/poisson

2 messages · Joshua Wiley, Dieter Menne

#
I do not recall for glmer off hand.  Ultimately, you want it To use the same link function as your outcom.  The question is whether glmer does this for you automatically or is like glmmadmb where it is your responsibility to know and use your link on the offset term.  Also, I thought offset was an argument, not a function in glmer, but I could be wrong (I know offset is used as you show it in things like glm).  I imagine you can try it both ways, perhaps with simple simulated data where the effect would be clear.  Or perhaps it's documented, it's late here but I can look in the morning.

Cheers,

Josh
On Jul 4, 2012, at 23:16, "Dieter Menne" <dieter.menne at menne-biomed.de> wrote:

            
#
Joshua Wiley wrote:

            
could be
I first simply tried it the glm way, then only noted that it is different in

glmer, but both methods give the same result.

library(lme4)
nsubj = 10
nvisit = 5
set.seed(100)
d = data.frame(
  subj = as.factor(1:nsubj),
  duration = runif(nsubj*nvisit,30,60),# in minutes
  predictor = rnorm(nsubj*nvisit,50,10))
d$nevent = with(d,rpois(nsubj*nvisit,predictor*duration/500))

# The glm way to use offset seems to work ok
glmer(nevent~predictor+offset(log(duration)) + (1|subj), data=d, 
      family=poisson)

# The lme4 documented way
glmer(nevent~predictor+ (1|subj), data=d, 
      offset= log(duration),family=poisson)