Tutorials › Regression Analysis (Undergraduate) › Interpreting Coefficients Under Sum Coding

Coding Categorical Predictors · Tutorial 308 of 991

Interpreting Coefficients Under Sum Coding

Interpret the intercept and category coefficients in a factor-only sum-coded model, including how to recover every fitted category mean.

Beginner 9 min read

What You'll Learn

  • Identify the sum-to-zero constraint used for a categorical predictor
  • Interpret the intercept as the unweighted average of fitted category means
  • Read a category coefficient as that category’s deviation from the average
  • Recover the final category’s effect and all fitted means from the coefficients
  • Distinguish a deviation from the average from a pairwise group difference

Introduction

When a categorical predictor has several levels, the coding scheme determines how the regression coefficients describe the category means. With reference coding, a coefficient describes a difference from the reference category. With sum coding, the comparison point is different: the intercept is the unweighted average of the fitted category means, and the category effects describe deviations from that average.

This interpretation is useful when no single category should serve as the natural baseline. It also makes the coefficients’ constraint visible: across all categories, the deviations from the average must sum to zero. The calculations below use a factor-only model, so the fitted value depends on the category and no other predictors.

The Sum-Coded Factor-Only Model

Suppose a factor has \(K\) categories, labelled \(1,\ldots,K\), and the quantitative response is measured in some specified units. Use \(K-1\) coded predictors. For categories \(1\) through \(K-1\), the code for a category is \(+1\) in its own column and \(0\) in the other columns. Category \(K\) receives \(-1\) in every column. This is one standard sum-coding convention.

The factor-only regression model is

$$ Y_i=\beta_0+\beta_1x_{i1}+\cdots+\beta_{K-1}x_{i,K-1}+\epsilon_i. $$

Here \(Y_i\) is the response for observation \(i\), \(x_{ij}\) is the code in column \(j\) for that observation’s category, and \(\epsilon_i\) is its error. For the usual linear-model interpretation, assume errors have mean zero conditional on category, are independent across observations, and have a common variance. Normality is not needed for the coefficient meanings or fitted-mean calculations below; it is relevant to some forms of exact small-sample inference.

Definition: In this sum-coded factor-only model, \(\beta_0\) is the intercept and \(\beta_j\) is the effect for category \(j\), for \(j=1,\ldots,K-1\). The effect for category \(K\) is defined by the sum-to-zero constraint as \(-\sum_{j=1}^{K-1}\beta_j\). Each category effect is its fitted category mean minus the unweighted average of all \(K\) fitted category means.

“Unweighted” means that each category contributes once to the average, regardless of how many observations are in it. It does not mean an average weighted by category sample sizes. The fitted category means are model predictions for the categories, not necessarily the same thing as the overall average of all observed responses.

How the Coefficients Produce Category Means

For category \(j\), where \(j<K\), its own coded column is \(+1\) and its other columns are \(0\). Substituting those codes into the model gives fitted mean \(\beta_0+\beta_j\). For category \(K\), all \(K-1\) codes are \(-1\), so its fitted mean is \(\beta_0-\beta_1-\cdots-\beta_{K-1}\).

$$ \widehat{\mu}_j=\beta_0+\beta_j\quad (j=1,\ldots,K-1), \qquad \widehat{\mu}_K=\beta_0-\sum_{j=1}^{K-1}\beta_j. $$

A hat here indicates a fitted category mean. Averaging these \(K\) fitted means gives

$$ \frac{1}{K}\sum_{j=1}^{K}\widehat{\mu}_j = \frac{(K-1)\beta_0+\sum_{j=1}^{K-1}\beta_j +\beta_0-\sum_{j=1}^{K-1}\beta_j}{K} =\beta_0. $$

The positive and negative coefficient terms cancel, leaving the intercept. Therefore the fitted mean for any category minus \(\beta_0\) is that category’s effect, and the effects sum to zero. This is an algebraic property of the coding, not a claim that every category has the same fitted mean.

Worked Example: Interpreting Three Category Effects

Suppose a hypothetical training program has three categories, A, B, and C. A factor-only model fitted to a quantitative outcome measured in points has an intercept of \(15\), with sum-coded coefficients \(\beta_A=-3\) and \(\beta_B=0\). Assume the model’s independent, mean-zero, common-variance errors are appropriate for these observations. The calculation of fitted means itself follows from the coding.

A and B are the first two categories, so each has its own \(+1\) code in one column and a \(0\) in the other. C has \(-1\) in both columns. Thus:

$$ \widehat{\mu}_A=15+(-3)=12\text{ points}, \qquad \widehat{\mu}_B=15+0=15\text{ points}, $$
$$ \widehat{\mu}_C=15-(-3)-0=18\text{ points}. $$

Their unweighted average is \((12+15+18)/3=45/3=15\) points, equal to the intercept. The effects are \(-3\), \(0\), and \(+3\) points: A is 3 points below the average, B is at the average, and C is 3 points above it. The coefficient \(\beta_A=-3\) does not say that A is 3 points below B; the A-versus-B difference is \(12-15=-3\) points in this example, but that happens because B’s effect is zero.

The Last Category’s Effect

Only \(K-1\) coefficients are estimated for the factor, so the last category does not receive a separate coefficient in the equation. Its effect is still determined: the effects across all categories must sum to zero. If the first \(K-1\) effects add to a positive number, the last effect is the negative of that sum; if they add to a negative number, the last effect is positive.

Key result: For categories \(1,\ldots,K\), define \(\alpha_j=\widehat{\mu}_j-\beta_0\). Then \(\sum_{j=1}^{K}\alpha_j=0\), \(\beta_0=(1/K)\sum_{j=1}^{K}\widehat{\mu}_j\), and the final category’s effect is \(\alpha_K=-\sum_{j=1}^{K-1}\beta_j\).

Worked Example: Recovering Means From Coefficients

Consider a hypothetical factor with categories A, B, and C, and a factor-only model for a test score measured in points. The estimated intercept is \(42\), and the coefficients for A and B are \(4\) and \(-1\), respectively. For this interpretation, assume the model’s independent errors have conditional mean zero and common variance; no significance test is being made.

The coding gives the fitted means:

$$ \widehat{\mu}_A=42+4=46\text{ points}, \qquad \widehat{\mu}_B=42+(-1)=41\text{ points}. $$

For C, both codes are \(-1\), so:

$$ \widehat{\mu}_C=42-4-(-1)=39\text{ points}. $$

The last category’s effect is \(-4-(-1)=-3\) points. The effects, \(4\), \(-1\), and \(-3\), sum to zero. The fitted means average to \((46+41+39)/3=126/3=42\) points. In context, the intercept is the unweighted average of the three fitted category scores, while the coefficient for A says that A’s fitted score is 4 points above this average.

Category Effects Are Not Pairwise Differences

A category effect compares that category with the unweighted average across all categories. A pairwise difference compares two particular categories. If categories \(r\) and \(s\) have effects \(\alpha_r\) and \(\alpha_s\), their fitted-mean difference is \(\alpha_r-\alpha_s\), because the shared intercept cancels. It is generally not equal to either effect alone.

$$ \widehat{\mu}_r-\widehat{\mu}_s =(\beta_0+\alpha_r)-(\beta_0+\alpha_s) =\alpha_r-\alpha_s. $$

Worked Example: Distinguishing a Deviation From a Difference

A hypothetical factor has four categories of a study schedule. A factor-only model for weekly study hours has an intercept of \(75\) hours, with effects for the first three categories of \(-5\), \(1\), and \(5\) hours. Assume independent observations and errors with conditional mean zero and common variance, as stipulated for this model.

The fourth category’s effect is the negative sum of the first three:

$$ \alpha_4=-((-5)+1+5)=-1\text{ hour}. $$

The four fitted means are therefore \(70\), \(76\), \(80\), and \(74\) hours. Their unweighted average is \((70+76+80+74)/4=300/4=75\) hours. The first category’s coefficient of \(-5\) hours means its fitted mean is 5 hours below that average. The difference between the third and first categories is instead \(80-70=10\) hours, or \(5-(-5)=10\) hours using their effects. The coefficient for the first category is not the third-versus-first difference.

Why This Interpretation Matters

Sum coding changes how the coefficients are described, not the fitted category means represented by a correctly specified factor-only model. The intercept provides a central summary of the fitted means, and each effect shows how far one category lies above or below that center. This can be a useful description when the categories have no natural baseline.

The meaning of the average deserves care. It is the unweighted average across the \(K\) category means: each distinct category receives equal weight in that calculation. If category sizes differ, this need not equal the average response across all individual observations. Nor does a coefficient’s sign establish that a category differs reliably from the average; deciding that requires an inferential procedure and its assumptions.

Common Mistakes

  • Treating the intercept as a reference-category mean. Under the sum coding defined here, the intercept is the unweighted average of the fitted category means. There is no reference category in this interpretation.
  • Reading a coefficient as a pairwise difference. A coefficient is a deviation from the average. To compare two categories, subtract their effects; the intercept cancels.
  • Forgetting the last category. It has no separately listed coefficient, but its effect is the negative sum of the other effects. It is not automatically zero.
  • Using the sample-size-weighted average instead. The intercept’s interpretation follows from the coding constraint and averages the category means equally, rather than weighting categories by their numbers of observations.
  • Confusing a model interpretation with a causal claim. A category coefficient describes fitted associations in the model. By itself it does not show that belonging to a category caused a response difference.
Key takeaway: With the stated sum coding, the intercept is the unweighted average of the fitted category means. Each category effect is its fitted mean minus that average; the effects sum to zero, and pairwise differences require subtracting two effects.

Check Your Understanding

Answer each question using the sum-coding convention defined above.

  1. A factor has four categories and an intercept of 20. What is the unweighted average of its four fitted category means?
  2. For a three-category factor, the first two effects are \(2\) and \(-5\). What is the third category’s effect?
  3. If a category’s effect is \(-4\) points, what does that say about its fitted mean in relation to the unweighted average?
  4. Two categories have effects of \(3\) and \(-2\) hours. What is their fitted-mean difference, taking the first category minus the second?
  5. Explain why the intercept need not equal the average response across all individual observations when category sizes differ.