Tutorials › Exam SRM - Statistics for Risk Modeling › Choosing a Reference Category

Exam SRM · Multiple Regression Estimation · Tutorial 43 of 926

Choosing a Reference Category

Use a reference category to interpret indicator coefficients as fitted comparisons with a clearly identified baseline.

Intermediate 12 min read

What You'll Learn

  • Define the reference category and its indicator coding in a regression model
  • Interpret the intercept and indicator coefficient relative to the reference level
  • Distinguish an adjusted fitted difference from a raw difference in group averages
  • Recode a two-level predictor using the other category as the reference
  • Explain why changing the reference changes coefficients but not fitted values

Why Choose a Reference Category?

A regression coefficient for a categorical predictor needs a comparison to be meaningful. With two categories, the reference category supplies the baseline: the indicator coefficient describes how the fitted response changes when moving from that baseline to the other category, with other predictors held fixed. Choosing the reference makes the model easier to read; it does not change the information in the data.

This tutorial focuses on a categorical predictor with two levels. The earlier material on binary predictors introduced indicator variables. Here, the emphasis is on how the choice of which level receives indicator value zero determines the interpretation of the intercept and coefficient.

Definition: For a two-level categorical predictor, the reference category is the level assigned indicator value zero. The other category is assigned value one. In a linear regression model, the indicator coefficient is the fitted difference between the value-one category and the reference category, holding the other predictors fixed.

For example, let \(D_i=1\) for category B and \(D_i=0\) for category A. With an intercept-only model, the fitted value for A is \(\hat\beta_0\), and for B it is \(\hat\beta_0+\hat\beta_D\). Thus, the fitted B-minus-A difference is \(\hat\beta_D\). If the model also contains a quantitative predictor \(x\), the difference is still \(\hat\beta_D\) at a fixed value of \(x\), provided there is no interaction between \(x\) and the category indicator.

Model and Interpretation

Suppose the response \(Y_i\) is modeled using a quantitative predictor \(x_i\) and a two-level category. Let \(D_i=1\) denote category B and \(D_i=0\) denote reference category A. The additive linear model is

$$ Y_i=\beta_0+\beta_x x_i+\beta_D D_i+\varepsilon_i. $$

For the conditional-mean interpretation, assume \(E(\varepsilon_i\mid x_i,D_i)=0\), so the model specifies the mean response at each predictor combination. To obtain unique ordinary least-squares estimates, the design matrix must have full column rank; in particular, the data must contain both categories, and the predictors must not be exactly redundant. No normality assumption is needed just to interpret the fitted coefficients.

Interpretation: In this model, \(\beta_0\) is the fitted mean for reference category A at \(x=0\). The coefficient \(\beta_x\) is the fitted change per one-unit increase in \(x\), holding category fixed. The coefficient \(\beta_D\) is the fitted B-minus-A difference at the same \(x\). Because there is no interaction term, that fitted difference is constant across \(x\).

The intercept is tied to both the reference category and the value \(x=0\). If zero is outside the meaningful range of \(x\), the intercept may not be practically useful, even though the category coefficient remains a comparison at equal \(x\). Centering \(x\) can make the intercept refer to a more meaningful predictor value, but it does not change the meaning of \(\beta_D\) as the same-\(x\) category difference.

Why the Coefficient Is a Fitted Difference

The interpretation follows directly by evaluating the model for each category at the same predictor value \(x\). For category A, \(D=0\); for category B, \(D=1\). Subtract the A fitted mean from the B fitted mean:

$$ \begin{aligned} \widehat{Y}_{B}(x)-\widehat{Y}_{A}(x) &=(\hat\beta_0+\hat\beta_x x+\hat\beta_D) -(\hat\beta_0+\hat\beta_x x)\\ &=\hat\beta_D. \end{aligned} $$

The intercept and quantitative-predictor contribution cancel. This is why the indicator coefficient is a comparison at the same predictor value, rather than necessarily the difference between the two categories’ unadjusted sample averages. If the categories have different distributions of \(x\), their raw average responses can differ for reasons associated with \(x\) as well as category.

In the special case with no quantitative predictors, the same result can be seen from least squares. The model is \(Y_i=\beta_0+\beta_DD_i+\varepsilon_i\), and the residual sum of squares is the sum of squared deviations from \(\beta_0\) for A and from \(\beta_0+\beta_D\) for B. At the least-squares minimum, the residuals within each group sum to zero: differentiating the residual sum of squares with respect to \(\beta_D\) makes the B residuals sum to zero, and differentiating with respect to \(\beta_0\) makes the total residuals sum to zero, so the A residuals also sum to zero. Therefore, the fitted value in each group is its sample mean:

$$ \hat\beta_0=\bar Y_A,\qquad \hat\beta_0+\hat\beta_D=\bar Y_B,\qquad \hat\beta_D=\bar Y_B-\bar Y_A. $$

With additional predictors, the category coefficient is generally an adjusted comparison from the fitted model, not simply the raw difference in group means.

Worked Examples

Worked Example: Choosing a Baseline for Two Groups

A hypothetical analyst records response amounts for two categories, A and B, and fits an intercept plus a category indicator. The observed responses are 18, 22, 20, and 24 for A, and 27, 31, 29, and 33 for B. Use A as the reference category. Find the fitted coefficients, the fitted values, the residual sum of squares, and the coefficients after switching the reference to B.

Method. In an intercept-plus-indicator model, least squares fits the sample mean in each category. Calculate the group means first:

$$ \bar Y_A=\frac{18+22+20+24}{4}=\frac{84}{4}=21,\qquad \bar Y_B=\frac{27+31+29+33}{4}=\frac{120}{4}=30. $$

With A as the reference, \(D_B=0\) for A and \(D_B=1\) for B. Therefore, \(\hat\beta_0=\bar Y_A=21\), and \(\hat\beta_D=\bar Y_B-\bar Y_A=30-21=9\). The fitted response is 21 for every A observation and 30 for every B observation.

For A, the residuals are \(18-21=-3\), \(22-21=1\), \(20-21=-1\), and \(24-21=3\). Their squared sum is \(9+1+1+9=20\). For B, the residuals are \(27-30=-3\), \(31-30=1\), \(29-30=-1\), and \(33-30=3\), also giving a squared sum of 20. Thus, the residual sum of squares is \(20+20=40\).

Now make B the reference and define \(D_A=1\) for A and zero for B. The fitted value for B is the new intercept, so \(\hat\beta'_0=30\). The fitted value for A must remain 21, so \(30+\hat\beta'_D=21\), giving \(\hat\beta'_D=-9\). The predictions and residual sum of squares are unchanged. The coefficient’s sign reverses because the comparison is now A minus B.

Check. The fitted category difference under the first coding is \(30-21=9\), while under the second it is \(21-30=-9\). Both codings reproduce the same group means and the same residual sum of squares. The common mistake this avoids is retaining a positive coefficient after reversing which category is the baseline.

Worked Example: A Category Difference Adjusted for a Predictor

A hypothetical study relates a response \(Y\) to a quantitative score \(x\) and category A or B. The observations are A: \((x,Y)=(0,10),(1,12),(2,14)\), and B: \((0,13),(1,15),(2,17)\). Fit the additive model with A as reference, then express the same fit using B as the reference.

Method. Since both categories have the same three \(x\)-values, calculate the shared slope from within-category deviations. In each category, \(\bar x=1\). The response means are \(\bar Y_A=(10+12+14)/3=12\) and \(\bar Y_B=(13+15+17)/3=15\). The deviations from the category means are \(-2,0,2\) in each group, and the \(x\)-deviations are \(-1,0,1\).

The sum of the products of the corresponding deviations is \(2+0+2=4\) in A and \(4\) in B, for a total of 8. The sum of squared \(x\)-deviations is \(1+0+1=2\) in A and 2 in B, for a total of 4. Thus, the common least-squares slope is \(8/4=2\).

$$ \hat\beta_x= \frac{\sum_g\sum_i(x_i-\bar x_g)(Y_i-\bar Y_g)} {\sum_g\sum_i(x_i-\bar x_g)^2} =\frac{8}{4}=2. $$

With A as reference, the fitted mean at \(x=1\) for A is 12. Since \(\hat\beta_0+2(1)=12\), the intercept is \(\hat\beta_0=10\). At \(x=1\), the B fitted mean is 15, so \(\hat\beta_D=15-12=3\). The fitted model is \(\hat Y=10+2x+3D_B\).

The predictions are A: \(10+2x\), giving 10, 12, and 14; B: \(10+2x+3\), giving 13, 15, and 17. Every fitted value equals its observed value, so all residuals are zero and the residual sum of squares is 0.

For B as the reference, the fitted mean at \(x=0\) is 13, so the new intercept is 13. The A-minus-B fitted difference at equal \(x\) is \(10-13=-3\), so the new coefficient for \(D_A\) is \(-3\). The re-expressed model is \(\hat Y=13+2x-3D_A\). For example, at \(x=2\), this gives B: \(13+2(2)=17\) and A: \(13+2(2)-3=14\), as before.

Check. Both codings give a common slope of 2, a fitted B-minus-A difference of 3, and zero residual sum of squares. The trap is to compare raw responses without holding \(x\) fixed; the model coefficient is the category difference at a common score.

Worked Example: Selecting a Baseline for Interpretation

In a hypothetical insurance analysis, annual claim cost is modeled in dollars using a risk score \(x\) and a plan category. The estimated model with Basic as reference is \(\widehat{Y}=520+18x-45D_P\), where \(D_P=1\) for Premium and \(D_P=0\) for Basic. Interpret the coefficients, predict at risk score 4 for each plan, and rewrite the model with Premium as reference.

Method. The reference category is Basic. At \(x=0\), the fitted Basic cost is \(\$520\). Holding the plan fixed, each one-point increase in risk score is associated with an \(\$18\) increase in fitted cost. The Premium coefficient is \(-\$45\), so at the same risk score, Premium has a fitted cost \(\$45\) lower than Basic.

At \(x=4\), the fitted Basic cost is \(520+18(4)=520+72=\$592\). For Premium, subtract \(\$45\): \(592-45=\$547\). Thus, the fitted Premium-minus-Basic difference at \(x=4\) is \(547-592=-\$45\).

To use Premium as the reference, define \(D_B=1\) for Basic and zero for Premium. The Premium fitted cost at \(x=0\) is \(520-45=\$475\), so the new intercept is 475. Basic is \(\$45\) higher than Premium at equal \(x\), so the new indicator coefficient is \(+\$45\). The re-expressed model is \(\widehat{Y}=475+18x+45D_B\). At \(x=4\), it gives Premium: \(475+72=\$547\), and Basic: \(475+72+45=\$592\).

Check. The original and re-expressed models give the same two predictions, while the indicator coefficient changes from \(-45\) to \(+45\). This avoids treating a negative coefficient as a universal statement that Premium costs less in every possible setting: the model’s statement is a fitted comparison at equal risk score.

Changing the Reference Without Changing the Fit

The algebra makes the invariance precise. Starting with B as the indicator category, write \(D_B=1\) for B and \(D_B=0\) for A. The reversed indicator satisfies \(D_A=1-D_B\). Substitute \(D_B=1-D_A\) into the model:

$$ \begin{aligned} \beta_0+\beta_xx+\beta_DD_B &=\beta_0+\beta_xx+\beta_D(1-D_A)\\ &=(\beta_0+\beta_D)+\beta_xx-\beta_DD_A. \end{aligned} $$

Thus, after switching the reference, the intercept becomes \(\beta_0+\beta_D\), the category coefficient becomes \(-\beta_D\), and the quantitative-predictor coefficient stays \(\beta_x\). This is a re-expression of the same fitted values, not a new substantive model. The intercept and category coefficient have different numerical interpretations because the baseline changed.

Key takeaway: Choose the reference category to make the intended comparison easy to read. The reference receives indicator zero; the indicator coefficient is the fitted difference for the other category minus the reference category, at equal values of the other predictors. Switching the reference changes coefficient values but, when the model is correctly re-expressed, leaves fitted values unchanged.

Common Mistakes

  • Reversing the difference. With B coded one and A as reference, the coefficient is B minus A. If A becomes the reference, the corresponding coefficient is A minus B.
  • Calling the indicator coefficient a raw mean difference in every model. That is generally true for a model with only an intercept and the indicator. With other predictors, it is the fitted difference at equal values of those predictors.
  • Interpreting the intercept without checking the reference and predictor value. In an additive model with \(x\), the intercept is the fitted response for the reference category at \(x=0\), not automatically the overall average.
  • Assuming a different reference changes predictions. If the intercept and indicator coefficient are re-expressed consistently, fitted values are identical.
  • Choosing a baseline because it is coded zero in the raw data. The analyst defines the coding. State clearly which category is the reference before interpreting the coefficient.

Check Your Understanding

For each problem, identify the reference category and interpret the fitted comparison carefully.

  1. A two-category intercept-only regression uses North as reference. The estimated intercept is 84 and the South indicator coefficient is 11. State both fitted category means and the South-minus-North difference. (Answer: North fitted mean \(84\); South fitted mean \(95\); South-minus-North difference \(11\).)
  2. A model uses Plan A as reference and estimates \(\widehat{Y}=30-7D_B\). Rewrite it with Plan B as reference using \(D_A=1\) for A, and state the fitted difference represented by the new indicator coefficient. (Answer: \(\widehat{Y}=23+7D_A\); the coefficient is A minus B, equal to \(7\).)
  3. A model with Group 0 as reference is \(\widehat{Y}=6+2x+5D_1\). Find the fitted values for Group 0 and Group 1 at \(x=3\), and state the conditional difference. (Answer: Group 0: \(12\); Group 1: \(17\); Group 1 minus Group 0: \(5\).)
  4. Two groups have mean responses 40 and 52, but the fitted additive model also includes a quantitative predictor. Explain why the indicator coefficient cannot generally be determined from these two means alone. (Answer: The coefficient is the fitted group difference at equal values of the quantitative predictor; raw group means can also reflect different predictor distributions.)
  5. A model with A as reference has \(\widehat{Y}=100+4x-12D_B\). Recode using B as reference, then find both fitted values at \(x=5\). (Answer: \(\widehat{Y}=88+4x+12D_A\); B fitted value \(108\), A fitted value \(120\).)
Clinical Biostats