# Testing interaction b/t group & longitudinal change for only part of the age range

I've fit a mixed linear model to some longitudinal data. I'm interested in the differences in patterns of decrease in the dependent variable according to group status, and my hypothesis particularly predicts a difference between the groups in trajectory of change at between specific ages. The data shows a significant interaction between group and the linear and quadratic effects of age, but I don't know if there is a way to assess this interaction for one part of the age range, or if I need to be able to do so in order to interpret my results as bing supportive of my hypothesis.

NB I'm using the nlme package in R

-

What you need to do is fit a new model with spline terms added to specify the different ranges of $age$ that your theory addresses. I talk about these issues here. Specific to your situation, let's imagine that you have 2 groups, and you think the relationship between $age$ and the response variable will be the same between 0 and 20, but will differ between 20 and 30, and then be the same again afterwards. Then you would have a model with, among other covariates, $group$, $age$, $age_{spline20}$, $age_{spline30}$, and all the associated interactions. Here is how you would create those spline terms: \begin{aligned} age_{spline20} &= 0 &\text{if } age\le{20} \\ age_{spline20} &= age-20 &\text{if } age>20 \\ \\ age_{spline30} &= 0 &\text{if } age\le{30} \\ age_{spline30} &= age-30 &\text{if } age>30 \end{aligned}
You can also form squared (quadratic) versions of these if you want them. The key to whether the slopes differ between the groups will be the tests of the interactions between these terms and the groups. For example, given the story above, you would expect no interaction between $age$ and $group$, but that there would be an interaction between $age_{spline20}$ and $group$. (Note that, in this complicated scenario, if the slope after 30 was the same between the groups, the $age_{spline30}*group$ interaction would also have to exist to compensate.)

-