# Determining when groups differ in repeated measures linear mixed model

I have two groups of individuals, each individual has a score measured multiple times and I have constructed a mixed model as follows with both individual slopes and intercepts allowed to vary:

lme(score ~ Group * Time , random = ~Time|Subject, data=df)


The data looks roughly like this at the group level:

I would like to do 2 things:

1. Estimate the time point at which the blue and red groups becomes equivalent in terms of score i.e. the red and blue line crossover, and also estimate a confidence interval for this value.

2. Test at certain time points e.g. Day 200 whether the blue and red groups are significantly different from one another in terms of score.

Time is treated continuously - not as a factor, because time points at which score is measured vary between individuals.

Thanks!

Rob

• Is there a reason to prefer your model instead of "score ~ Group, random = ~1|Subject + 1|Time"? I am assuming that, for each subject, you have data on multiple levels of "Time". Jul 15, 2021 at 12:42
• Your current formulation is modeling a linear effect of time. Thus, the tendency line you have in the figure is quite misleading - are you really interested in this kind of non-linear pattern, or you are aware that the model will fit a straight line for each group? That said, you can probably solve both of your questions by calculating a confidence interval on the model estimates. Jul 15, 2021 at 13:04
• @smndpln I do have multiple time points for each subject, I am not sure how to implement your suggested alternative in lme. Jul 16, 2021 at 13:33
• @LeoRJorge I am aware the model will fit a straight line and I am happy with this. If you are able to describe precisely how one would do solve my questions in R I would be most grateful Jul 16, 2021 at 13:34

## 1 Answer

Sorry, I'm not so familiar with the nlme package to give you a code solution, but as long as you are able to build Confidence Intervals for your model parameters (for lme4 models I would use predictInterval from merTools and build a newData dataframe with all combinations of time values from 0 to 300 and both groups), you are able to define your predicted mean and the confidence around the score for every time value and group, and then you can address both questions:

1. The prediction for both groups to be equivalent is the time value where both groups have the same mean, and similarly for the confidence intervals, you'll have a band of values where both groups are not distinguishable, where the confidence intervals overlap.

2. As you will have the confidence interval for every time value, you can check for any time, whether the intervals overlap.