Tutorials › Exam PA - Predictive Analytics › Interpreting Simple Slopes and Category Differences

Exam PA · Categorical Encoding and Interactions · Tutorial 245 of 966

Interpreting Simple Slopes and Category Differences

Calculate within-category slopes and compare fitted values across categories at specified predictor values in an interaction model.

Intermediate 11 min read

What You'll Learn

  • Identify the reference category and write the fitted line for each factor level.
  • Calculate each category’s simple slope from the model coefficients.
  • Find a category difference at a specified numeric-predictor value.
  • Compare two non-reference categories by subtracting their fitted lines.
  • Recognize when an interaction makes category differences depend on the predictor.
  • Check whether a calculated equality point falls within the data’s predictor range.

What an Interaction Changes

A factor-by-numeric interaction allows the relationship between a numeric predictor and a response to differ across categories. It therefore changes two related interpretations: the slope within each category and the difference between categories at a given predictor value. A category difference is not necessarily one fixed number; with an interaction, it can vary as the numeric predictor changes.

The calculations in this tutorial use a linear model with an identity link. The fitted response is a conditional mean, and each category has a straight-line fitted relationship with the numeric predictor. Interpretations are limited to predictor values for which the model is intended to apply; extending a fitted line far beyond the observed range can be misleading.

Definition: A simple slope is the change in a model’s fitted response for a one-unit increase in a numeric predictor within a specified factor category. A category difference at \(x\) is the difference between the categories’ fitted responses when the numeric predictor equals \(x\). In an interaction model, that difference may depend on \(x\).

Reading the Coefficients in a Two-Category Model

Suppose a factor has reference category A and comparison category B. Let \(I_B\) equal 1 for category B and 0 for category A. A linear model with a factor-by-numeric interaction can be written as

$$ \widehat{y}=\beta_0+\beta_1x+\beta_2 I_B+\beta_3(xI_B). $$

Here, \(\beta_0\) is the fitted response for category A at \(x=0\), and \(\beta_1\) is category A’s slope. The coefficient \(\beta_2\) is the B-minus-A difference at \(x=0\), while \(\beta_3\) is the difference between B’s slope and A’s slope. These coefficient interpretations follow from substituting the indicator’s value for each category.

$$ \begin{aligned} \widehat{y}_A(x)&=\beta_0+\beta_1x,\\ \widehat{y}_B(x)&=(\beta_0+\beta_2)+(\beta_1+\beta_3)x. \end{aligned} $$

Thus, A’s simple slope is \(\beta_1\), and B’s simple slope is \(\beta_1+\beta_3\). Subtracting the fitted lines gives the B-minus-A category difference at \(x\):

$$ \widehat{y}_B(x)-\widehat{y}_A(x)=\beta_2+\beta_3x. $$

The interaction coefficient does not itself give the category difference at every \(x\). It gives the amount by which the category difference changes for a one-unit increase in \(x\). If \(\beta_3=0\), the slopes are equal and the category difference is constant. If \(\beta_3\ne 0\), the difference generally changes with \(x\).

Assumptions for these calculations: The model has a linear fitted mean on the response scale, uses the stated factor coding, and includes the numeric-predictor-by-category interaction shown in the equation. The slope and difference calculations are algebraic consequences of this model. They do not, by themselves, establish that the model fits well, that the relationship is causal, or that a coefficient is statistically significant.

Worked Example: Slopes and Differences for Two Service Plans

A hypothetical service provider models monthly maintenance hours \(y\) using numeric equipment age \(x\), measured in years, and service plan. Plan A is the reference category. The fitted model is

$$ \widehat{y}=18+1.2x-4I_B+0.8(xI_B), $$

where \(I_B=1\) for Plan B and \(I_B=0\) for Plan A. Find each plan’s slope and the B-minus-A difference at ages 2 and 5. Check the fitted values at those ages.

Method. Substitute the indicator values to obtain each fitted line. Read the coefficient of \(x\) as the category’s slope, then subtract the lines to obtain the category difference.

For Plan A, \(I_B=0\), so its fitted line is \(\widehat{y}_A(x)=18+1.2x\). Its slope is \(1.2\) maintenance hours per year of equipment age.

For Plan B, \(I_B=1\), so combine the intercept terms and the \(x\) terms: \(18-4=-\!{}\! -\!{}\! \) is not needed; directly, \(18+(-4)=14\), and \(1.2+0.8=2.0\). Therefore, \(\widehat{y}_B(x)=14+2.0x\). Plan B’s slope is \(2.0\) hours per year.

Subtract the Plan A line from the Plan B line: \((14+2.0x)-(18+1.2x)=-4+0.8x\). At age \(x=2\), the B-minus-A difference is \(-4+0.8(2)=-4+1.6=-2.4\) hours. At age \(x=5\), it is \(-4+0.8(5)=-4+4=0\) hours.

Check at \(x=2\): Plan A predicts \(18+1.2(2)=20.4\) hours, and Plan B predicts \(14+2(2)=18\) hours. The difference is \(18-20.4=-2.4\), as calculated. At \(x=5\), Plan A predicts \(18+6=24\) hours and Plan B predicts \(14+10=24\) hours, giving a difference of 0. The check confirms that the category difference is value-dependent.

Common mistake avoided: Reporting \(-4\) as the B-minus-A difference at every age uses only the intercept contrast. It is the difference at \(x=0\); at another age, the interaction contribution \(0.8x\) must be included.

Comparing Any Two Categories

With more than two factor levels, treatment coding gives each non-reference category an intercept contrast and a slope contrast relative to the reference category. For three categories, let A be the reference. Suppose the fitted model is

$$ \widehat{y}=\beta_0+\beta_1x+\beta_B I_B+\beta_C I_C+\gamma_B(xI_B)+\gamma_C(xI_C). $$

Then category A has fitted line \(\beta_0+\beta_1x\); B has fitted line \((\beta_0+\beta_B)+(\beta_1+\gamma_B)x\); and C has fitted line \((\beta_0+\beta_C)+(\beta_1+\gamma_C)x\). The slope contrasts \(\gamma_B\) and \(\gamma_C\) are relative to A, not directly relative to each other. To compare C with B, subtract B’s fitted line from C’s.

$$ \widehat{y}_C(x)-\widehat{y}_B(x) =(\beta_C-\beta_B)+(\gamma_C-\gamma_B)x. $$

This subtraction is essential: a comparison between two non-reference categories requires subtracting both their intercept contrasts and their slope contrasts. Their difference can change with \(x\), even though both categories’ coefficients were originally expressed relative to A.

Worked Example: Comparing Two Non-Reference Categories

A hypothetical training program models assessment scores \(y\) against hours of practice \(x\). Program A is the reference. The fitted model has an A intercept of 40 and an A slope of 4. Program B has an intercept contrast of 6 and a slope contrast of \(-1.5\); Program C has an intercept contrast of \(-3\) and a slope contrast of 2.5. Find all three slopes and the C-minus-B difference at \(x=4\). Verify the comparison using fitted values.

Method. Add each category’s slope contrast to the reference slope. To compare C with B, subtract the full fitted lines, not just their intercepts.

Program A’s slope is \(4\). Program B’s slope is \(4+(-1.5)=2.5\). Program C’s slope is \(4+2.5=6.5\).

The fitted lines are \(\widehat{y}_A(x)=40+4x\), \(\widehat{y}_B(x)=(40+6)+(4-1.5)x=46+2.5x\), and \(\widehat{y}_C(x)=(40-3)+(4+2.5)x=37+6.5x\).

At \(x=4\), Program B predicts \(46+2.5(4)=46+10=56\). Program C predicts \(37+6.5(4)=37+26=63\). Therefore, C minus B is \(63-56=7\) score points.

The coefficient-based calculation gives the same result: \(({-3}-6)+(2.5-(-1.5))(4)=-9+4(4)=-9+16=7\). The intercept contrast difference is \(-9\), and the slope contrast difference is \(4\).

Check. The two methods both give a C-minus-B difference of 7 at \(x=4\), so the calculation is internally consistent. Using only the intercept contrasts would give \(-9\), which is the C-minus-B difference at \(x=0\), not at \(x=4\).

Why the Difference Changes: A Short Derivation

For two categories, the fitted difference at \(x\) is \(\beta_2+\beta_3x\). If the predictor increases from \(x\) to \(x+1\), the new difference is \(\beta_2+\beta_3(x+1)\). Subtract the original difference:

$$ \left[\beta_2+\beta_3(x+1)\right]-\left[\beta_2+\beta_3x\right] =\beta_3. $$

So each one-unit increase in \(x\) changes the B-minus-A difference by \(\beta_3\). This is also why the interaction coefficient is the difference in slopes: B’s slope is \(\beta_1+\beta_3\), while A’s slope is \(\beta_1\), and their difference is \((\beta_1+\beta_3)-\beta_1=\beta_3\). The category difference is constant only when the slope difference is zero.

Worked Example: Finding Where Two Fitted Lines Meet

A hypothetical analyst models a service outcome against response time \(x\), measured in hours, for categories A and B. The fitted A line is \(\widehat{y}_A(x)=12+3x\). Category B has an intercept contrast of 9 and a slope contrast of \(-2.5\). The observed response-time range is 0 to 8 hours. Find the B-minus-A difference at \(x=2\) and \(x=6\), and determine whether the fitted lines meet within the observed range.

Method. Category B’s intercept is \(12+9=21\), and its slope is \(3-2.5=0.5\). Thus \(\widehat{y}_B(x)=21+0.5x\). Subtraction gives the difference function \(\widehat{y}_B(x)-\widehat{y}_A(x)=(21-12)+(0.5-3)x=9-2.5x\).

At \(x=2\), the difference is \(9-2.5(2)=9-5=4\). The fitted values are \(\widehat{y}_A(2)=12+6=18\) and \(\widehat{y}_B(2)=21+1=22\), confirming \(22-18=4\).

At \(x=6\), the difference is \(9-2.5(6)=9-15=-6\). The fitted values are \(\widehat{y}_A(6)=12+18=30\) and \(\widehat{y}_B(6)=21+3=24\), confirming \(24-30=-6\).

The lines meet when their difference is zero: \(9-2.5x=0\), so \(2.5x=9\) and \(x=9/2.5=3.6\) hours. Since \(0\leq 3.6\leq 8\), this equality point is within the stated observed range. At that value, A predicts \(12+3(3.6)=22.8\), and B predicts \(21+0.5(3.6)=22.8\). The equal predictions check the solution.

Common mistake avoided: A fitted-line intersection outside the data range may be an extrapolation rather than a supported comparison. Here, the intersection is inside the given range, so it is not an extrapolation relative to that range.

Common Interpretation Traps

  • Using the interaction coefficient as a category difference. The interaction coefficient is a slope difference. The category difference at \(x\) combines the intercept contrast and the interaction contribution.
  • Calling a reference slope the slope for every category. The reference slope is the numeric-predictor coefficient alone. Each other category’s slope adds its own slope contrast.
  • Comparing two non-reference categories using only their intercepts. Their slope contrasts must also be subtracted and multiplied by the predictor value.
  • Ignoring the direction of subtraction. “C minus B” is \(\widehat{y}_C-\widehat{y}_B\); reversing the order changes the sign.
  • Over-interpreting a fitted equality point. A calculated crossing is a property of the fitted lines. It should be treated cautiously outside the range or setting to which the model applies.

For an exam-style interpretation, state the category, the direction of comparison, the numeric-predictor value, and the response units. For example, “At five years of age, Plan B’s fitted maintenance hours are equal to Plan A’s” is more informative than reporting a contrast without context. These calculations are aligned with the SOA Exam PA (Predictive Analytics) syllabus.

Check Your Understanding

For each problem, identify the reference category, use the fitted lines or coefficient contrasts, and keep the direction of each comparison explicit.

  1. A model uses category A as its reference and has fitted equation \(\widehat{y}=10+2x+3I_B-0.5(xI_B)\). Find the slopes for A and B and the B-minus-A difference at \(x=4\). (Answer: A slope \(=2\), B slope \(=1.5\), and B-minus-A \(=1\).)
  2. In a three-category model, A has slope \(1.5\). B’s intercept and slope contrasts are \(-2\) and \(0.5\); C’s are \(4\) and \(-1\). Find all three slopes and the C-minus-B difference at \(x=3\). (Answer: Slopes A \(=1.5\), B \(=2\), C \(=0.5\); C-minus-B \(=1.5\).)
  3. For two categories, the B-minus-A difference is \(-5+1.25x\). At what predictor value are the fitted responses equal, and what is B-minus-A at \(x=6\)? (Answer: The fitted responses are equal at \(x=4\); B-minus-A at \(x=6\) is \(2.5\).)
  4. Relative to A, category B has an intercept contrast of \(-2\) and a slope contrast of \(0.4\); category C has an intercept contrast of \(5\) and a slope contrast of \(-0.6\). Find C-minus-B at \(x=5\). (Answer: \(2\).)
  5. A reference category has fitted line \(\widehat{y}_A(x)=20+1.2x\). Category B’s intercept contrast is 3 and its slope contrast is \(-0.2\). Find B’s fitted line, the B-minus-A difference at \(x=10\), and the predictor value where the lines meet. (Answer: \(\widehat{y}_B(x)=23+x\); B-minus-A at \(x=10\) is \(1\); the lines meet at \(x=15\).)
Clinical Biostats