Why a Predictor’s Slope Can Depend on Another Predictor
In a regression model with two quantitative predictors, the relationship between one predictor and the expected outcome need not be the same at every value of the other predictor. For example, an additional hour of study might be associated with a larger score increase for students who slept more. A product term lets a regression model describe this changing slope. The key task in this tutorial is to read the slope at a particular value of the second predictor.
The second predictor is often called a moderator when the association between the first predictor and the outcome varies with it. Here, “slope” means the change in the model’s expected outcome associated with a one-unit increase in the predictor, with the moderator held fixed. It describes a fitted association; by itself, it does not establish causation.
The Two-Predictor Interaction Model
Let \(X\) and \(Z\) be quantitative predictors and let \(Y\) be the outcome. The usual linear model containing their two-way interaction is
The coefficients \(\beta_0,\beta_1,\beta_2,\beta_3\) are fixed but unknown model parameters, and \(\varepsilon_i\) is the error for observation \(i\). The corresponding fitted regression equation replaces each parameter with its estimate \(b_0,b_1,b_2,b_3\).
The interaction term \(X_iZ_i\) is the product of the two predictors for observation \(i\). The model includes both main effects, \(X_i\) and \(Z_i\), as well as their product. Including the product without the corresponding main effects generally changes the model’s meaning and can impose an inappropriate restriction.
Deriving the Conditional Slope
To find the slope for \(X\) at a specified value of \(Z\), hold \(Z=z\) fixed in the conditional mean. The terms involving \(X\) can then be collected:
At this fixed value of \(Z\), the conditional mean is a straight line in \(X\). Its intercept is \(\beta_0+\beta_2z\), and its slope is \(\beta_1+\beta_3z\). Therefore, the conditional slope of \(X\) at \(Z=z\) is:
The same result can be justified using a finite change rather than a derivative. If \(X\) increases from \(x\) to \(x+\Delta x\) while \(Z=z\) remains fixed, the difference in the expected outcome is:
Thus, for a one-unit increase in \(X\), the expected outcome changes by \(\beta_1+\beta_3z\) units at \(Z=z\). This difference calculation also shows why the slope does not depend on the starting value \(x\): at each fixed \(z\), the model’s conditional mean is linear in \(X\).
The coefficient \(\beta_1\) is the slope of \(X\) specifically when \(Z=0\), because \(\beta_1+\beta_3(0)=\beta_1\). The coefficient \(\beta_3\) describes how the slope of \(X\) changes when \(Z\) increases by one unit. If \(Z\) increases by \(\Delta z\), the conditional slope changes by \(\beta_3\Delta z\). Meanwhile, \(\beta_2\) describes the slope of \(Z\) when \(X=0\); it is not the slope of \(X\).
Worked Example: A Dose Slope at Two Marker Values
Suppose a hypothetical fitted model predicts enzyme activity \(Y\), measured in activity units, from dose \(X\), measured in milligrams per day, and a baseline marker \(Z\), measured in marker points:
The estimated slope of dose at marker value \(z\) is \(b_1+b_3z=1.8-0.25z\), in activity units per milligram per day.
At \(Z=2\) marker points, substitute \(z=2\):
At this marker value, a one-milligram-per-day increase in dose is associated with an estimated 1.30-unit increase in expected enzyme activity, according to the fitted model.
At \(Z=6\) marker points:
Here, the estimated dose slope is 0.300 activity units per milligram per day. The two estimated slopes differ by \(1.30-0.300=1.00\) activity unit per milligram per day. That change also follows from the interaction coefficient: \((-0.25)(6-2)=-1.00\). These are fitted associations, not evidence that changing a person’s dose would cause the stated change in enzyme activity.
Interpreting the Coefficients and Their Units
The interaction coefficient’s units combine the units of the outcome and both predictors. In the dose example, \(\beta_3\) is measured in activity units per (milligram per day) per marker point. Multiplying it by \(z\), measured in marker points, gives the same units as the slope of \(X\): activity units per milligram per day. Keeping track of units is a useful check that the formula has been interpreted correctly.
The zero value in “the slope when \(Z=0\)” matters. If zero is outside the meaningful range of \(Z\), or is simply an arbitrary value, the main-effect coefficient \(\beta_1\) may not describe a practically relevant slope. The conditional-slope formula is still valid, but interpretation should focus on moderator values that make sense for the question and the data. Calculating a slope far outside the observed range can amount to extrapolation.
Worked Example: Commute Distance and Traffic
Consider a hypothetical fitted model for commute time \(Y\), in minutes, using distance \(X\), in kilometres, and a traffic index \(Z\), in index points:
The estimated slope of distance at traffic index \(z\) is \(2.4+0.7z\) minutes per kilometre. At \(Z=1.5\), the calculation is:
Thus, at traffic index 1.5, each additional kilometre of distance is associated with an estimated 3.45-minute increase in the model’s expected commute time. At \(Z=0.5\), the estimated slope is \(2.4+(0.7)(0.5)=2.75\) minutes per kilometre. The difference, \(3.45-2.75=0.70\), is \(b_3\) multiplied by the one-point difference in traffic index.
The coefficient \(b_2=1.1\) is not used to calculate either distance slope. It is the estimated traffic-index slope when distance is zero. This example also illustrates why a reported “distance coefficient” alone does not tell the full story when the product term is in the model.
How the Conditional Slope Changes Across the Moderator
The formula \(b_1+b_3z\) is a straight-line function of \(z\). If \(b_3>0\), the estimated slope of \(X\) becomes larger as \(Z\) increases; if \(b_3<0\), it becomes smaller. If \(b_3=0\), the fitted slope of \(X\) does not vary with \(Z\), although the model may still contain a \(Z\) main effect.
A conditional slope can also change sign. This happens when \(b_1+b_3z=0\), if that equation has a solution. The value \(z=-b_1/b_3\) is only meaningful for this purpose when \(b_3\ne0\), and it should be interpreted cautiously if it falls outside the observed moderator range. Finding a zero crossing describes the fitted equation; it does not, on its own, establish that the slope differs statistically from zero.
Worked Example: A Slope That Changes Sign
Suppose a hypothetical model predicts quiz score \(Y\), in points, from study time \(X\), in hours, and sleep \(Z\), in hours:
The estimated study-time slope at sleep duration \(z\) is \(4-0.6z\) quiz points per study hour. At \(Z=2\) hours:
At \(Z=5\) hours, the slope is \(4-(0.6)(5)=1.0\) quiz point per study hour. At \(Z=8\) hours, it is \(4-(0.6)(8)=-0.8\) quiz points per study hour. Under this fitted equation, the estimated association between study time and quiz score is positive at \(Z=5\), but negative at \(Z=8\).
The slope is zero where \(4-0.6z=0\), so \(z=4/0.6=6.67\) hours (to three significant figures). This zero crossing is a feature of the fitted slopes. Whether it is substantively useful depends on whether sleep durations near 6.67 hours are represented in the data and whether the model is appropriate there.
A Practical Reading Sequence
When reading a fitted two-predictor interaction model, identify the predictor whose slope is requested, identify the moderator value, and then use the matching coefficient pair. For the slope of \(X\) at \(Z=z\), those coefficients are \(b_1\) and \(b_3\). Substitute the given \(z\), calculate, and state the result with units and context.
Find the coefficient of \(X\) and the coefficient of the product \(XZ\); these are \(b_1\) and \(b_3\).
Use the specified value \(z\) of \(Z\), with its original scale and units.
Compute \(b_1+b_3z\), then describe the fitted change in expected \(Y\) for a one-unit increase in \(X\) at that moderator value.
This calculation gives a point estimate of a conditional slope. It does not provide its standard error, confidence interval, or test of whether it differs from zero. Those require additional calculations and are separate questions from reading the slope formula.
Common Mistakes and Why They Matter
- Using \(b_1\) as the slope everywhere. That is only the slope at \(Z=0\). At another value \(z\), use \(b_1+b_3z\).
- Using the wrong coefficient. The slope of \(X\) depends on the coefficient of \(X\) and the coefficient of \(XZ\). The coefficient of \(Z\) describes a different conditional slope.
- Leaving out the moderator value. A conditional slope is not fully specified until the value of \(Z\) is stated. “The slope is 2” is incomplete without naming the moderator value and units.
- Ignoring units or scale. The numerical answer depends on how \(Z\) is measured. If \(Z\) is measured in points, use the supplied value in points, not a rescaled value without also rescaling the coefficient.
- Turning association into causation. A fitted conditional slope describes the model’s expected outcome pattern. Causal language requires a design and assumptions beyond the interaction equation.
- Extrapolating without warning. A calculated value is algebraically available at any \(z\), but slopes at moderator values far beyond the data may not be reliable descriptions of the observed setting.
Check Your Understanding
For each question, show the relevant substitution and state the result in context when units are provided.
- A fitted model is \(\widehat{Y}=5+3X+2Z-0.4XZ\). What is the estimated slope of \(X\) when \(Z=5\)?
- In the model \(Y=\beta_0+\beta_1X+\beta_2Z+\beta_3XZ+\varepsilon\), what does \(\beta_1\) represent, and why is it not generally the slope of \(X\) for every value of \(Z\)?
- If \(b_3\) is positive, how does the fitted slope of \(X\) change as \(Z\) increases by two units?
- A model predicts sales in dollars from advertising in hundreds of dollars, \(X\), and store size in square metres, \(Z\). What are the units of the interaction coefficient?
- Why might a conditional slope calculated at a moderator value far outside the observed data range be difficult to interpret?