I'm trying to setup a custom contrast using emmeans but am a bit unsure on how to do so properly.
I have two factors, let's call them A and B, with three levels each.
I want to test the following contrasts:
$$ c_1 = [ 0.5A_1 \quad 0.5B_3 \quad -1(AB)_{22}]$$ $$ c_2 = [ 0.5A_3 \quad 0.5B_1 \quad -1(AB)_{22}]$$
I have the following R code so far.
# data is in dataframe df
mod <- glm(Y ~ A * B, data=df)
emm <- emmeans(mod, ~A*B)
emm
What I'm unsure of is how to set the coefficients for the interaction terms to use with the contrast() function. When I display the emm object as I did in the above code, interaction terms aren't listed. It gives me marginal means for each combination of factor levels, and not estimates for the main effects.
That makes me think I can set the contrast for $c_1$ as this:
$$ \left[ \frac{1}{6}(AB)_{11} \quad \frac{1}{6}(AB)_{12} \quad \frac{1}{6}(AB)_{13} \quad \frac{1}{6}(AB)_{13} \quad \frac{1}{6}(AB)_{23} \quad \frac{1}{6}(AB)_{33} \quad -1(AB)_{22} \right]$$
(and similarly for $c_2$)
Does this make sense? It feels clunky and I feel like I'm missing an easier solution.
Thanks.