Let's say I have a model with two continuous predictors (nitrogen and temperature
) and one categorical variable (variety
).
dat <- data.frame(blocks=rep(c(1:15),each=2), variety=rep(c("A","B","C"),each=10),soil=runif(30,0,10), nitro = runif(30, 0, 10), temp= rnorm(30, 10, 3));
mod <- lmer(soil ~ variety*nitro*temp + (1|blocks), data=dat)
Let's pretend the variety:nitro:temp
interaction is significant. How can I calculate the trend involving these two continuous predictors? For example maybe I believe that the slope between soil and nitrogen will be steeper at increasingly higher temperatures only in variety A. Or, in other words, how can I test if the slope between soil and nitrogen changes as a function of temperature in variety A?
I thought this would give me that information
> emtrends(mod, pairwise~variety, var=c("nitro","temp"))
but it throws an error
Error in .subset2(x, i, exact = exact) : subscript out of bounds