jajoko
jajoko

Reputation: 1

How to restrict the number of comparisons between estimated marginal means using emmeans

I'm analyzing longitudinal hormonal data using lme (time entered as a categorical covariate), and would wish to test for the differences between study groups (control group and two experimental groups) as well as visualize the difference using emmeans. I am not at all interested in the comparison between successive time points within or across groups. Therefore I would wish to change the contrasts so that the correction for multiple comparisons takes into account only those comparisons that I'm at all looking at. However, even after consulting the emmeans vignette and this very nice tutorial by @aosmith16, I don't seem to understand how to do that.

A reproducible example, which does produce the comparisons between groups, but probably overadjusts the p-values. Of course, this is only a minimal problem and I don't mind being conservative in this respect.

ortho <- nlme::Orthodont
ortho <-ortho %>% 
  mutate(Sex = as.character(Sex)) %>%
  mutate(Sex = replace(Sex, Subject %in% 
                                 c("M10", "M11", "M12", "M13", "M14", "M15", "M16", "F01", "F02"),
                 "Other"))

fit <- lme(fixed = distance ~ factor(age) * Sex,
    random = ~ 1 | Subject, data = ortho)

fit %>% 
  emmeans(trt.vs.ctrl ~ factor(age) * Sex)

Upvotes: 0

Views: 503

Answers (1)

jajoko
jajoko

Reputation: 1

Seems like I didn't read the tutorial by @aosmith16 long enough. This is done by

fit %>% 
  emmeans(trt.vs.ctrl ~ Sex|factor(age)) %>%
  confint()

Upvotes: 0

Related Questions