# Mixed effect model with interaction

I am trying to explore the effects of an intervention on different outcome measures over time. In this example I evaluate the differences in the log-transformed data of my response variable (named: measurement) over time (time1 [baseline], time2, time3) between groups (Group1, Group2, Group3).

This is my code:

t0<-lmer(measurement ~ Group * time + (1|ID),gTUG)

And this is my output:

And the output from the anova(model) function:

(edited)(the total effect of the interaction is not significant; I think that it is due to lack of power and, additionally, my participants' data is quite variable and a bigger sample size could've improved the model)

(edited)Graph of the data:

How would you interpret the interaction properly? Would it be correct to say that only one level of the interaction is significant (i.e., Group2:timet2)?

(edited) Following the recommendations posted in the comments, I have checked whether adding an interaction significantly improves the model, and it does not significantly improve it. Output:

Therefore, would it be correct to focus on the differences between groups and across time points and report those?

I'd really appreciate your help! Many thanks, Anna

My reaction is that you should see whether the time variable, including all of its interactions, adds anything significant to the model.

Interactions are tricky. The interaction coefficient for Group2:timet2 represents the difference of the estimated value from what you would predict solely from the individual Group2 and timet2 coefficients. (Recall that the timet2 coefficient itself represents the estimated difference between timet2 and timet1 only within Group1.) Your results show that is the only combination of Group and time whose effect can be distinguished statistically from those 2 sets of individual coefficients.

What makes me hesitate are the relatively small coefficients for either of timet2 or timet3 or for the other interaction coefficients, particularly when compared against the much larger coefficients for Group. I wonder whether a model without the interaction terms or maybe even without a time predictor at all might fit the data just as well.

Unless you had a pre-specified hypothesis about this particular interaction, I'd recommend comparing the full set of nested models overall: compare this model to one without the interaction, and compare the model without the interaction against one that just includes group as a predictor. Those are simple anova()-type comparisons.

If the overall test of the models with and without interaction show that the interaction model is significantly better than the one without the interaction, then go ahead and report this result. Otherwise, see whether time matters at all when added to a model that only contains Group. It might be that your data support no significant (or at least substantial) effect of time at all.

Added in response to updated information

As the overall interaction term isn't significant but the time term adds significantly to the Group-only model (p = 0.012 in anova(t0)), you should report the model with just the additive Group and time terms, no interaction.

Show something like the plot you have now added, which seems to summarize the data pretty well. The differences over time are significant, but they are much less than the difference between Group1 and the other 2 Groups. Group2 and Group3 don't seem to differ from each other.

You can then discuss whether the "statistically significant" effect of time is large enough to matter in practice, something that is based on your understanding of the subject matter rather than statistics per se.

As a separate note, consider whether it might be better to use a generalized linear model with a log link rather than to analyze the log-transformed data directly with lmer(). It's essentially a question of whether you wish to model the mean of the predictions on the log scale (as you are) or the log of the mean estimate from the linear predictor (generalized linear model with log link).

• Thank you so much for your answer! I have now amended the question to include more information. In regard to the small coefficients of time, I understand your concerns about the small effect of time. However, my research aims to check whether there would be differences across timepoints for the outcome measure. Therefore, I think I cannot delete time since it is an important factor. Is this correct? Many thanks for all the helpful suggestions, I will take a look at those now! Jul 26 at 15:46
• @AnnaFerrusolaPastrana I have added to the answer. Yes, a model with Group and Time but without their interaction seems to be the best way to proceed.
– EdM
Jul 26 at 16:11
• This is very helpful, thank you very much! Jul 26 at 16:25

The effect estimators of interactions depend on the coding/contrasts. They are hard to interpret in the sense that they always compare a specific value to a baseline, interpretation depends on the baseline, and the contrast setting defines what it is. Probably from the code that you posted one could guess what the baseline is, but I'm frankly too lazy to look around and find it out (also it may depend on things that you have done before running the code that is posted above).

In any case what I recommend is this:

1. Test for the presence of the Group:timet interaction in total by fitting a model with it and another model without it and using the anova function to compare them.

2. Produce an interaction plot so that you can see what the most striking things are that cause the interaction as a whole to be significant (in case it is - I'd expect so based on the shown output, if maybe with p close to 0.05). Then interpret the plot.

• I would add that you can use marginal means and pairwise comparisons to test on which specific pairs of conditions there are significant differences. Jul 26 at 14:38
• Many thanks for your answer! I have now amended the question to provide more information about the model. I have also checked whether the model improved when adding the interaction term and it does not. Therefore, I assume I should delete the interaction and focus on the output from the model including only Group + time? Many thanks! Jul 26 at 15:36
• Personally I'd say you can use the model as it is, and say interactions are not significant so you won't interpret them. It is by no means mandatory to remove insignificant effects from a model, and there are good reasons against it (standard tests from a model that was constructed by data dependent selection are invalid). However there is a school of thought that would kick the interactions out in this case, so chances are if you do it it won't cause you trouble. Jul 26 at 22:22