I am confused about how sum contrasts are set up. As I understand, if I have some $K$-leveled factor, I can use sum contrasts to compare each level to the grand mean ($M_G$), effectively testing multiple hypotheses each predicting that some group $i$ of $K$ is different from $M_G$.
In practice (in R
), when I create a contrast matrix for a 4-leveled factor by calling contr.sum(4)
, I get:
contr.sum(4)
1 0 0
0 1 0
0 0 1
-1 -1 -1
then when I invert it using ginv
from MASS
(adding an intercept column) to get a hypothesis table of mean weights, I get this:
ginv(
cbind(1, contr.sum(4))
)
0.25 0.25 0.25 0.25
0.75 -0.25 -0.25 -0.25
-0.25 0.75 -0.25 -0.25
-0.25 -0.25 0.75 -0.25
which gives me 3 ($K - 1$) hypotheses, excluding the null. So, the first row (hypothesis) says that the weighted average of all 4 groups ($M_G$) is 0. Then, the second row says that $\frac{3}{4}M_1 - \frac{1}{4}M_2 - \frac{1}{4}M_3 - \frac{1}{4}M_4 = 0$, or equivalently that $M_1 = \frac{M_1+M_2+M_3+M_4}{4} = M_G$ and so on ($M_i$ is the mean of group $i$).
However, there is no hypothesis comparing the mean of the 4th group, or in general the $K$th group. Why is that?. What if I wanted to specifically compare each group mean to the grand mean in my analysis? I feel like I am missing something obvious here, as most resources I see on that simply mention that there are $K-1$ sum contrasts for a factor with $K$ levels.