Why Compare Conditional Slopes?
In a regression model with an interaction between two quantitative predictors, the slope relating one predictor to the mean response can depend on the value of the other predictor. Comparing those slopes at two specified values gives a direct description of how much the relationship changes across those values. The product coefficient makes this comparison especially simple: the difference in slopes is the product coefficient multiplied by the difference between the two specified values.
The direction of the comparison matters. In this tutorial, the contrast is defined as the slope at the second value minus the slope at the first value. Reversing the order reverses the sign. The contrast describes a feature of the fitted regression mean; by itself, it does not establish that changing either predictor causes a change in the response.
Model and Assumptions
Let \(X\) and \(Z\) be two quantitative predictors and let \(Y\) be the response. Use the product-term model
Here \(\beta_0,\beta_1,\beta_2,\beta_3\) are the model coefficients, and \(\varepsilon_i\) is the error for observation \(i\). For the conditional-mean interpretation, assume the model has the form
Equivalently, the error has conditional mean zero: \(E(\varepsilon_i\mid X_i,Z_i)=0\). The result below follows from this specified mean function. It does not require an assumption about the errors being normally distributed. The predictors are treated as quantitative, and the linear product-term form is assumed to be an appropriate description over the values being compared. The coefficients may be estimated from data; the algebra applies to either the model coefficients or their fitted estimates.
Deriving the Contrast
Write the conditional mean as a function of \(x\) and \(z\). At a fixed \(z\), the terms involving \(x\) are \(\beta_1x+\beta_3xz\). Their combined coefficient on \(x\) is \(\beta_1+\beta_3z\), so this is the conditional slope of \(X\) at \(Z=z\).
The derivative is constant in \(x\) for any fixed \(z\), as expected for a linear relationship in \(X\) at that fixed value of \(Z\). Substituting \(b\) and \(a\) into this slope expression and subtracting in the stated order gives the result.
The lower-order coefficient \(\beta_1\) cancels because it contributes equally to the slope at both values of \(Z\). The contrast depends on the product coefficient and on how far apart \(a\) and \(b\) are. In particular, it is zero if \(a=b\), and it is also zero if \(\beta_3=0\). A positive product coefficient means the conditional slope of \(X\) increases as \(Z\) increases; it does not necessarily mean the slope itself is positive.
The same result can be checked without calculus. For a nonzero change \(h\) in \(X\), at fixed \(z\), the change in the conditional mean divided by \(h\) is
This is the same conditional slope for any \(h\ne 0\). Subtracting this quantity at \(z=a\) from the quantity at \(z=b\) again gives \(\beta_3(b-a)\). Thus the result is exact for the specified linear product-term mean function, not an approximation for small changes in \(X\).
Worked Example: Comparing Slopes at Two Preparation Levels
Suppose a hypothetical fitted model predicts a quiz score \(Y\), in points, from study time \(X\), in hours, and a preparation measure \(Z\), in units:
Compare the conditional slope for study time at preparation levels \(Z=2\) and \(Z=5\), defining the contrast as the slope at 5 minus the slope at 2.
At a fixed \(Z=z\), the fitted conditional slope for study time is \(\hat{\beta}_1+\hat{\beta}_3z=1.8+0.12z\) points per hour. Therefore,
The difference is \(2.40-2.04=0.36\) points per hour. Using the product-coefficient contrast gives the same answer:
In this hypothetical model, the fitted increase in mean quiz score per additional study hour is 0.36 points per hour greater at preparation level 5 than at level 2. This describes a difference between two slopes, not a predicted score difference of 0.36 points between students at those preparation levels.
Interpreting Sign, Order, and Units
A difference-in-slopes contrast has units that combine the slope units with the units of the predictor whose values are being compared. If \(Y\) is measured in response units, \(X\) in \(X\)-units, and \(Z\) in \(Z\)-units, then the slope of \(X\) has units of response units per \(X\)-unit. The product coefficient \(\beta_3\) has units of response units per \(X\)-unit per \(Z\)-unit. Multiplying it by \(b-a\), measured in \(Z\)-units, leaves response units per \(X\)-unit: the units of a difference between slopes for \(X\).
The sign must be interpreted with the contrast order in view. If \(b>a\), a positive \(\beta_3\) makes the slope at \(b\) greater than the slope at \(a\). If \(b<a\), the same positive coefficient produces a negative contrast because the first named value is lower than the second. Always write down which slope is subtracted from which before interpreting the sign.
Worked Example: A Negative Contrast from a Positive Product Coefficient
Consider a hypothetical model for daily energy use \(Y\), in kilowatt-hours, with outdoor temperature \(X\), in degrees Celsius, and insulation rating \(Z\), in rating units:
Find the difference between the conditional slopes of temperature at \(Z=6\) and \(Z=2\), with the slope at 6 first. The conditional slope is \(-4.2+0.30z\) kilowatt-hours per degree Celsius, so
Subtracting in the requested order gives \((-2.4)-(-3.6)=1.2\) kilowatt-hours per degree Celsius. The contrast formula confirms this:
The positive contrast means the temperature slope is 1.2 kilowatt-hours per degree Celsius greater at insulation rating 6 than at rating 2. Both slopes are negative in this example: the modeled energy use decreases as temperature increases at both ratings, but the decrease is less steep at rating 6. A positive difference does not imply that either conditional slope is positive.
Use the Fitted Coefficient and Preserve the Comparison
When a regression output reports an estimated product coefficient, use that estimate in the contrast. If the estimated coefficient is \(\hat{\beta}_3\), the estimated difference between the conditional slopes at \(b\) and \(a\) is \(\hat{\beta}_3(b-a)\). The other coefficients are needed if the separate slopes are requested, but they cancel from their difference. This is a calculation about the fitted model; assessing uncertainty in the contrast requires additional calculations and is a separate question.
Worked Example: Reversing the Order Reverses the Sign
A hypothetical fitted model for a response measured in points has a product coefficient of \(\hat{\beta}_3=0.08\) points per practice hour per baseline-score unit. Compare the conditional practice-hour slopes at baseline scores 70 and 60.
First define the contrast as slope at 70 minus slope at 60. Then \(b=70\), \(a=60\), and the score difference is \(70-60=10\) units:
Thus, the fitted practice-hour slope is 0.80 points per hour greater at baseline score 70 than at score 60. If the comparison is instead stated as slope at 60 minus slope at 70, the calculation becomes
These are not conflicting conclusions. They describe the same difference in opposite orders. This example also shows why the size of a slope difference depends on the distance between the two values: the product coefficient alone is the change in the conditional slope for a one-unit increase in \(Z\), not necessarily the contrast for the two values under consideration.
Common Mistake
A frequent error is to report \(\beta_3\) itself as the difference between the slopes at any two chosen values. That is only correct when those values differ by exactly one unit in \(Z\), with the higher value second. In general, the difference is \(\beta_3(b-a)\). For example, a product coefficient of 0.12 and a comparison from \(Z=2\) to \(Z=5\) give \(0.12(5-2)=0.36\), not 0.12.
Another error is to interpret a positive contrast as proof that the slope at the second value is positive. The contrast only says that this slope is greater than the slope at the first value. As the energy-use example showed, both slopes can be negative. Calculate or otherwise establish the individual slopes before making claims about their signs.
Check Your Understanding
For each question, keep track of the order of subtraction and distinguish a difference between slopes from the value of a slope.
- In a model with product coefficient \(\hat{\beta}_3=0.25\), what is the estimated difference in the conditional slopes of \(X\) at \(Z=8\) and \(Z=3\), taking the slope at 8 minus the slope at 3?
- If the product coefficient is negative and \(b>a\), what does the sign of the contrast say about the slope at \(b\) relative to the slope at \(a\)?
- A fitted model has \(\hat{\beta}_1=-2\) and \(\hat{\beta}_3=0.4\). Find the conditional slope at \(Z=2\), then find the slope at \(Z=5\) minus the slope at \(Z=2\).
- Explain why a positive difference-in-slopes contrast does not necessarily mean that the slope at the second value is positive.
- If \(Y\) is measured in kilograms, \(X\) in days, and \(Z\) in degrees Celsius, what are the units of the difference between two conditional slopes of \(X\)?