Statistics Glossary → Deviation (effect) coding
Deviation (effect) codingconcept
A coding scheme that represents each level of a categorical variable as its deviation from the grand mean, constraining the level effects to sum to zero.
For a variable with k levels, k − 1 coding columns are created. In each column the corresponding level gets 1, the omitted level gets −1 and all others get 0. Each coefficient is then the difference between that level's mean and the grand mean (the unweighted mean of the level means), and the intercept is the grand mean. The effect of the omitted level is minus the sum of the other coefficients.
With dummy (indicator) coding the coefficients are comparisons with a reference category; with deviation coding no level is privileged. Model fit and predicted values are identical under both codings; only the meaning of the coefficients changes. In models with interactions, Type III sums of squares are meaningful only with sum-to-zero coding such as this one. The λ parameters of log-linear models are usually written in this form too.
An everyday example
In a chain with four branches, the mean daily sales per branch are 120, 100, 90 and 90 thousand; the grand mean is 100. Under deviation coding the effect of the first branch is read as +20, the second as 0 and the third as −10; the effect of the fourth is −(20 + 0 − 10) = −10. No branch is chosen as the 'reference'.
In MerQur
In the log-linear model, 'Extra outputs: Deviation-coded λ' gives the parameters so that the level λs of each term sum to zero. In Cox regression, the 'Categorical coding' option chooses indicator (first), indicator (last) or deviation coding (last level -1) for text covariates. Type III sums of squares in two-way ANOVA and the factorial block of MANOVA are computed with sum-to-zero contrasts.
Analyses where this concept appears
Two-Way ANOVAMANOVALog-Linear ModelCox Regression (Proportional Hazards Model)
Related concepts
Dummy (indicator) variable codingReference category (comparison level)