Trouble extracting selected contrast pairs from either pairwise Summary() or Confint()

34 views Asked by At

There are 190 pairwise contrasts that appear in a summary() or confint(). If I use summary() or confint() I can manually located the selected contrast in the console. Instead, I would like to find code to extract the selected contrast.

This is the code I have tried:

mN3em = emmeans(mN3, specs = 'region') # calculate estimated region means
mN3tuk = contrast(mN3em, method = 'pairwise') # perform tukey's for pairwise mult. comparisons
summary(mN3tuk)
summary(mN3tuk, infer = TRUE)$contrasts$"853 - 902"

mN3em = emmeans(mN3, specs = 'region') # calculate estimated region means
mN3tuk = contrast(mN3em, method = 'pairwise') # perform tukey's pairwise multiple comparisons
confint(mN3tuk) #check confidence interval
confint(mN3tuk)$estimate['region1573 - region1575']

When using the codes to attempt isolation of select pair, they return

[1] NA
1

There are 1 answers

0
Russ Lenth On

It sounds like you want just a few contrasts, but you have created a quagmire by generating all pairwise comparisons. There are other possibilities, for example contrast(mN3em, "consec") just compares each mean with the next one. Or instead of "consec" or "pairwise", you can give a list of the contrast coefficients you want, e.g.,

coeflist = list(`m5-m4` = c(0,0,0,-1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
                `m8-m1` = c(-1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0))
contrast(mN#em, coeflist)