1

I have a response (y/n) taken at 4 time points for two treatments, for the same individuals in each treatment. I've found other answers which say time needs to be included in the model as below, can someone explain why it needs to be included like that please?

 model <- glmer(response ~ time*treatment + (1+time | person), data, family=binomial)

Thanks!

Katie_C94
  • 11
  • 3
  • 1
    Adding time as a random effect allows the slopes to vary by person over time. – Glen Aug 22 '17 at 16:40
  • Thanks Glen, so to confirm time and person are both random effects now? Or person is a random effect, given multiple measurements are taken for the same person, and time is also a random effect to account for the fact individual responses will vary over time? Also do I need to include the 1+ ? – Katie_C94 Aug 23 '17 at 00:17
  • Person is random, I'm not sure whether I'd call time random though, you still get a fixed overall effect from the model. I think reading this post will help you: https://stats.stackexchange.com/questions/31569/questions-about-how-random-effects-are-specified-in-lmer – Glen Aug 23 '17 at 17:10

1 Answers1

1

It is a random slope model. You have a random intercept for each person, in this case you are accounting the (random) slopes of time within each person.

It is not necessaraly the best approach, you should run the models and compare them. It is also worth to consider the correlation (or not) between the slopes and intercept, your syntax assumes correlation between them.

     model <- glmer(response ~ time*treatment + (1+time | person), data, family=binomial) # correlated slopes and intercept
     model1 <- glmer(response ~ time*treatment + (1+time || person), data, family=binomial) #uncorrelated slopes and intercept
     model2<- glmer(response ~ time*treatment + (1| person), data, family=binomial) 

  MuMIn::model.sel(model,model1,model2) # compare their AICc and pick the one with the lower AICc value. 
kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
maiava
  • 109
  • 5