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)


  • 1
    $\begingroup$ Adding time as a random effect allows the slopes to vary by person over time. $\endgroup$
    – Glen
    Aug 22, 2017 at 16:40
  • $\begingroup$ 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+ ? $\endgroup$
    – Katie_C94
    Aug 23, 2017 at 0:17
  • $\begingroup$ 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: stats.stackexchange.com/questions/31569/… $\endgroup$
    – Glen
    Aug 23, 2017 at 17:10

1 Answer 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. 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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