4
$\begingroup$

Let's say I run the following contrast:

fit_robust <- lm_robust(feelings ~ treatment * condition, 
                 cluster = teamID,
                 se = "stata",
                 data = all_data)

rg = qdrg(object = fit_robust, data = all_data)
outgroup_means = emmeans(rg, ~ condition | treatment)
contrast(outgroup_means, method = "pairwise")

This yields the following results:

outgroup_means

treatment = DD:
 condition      emmean    SE  df lower.CL upper.CL
 Main_Treatment  0.565 0.947 398   -1.298     2.43
 Pure_Control    1.117 1.539 398   -1.908     4.14

treatment = DR:
 condition      emmean    SE  df lower.CL upper.CL
 Main_Treatment  6.140 1.539 398    3.115     9.16
 Pure_Control    4.311 1.733 398    0.903     7.72

treatment = RD:
 condition      emmean    SE  df lower.CL upper.CL
 Main_Treatment  6.783 2.492 398    1.885    11.68
 Pure_Control    1.154 0.852 398   -0.521     2.83

treatment = RR:
 condition      emmean    SE  df lower.CL upper.CL
 Main_Treatment  0.722 0.804 398   -0.858     2.30
 Pure_Control    2.791 2.128 398   -1.393     6.97

contrast

treatment = DD:
 contrast                      estimate   SE  df t.ratio p.value
 Main_Treatment - Pure_Control   -0.552 1.81 398 -0.305  0.7602 

treatment = DR:
 contrast                      estimate   SE  df t.ratio p.value
 Main_Treatment - Pure_Control    1.829 2.32 398  0.789  0.4305 

treatment = RD:
 contrast                      estimate   SE  df t.ratio p.value
 Main_Treatment - Pure_Control    5.629 2.63 398  2.138  0.0332 

treatment = RR:
 contrast                      estimate   SE  df t.ratio p.value
 Main_Treatment - Pure_Control   -2.069 2.27 398 -0.910  0.3636 

Question 1. I'm not sure if a p-value correction is applied here, but I'm not interested in the contrasts involving treatment = DD or treatment = RR How would I exclude them to ensure correct p-values? I've seen examples involving specifying a custom grid, but I can't quite wrap my head around it.

Question 2. How would I specify the following contrast: treatment = RD, Main_Treatment vs. treatment = RR, Pure_Control; and treatment = DR, Main_Treatment vs. treatment = DD, Pure_Control?

For the second question, I have tried something like the following:

DD_control <- c(0, 1, 0, 0, 0, 0, 0, 0)
DR_treatment <- c(0, 0, 1, 0, 0, 0, 0, 0)

contrast(outgroup_means, method = list(DR_treatment - DD_control))

But I'm getting the error:

Error in contrast.emmGrid(outgroup_means, method = list(DR_treatment - : Nonconforming number of contrast coefficients

$\endgroup$

1 Answer 1

6
$\begingroup$

Question 1

As is documented, P-value correction is done by default separately for each by group. In this case, each by group has only one comparison, so there is no adjustment. You can always change the by group, e.g., to construct the comparisons for each treatment, then adjust as a single family of four comparisons:

summary(contrast(outgroup_means, "pairwise"), by = NULL)

You can also subset the comparisons:

summary(contrast(outgroup_means, "pairwise")[c(1,4)], adjust = "mvt")

[Notes: subsetting resets the by variable; also, trying adjust = "tukey" will fail be cause the Tukey adjustment applies to only one set of pairwise comparisons.]

Question 2

Here, you need to remove the by variable before computing the contrasts you want, because these are diagonal comparisons:

contrast(outgroup_means, 
    list(con1 = c(0,0,0,0,1,0,0,-1), con2 = c(0,-1,1,0,0,0,0,0)),
    by = NULL)

The order of contrast coefficients here is the same as the order of listing outgroup_means

You may find the vignette on contrasts and comparisons useful.

$\endgroup$
0

Your Answer

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

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