Effect Coding (Sum-to-Zero) for Categorical Factors
Maps a categorical factor with k levels onto k − 1 indicator columns; the intercept becomes the grand mean.
Description
Sum-to-zero coding (R: contr.sum) assigns each non-reference level a unit vector (+1 in its own column, 0 elsewhere) and gives the reference level a vector of −1s. The matching coefficient reads as the deviation from the grand mean; the reference deviation is the negative sum of the others. Advantage over dummy coding: the intercept estimates the grand mean rather than just the reference cell, ANOVA main effects are orthogonal to the intercept, and balanced designs simplify.
Formulas
Assumptions
- At least 2 levels per factor
- Reference level is one of the supplied levels
Limitations
- In extremely unbalanced designs the sum-to-zero coefficients may be hard to interpret — consider treatment (dummy) coding instead
References
- R Core Team (2024). contr.sum() in stats::contrasts
- Montgomery, D.C. (2017). Design and Analysis of Experiments, 9th Ed., Wiley — Chapter 3.5 (Effect Coding)