I have a linear mixed effect model with three-way interaction fitted by the following code:
m <- lmer(cog ~ PRS*poly(Age, 2, raw=T)*Score
+ gender + Edu + fam + factor(Time)
+ (1|family/DBID),
data = test_all, REML = F)
In this model, there is a three-way interaction between PRS, Score, and polynomial terms of age with two degrees (linear + quadratic). For this three way interaction, how can I obtain the marginal effect(slope) of one variable, conditional on the other variables? For example, what is the slope of PRS, when age = 50 and score = 1?
Second, I tried to use the following code to plot this three-way interaction:
plot <- ggpredict(m, ci.lvl=0.95, c("PRS [all]", "Age [60, 65, 70, 75, 80]", "Score[0, 0.321, 0.695, 1.492, 1.914, 3.252]"))
plot(m)
The interaction plot finally shows but R didn't give the confidence interval. The error message is Error: Confidence intervals could not be computed.
How can I plot this three-way interaction with confidence interval?