Add support for ART-C multiple comparisons by = "factor"
Closed this issue · 2 comments
I would like to limit pairwise comparisons to each time point of a mixed model repeated measures:
m <- art(
score ~ trt * time + Error(id),
data = mydf
)
anova(m)
The above shows significance for trt and trt:time interaction.
contrast(emmeans(artlm(m.art.lg, "trt:time"), ~ trt:time), method = "pairwise", by = "time")
will give me what I want and do pairwise comparisons between treatments (trt) at each time point only. However, I know that this will use ART and not ART-C, so the results are not valid.
contrast(emmeans(artlm.con(m.art.lg, "trt:time"), ~ trttime), method = "pairwise")
is overkill and does not report any significant differences for any pair.
contrast(emmeans(artlm(m.art.lg, "trt:time"), ~ trttime), method = "pairwise", by = "time")
is what I want, but I get the error "Error in .find.by.rows(args, by) : 'by' variables are not all in the grid".
Would you be able to change it so that the original factor columns are (e.g., in this case, the time and trt columns) are retained as well as the concatenated trttime factors column for this to work?
Hmmm, I'm not sure if we can retain the "time" variable in artlm.con
in this case in a way that emmeans can access it, as it would have to be in the model itself.
You might be able to use artlm.con()
as in your second example but with custom emmeans contrasts to specify just the subset of all pairwise comparisons you are interested in. It would unfortunately be a bit of a pain but I think it would work. Would have to think about API support for something like that.
That worked beautifully.
Thanks for the quick reply and useful package.