[R-sig-ME] Adjusting for random recording intervals in glmer/poisson

Joshua Wiley jwiley.psych at gmail.com
Thu Jul 5 08:26:42 CEST 2012

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.



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

> Joshua Wiley wrote:
>> What is the significance of the recording interval varying?  If the
>> issue is that with a longer recording time, there are more
>> opportunities for events to occur, then what about treating duration as
>> an exposure and including it in the offset?  Essentially you model rate
>> then rather than counts.
> Good to hear that you suggest it to put it into the offset; I wanted to do this, but was not sure what exactly to put into the offset term. Duration or log(duration)?
> Dieter
> Apologies: I forgot to attach the simulated sample data in the original message
> 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))
> # Proposed solution by university statistician: 
> # use only the data from the first 30 minutes (not shown here) and do
> glmer(nevent~predictor + (1|subj),data=d, family=poisson)
> # Result is not correct, because truncated data not used
> # Proposed by Joshua
> glmer(nevent~predictor+offset(log(duration)) + (1|subj), data=d, family=poisson)

More information about the R-sig-mixed-models mailing list