# Interpreting an interaction in a mixed effects regression

library(lme4)
library(lmerTest)
library(tidyverse)
data("ChickWeight", package = "datasets")

chickm4 <- lmer(weight ~ Time * Diet + (Time | Chick), data = ChickWeight)

summary(chickm4)

Fixed effects:
Estimate Std. Error       df t value Pr(>|t|)
(Intercept)  33.6613     2.9192  47.5328  11.531 2.25e-15 ***
Time          6.2770     0.7614  46.9857   8.244 1.10e-10 ***
Diet2        -5.0277     5.0108  46.1500  -1.003 0.320918
Diet3       -15.4110     5.0108  46.1500  -3.076 0.003526 **
Diet4        -1.7505     5.0179  46.4012  -0.349 0.728786
Time:Diet2    2.3321     1.3044  45.7534   1.788 0.080420 .
Time:Diet3    5.1459     1.3044  45.7534   3.945 0.000272 ***
Time:Diet4    3.2550     1.3051  45.8534   2.494 0.016302 *


So I'm semi-sure I understand how to interpret the interaction effect: eg if my time was 10 and I was on Diet4, my weight would be predicted as 33.66 + 10*(6.277+3.25) - 1.75.

I'm need to better understand the implications of my p-values and what this means. The interactions between time and Diet 3 & 4 are significant. Does this mean that the liklihood this interaction is occurring due to chance is very low (eg 1.6% for Diet 4, statistically significant), and that therefore the Time:Diet2 interaction can't be ruled out as being down to chance (since at least in psychology we have a p< 0.05 threshold).

Also, for the relationship between Diet1 and Time, is this just the model coefficient Intercept + Time and it's assumed this is for Diet 1?

It certainly appears to be the case that Diet affects the chicks growth rate (weight over time) as visualised here:

ggplot(ChickWeight, aes(x = Time, y = weight, colour = Diet)) + geom_point() +
stat_smooth(method = 'lm', se = F) + theme_minimal()


So what can I say about time:Diet2, and Diet1 for which it doesn't specify. Would I say Diet2 trends towards significance? What I guess I'm trying to say is, does my model think that Diet2's effect on weight over time is not statistically significant, and therefore shouldn't be used to predict somewhat reliably? And if so is that just my poor modelling skills, a reflection of the data, or a combo of both?

Many thanks

Regarding p-values:

The p-values in the regression output are used to test the null hypothesis that the regression coefficient is 0, or in other words, that the variable is useful in predicting the response, given that the other variables are in the model. So the fact that the p-value for Time:Diet2 is greater than 0.05 means that you can conclude the following:

"Given that the model includes the other variables present, we cannot conclude at the interaction between Diet 2 and Time is significant in predicting the growth rate at the 0.05 level."

In general, the fact that the p-value is greater than 0.05 doesn't mean that the interaction isn't occurring, but rather that it's possible it's not adding additional information as far as predicting the response, once you already have the other variables in the model.

But the fact that the other interactions in your model are significant clearly indicates that you should keep all of the interaction variables in your model, even if one of them does have a p-value greater than 0.05.

Regarding Diet 1:

Your understanding here is correct. Diet 1 is the baseline in the model, so if you're using the model to predict a value for a time, given that they were on diet 1, you would just use the "intercept" and "time" coefficients.