emtrends in presence of a quadratic term: difference in quadratic trends

242 Views Asked by At

I want to model my response variable by Time. I used a quadratic term .

Usually when I only have a linear term, I use the function emtrends of emmeans package to get the differences between the two trend of two levels of my factor 'Side', how to find the differences of trend when there is a quadratic term "I(Age^2) Can emtrends achieve that ?

> mod.quadra<-lmer(RV~Side*(Age + I(Age^2))+(1|ID),data)
> Anova(mod.quadra)
                      Chisq Df Pr(>Chisq)    
Side                2.0791  1  0.1493267    
Age                 12.0248  1  0.0005250 ***
I(Age^2)            10.9917  1  0.0009152 ***
Side:Age            1.8857  1  0.1696876    
Side:I(Age^2)       2.0099  1  0.1562804   

enter image description here

how I usually do (when I only have a linear term)

>mtrend<-emtrends(LM.fit, "laterality", var = "Age")

 Side       Age.trend    SE  df lower.CL upper.CL
 contra          1.03 0.648 159   -0.251     2.31
 ipsi            2.03 0.648 159    0.755     3.31

>pairs(mtrend)
 contrast      estimate    SE  df t.ratio p.value
 contra - ipsi    -1.01 0.891 149  -1.129  0.2606
1

There are 1 best solutions below

0
evelyn On

Tricky to answer properly without reproducible data, but yes emtrends can handle polynomial terms. For your model, instead of using Age + I(Age)^2, try :

LM.fit <- lmer(RV ~ Side * poly(Age, 2) + (1|ID), data)

Then

emtrends(LM.fit, pairwise~Side, var = "Age", max.degree=2)

would give you the pairwise contrasts for both the linear and quadratic trends.

Your anova results suggest no difference in the trends due to Side, so I probably wouldn't do a post hoc test in this particular case, but that's up to you.