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.

Statusvalidated
Version1.0.0
Minitab equivalentStat > DOE > Factorial > Analyze (Coded levels with reference contrasts)

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

Reference
Reference level is represented by a vector of −1
Non-reference
Non-reference level j gets the unit vector with +1 at position j
Sum-to-zero constraint
The effect coefficients sum to zero; the reference effect follows from that

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)