I have the following mixed model (package {lme4} in R) :


Here is the model output:

enter image description here

I have a significant triple interaction between year : syst : timing.

Year (=time) is continuous, syst(=treatment) has 5 levels and timing(=sampling session) has two levels.

I wish to set up constrats to test if the slopes for scale(year):syst differ from zero at level 1 of timing.

It seems like we can do this with testInteractions from package {phia} but the following set-up doesn't seem correct (or I don't see how "Value" is computed):

testInteractions(mod1,custom=list(syst=c(1,0,0,0,0),timing=c(1,0)), slope="scale(year)", adjustment="none")

Here is the output:

enter image description here

Could anyone shed their light on this?

This was previously discussed in the following link (but only for linear models with only continuous predictors): Test whether simple slopes are different from zero in 3-way interaction in multiple regression

It was also discussed in the following link (but only for second order interactions in mixed models): Mixed model interaction (covariate+factor): How to interpret posthoc table output in R package phia?


2 Answers 2


After discussion with Russell Lenth (a big thanks to him), this could be done the following way with emmeans::emtrends:


Even if year is scaled (which is the case here), this doesn't need to precised. To get the inferences (test against 0) and confidence intervals, one needs to do the following:

summary(em, infer=c(TRUE,TRUE),null=0)

Watch out for offsets, which seem to mess things up.


Following @Guillaume A2, you can also just nest the emtrends() function within the summary() and test() call to accomplish everything in one line. As an example:

summary(test(emtrends(mod, ~syst|timing, var = "year")))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.