# significance of slope (different than zero) in triple interaction (with factors) for mixed model

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

mod=glmer(Weed_density~block+scale(year)*syst*timing+(1|year)+(1|plot)+(1|plot:year)+(1|ID_quadrat)+(1|OLRE)+offset(log(size_quadrat)),family=poisson(link="log"),dat=WEED)


Here is the model output:

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:

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?

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

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


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")))