2
$\begingroup$

I am trying to probe the following significant interaction between Condition (categorical, three levels) and time (continuous) using R emmeans package: enter image description here

Original formula for the model was:

m.EDA = lmer(EDA_cs ~ Time_sd * Condition+
               (1+Time_sd|Subject) + 
               (1+Time_sd|Video),  
             data=data, control = lmerControl(optimizer="bobyqa", calc.derivs = FALSE, optCtrl=list(maxfun=2e5)),na.action = "na.exclude")

I know that with emtrends I can check if the effect over time is different across the different levels of condition. E.g.:

test(emtrends(m.EDA.hm, ~Condition|Time_sd, var="Time_sd", at = list(Time_sd = seq(-1.6, 1.6, by=.3))))

But I want something more specific: testing whether FS, HH and T are significantly different from each other 1. at the beginning of time (time_sd = -2), middle of time (=0) and end of time (time=2?).

I've been reading the emmeans manual but I can't figure out a way to go about this. The closest I've found is this:

test(emmeans(m.ECG.hm, pairwise ~ Condition*Time_sd, var="Time_sd", cov.reduce=range))

Which does offer a comparison of the diff. level of condition at different times, but the results don't make any sense (the differences are significant for negative time but not towards the end of time, and from the graph we can tell it's the exact opposite)

Any emmeans experts out there? thank you!

$\endgroup$

1 Answer 1

3
$\begingroup$

Woho! I got it. It wasn't as complicated as I thought it'd be, I don't know why it took me so much to figure it out. I leave here the answer in case it helps others: Say you want to do pairwise comparisons of your categorical variable at level 2, 0 and -2 of your continuous, this is the way to go about it:

test(emmeans(m.EDA.hm, pairwise ~Condition*Time_sd, at = list(Time_sd = 2)))
test(emmeans(m.EDA.hm, pairwise ~Condition*Time_sd, at = list(Time_sd = -2)))
test(emmeans(m.EDA.hm, pairwise ~Condition*Time_sd, at = list(Time_sd = -0)))

See example of results for time = 0:

$contrasts
 contrast    estimate     SE  df z.ratio p.value
 FS 0 - HH 0   -0.214 0.0124 Inf -17.273 <.0001 
 FS 0 - T 0    -0.100 0.0124 Inf  -8.098 <.0001 
 HH 0 - T 0     0.114 0.0124 Inf   9.210 <.0001 
$\endgroup$
3
  • 2
    $\begingroup$ You can do it in one call by putting all 3 of those times in a vector inside that list. $\endgroup$
    – Russ Lenth
    Feb 10, 2022 at 1:29
  • $\begingroup$ Would doing that be better/more conservative because it would do the p-adjustment to the entire group? $\endgroup$
    – Luminosa
    Feb 21, 2022 at 19:12
  • 1
    $\begingroup$ Yes, especially if you are concerned about multiplicity. $\endgroup$
    – Russ Lenth
    Feb 21, 2022 at 22:21

Your Answer

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

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