# Mixed model contrasts for testing whether group differences increase/decrease across time points

I'm trying to fit a lmer model in order to predict whether group differences in scores on a scale increase/decrease over time.

The dataset includes the following variables:

Dependent variable: Scores on a scale ranging from 0 to 20

Predictors: Time_Point - a factor ranging from 1 to 6 and Group - a factor ranging from 1 to 3

Random factor: Subject_ID

The model looks like this:

fit <- lmer(Score ~ Time_Point * Group + (1|Subject_ID), data = dat,
contrasts = list(Time_Point = MASS:contr.sdif,
Group = MASS:contr.sdif))

The Time_Point * Group interaction is significant, however, I'm not sure what the most suitable follow-up analysis would be. I know that packages such as emmeans can provide contrasts and pairwise comparisons (e.g. Time_Point 1 Group vs Group 2), but I'm interested in testing for change across time points (i.e. Do differences in scores between group 1 and 2 increase from time point 1 to time point 2 and time point 2 to time point 3 etc. The only solution I have found so far is to create manual contrasts (using successive difference coding) and run a model that look like this:

dat$$Time_Point1_2 <- scale(ifelse(dat2$$Time_Point2 < 2,0,1), scale = FALSE)
dat$$Time_Point2_3 <- scale(ifelse(dat2$$Time_Point2 < 3,0,1), scale = FALSE)
dat$$Time_Point4_4 <- scale(ifelse(dat2$$Time_Point2 < 4,0,1), scale = FALSE)
dat$$Time_Point4_5 <- scale(ifelse(dat2$$Time_Point2 < 5,0,1), scale = FALSE)
dat$$Time_Point5_6 <- scale(ifelse(dat2$$Time_Point2 < 6,0,1), scale = FALSE)
dat$$Group1_2<-scale(ifelse(as.numeric(dat$$Group) < 2,0,1), scale = FALSE)
dat$$Group2_3<-scale(ifelse(as.numeric(dat$$Group) < 3,0,1), scale = FALSE)

fit2<- lmer(Score ~ Time_Point1_2 +Time_Point2_3 + Time_Point3_4 +
Time_Point4_5 + Time_Point5_6 +
Group1_2 + Group2_3 +
Time_Point1_2:Group1_2 +Time_Point2_3:Group1_2 +
Time_Point3_4:Group1_2 + Time_Point4_5:Group1_2 +
Time_Point5_6:Group1_2 +
Time_Point1_2:Group2_3 +Time_Point2_3:Group2_3 +
Time_Point3_4:Group2_3 + Time_Point4_5:Group2_3 +
Time_Point5_6:Group2_3 +
(1|Idnumber), data = dat)

and then use lmerTest and summary(fit2) to obtain the following comparisons:

Fixed effects:
Estimate Std. Error         df t value Pr(>|t|)
(Intercept)             2.514e+00  3.306e-02  3.939e+03  76.022  < 2e-16 ***
Time_Point1_2          -5.059e-02  4.299e-02  1.656e+04  -1.177  0.23933
Time_Point2_3          -5.663e-02  4.427e-02  1.650e+04  -1.279  0.20077
Time_Point3_4           4.195e-01  4.549e-02  1.648e+04   9.223  < 2e-16 ***
Time_Point4_5           2.615e-01  4.720e-02  1.645e+04   5.541 3.06e-08 ***
Time_Point5_6           4.585e-01  4.950e-02  1.646e+04   9.264  < 2e-16 ***
Group1_2                2.234e-01  7.836e-02  3.883e+03   2.851  0.00438 **
Group2_3                8.423e-01  8.472e-02  4.026e+03   9.942  < 2e-16 ***
Time_Point1_2:Group1_2 -4.843e-02  1.018e-01  1.653e+04  -0.476  0.63437
Time_Point2_3:Group1_2  9.127e-02  1.045e-01  1.647e+04   0.873  0.38260
Time_Point3_4:Group1_2  1.132e-01  1.066e-01  1.644e+04   1.062  0.28823
Time_Point4_5:Group1_2 -8.510e-02  1.094e-01  1.642e+04  -0.778  0.43675
Time_Point5_6:Group1_2  1.718e-01  1.138e-01  1.643e+04   1.509  0.13124
Time_Point1_2:Group2_3 -3.674e-02  1.101e-01  1.662e+04  -0.334  0.73866
Time_Point2_3:Group2_3  4.578e-02  1.141e-01  1.654e+04   0.401  0.68824
Time_Point3_4:Group2_3  2.058e-01  1.186e-01  1.653e+04   1.735  0.08272 .
Time_Point4_5:Group2_3  2.602e-02  1.248e-01  1.649e+04   0.209  0.83476
Time_Point5_6:Group2_3  8.333e-04  1.325e-01  1.650e+04   0.006  0.99498
---

Would this be a correct way to obtain estimates of the group differences across time and is there a better way of doing this, considering time point is a factor?