Why a Predictor’s Slope Can Depend on Two Moderators
In an interaction model, the association between a predictor and an outcome can depend on another variable. With a three-way interaction, it can depend on two moderators at once. The practical question is often direct: at specified values of both moderators, what is the estimated change in the outcome for a one-unit increase in the predictor?
The answer is a conditional slope. It is obtained from the model by differentiating the fitted conditional mean with respect to the predictor while holding the moderators fixed. Comparing those slopes across moderator combinations shows how the predictor’s relationship with the outcome changes across conditions. These are model-based associations; an interaction by itself does not establish a causal effect.
The Model and Its Conditional Slope
Let \(Y\) be the outcome, \(X\) the predictor whose slope is of interest, and \(W\) and \(Z\) the two moderators. For three continuous variables, a hierarchical model containing a three-way interaction is
The model includes all lower-order terms as well as the three-way product. This makes the conditional mean a linear function of each predictor when the other two are held fixed. The coefficients describe this model’s conditional mean; in a fitted model, their estimates are used to calculate estimated slopes.
The slope does not depend on \(X\) in this model, but it does depend on both moderator values. If \(X\) is measured in hours and \(Y\) in outcome units, the slope is in outcome units per hour. The moderator values must be interpreted in their recorded or centered units.
The calculation follows directly from differentiation. Terms that do not contain \(X\) have derivative zero. The derivative of \(\beta_1X\) is \(\beta_1\), those of \(\beta_4XW\) and \(\beta_5XZ\) are \(\beta_4W\) and \(\beta_5Z\), and that of \(\beta_7XWZ\) is \(\beta_7WZ\). Holding \(W=w\) and \(Z=z\) fixed gives the stated formula.
Comparing Slopes Across Moderator Combinations
Once the conditional-slope formula is available, a comparison is a subtraction. For two moderator combinations, \((w_1,z_1)\) and \((w_0,z_0)\), the difference in the \(X\)-slopes is
where \(S(w,z)=\beta_1+\beta_4w+\beta_5z+\beta_7wz\). For example, if only \(Z\) changes while \(W=w\) stays fixed, then
Thus, the difference in \(X\)-slopes between two \(Z\) values can itself depend on \(W\). The three-way coefficient \(\beta_7\) describes how the \(X\)-by-\(W\) slope change varies with \(Z\), or equivalently how the \(X\)-by-\(Z\) slope change varies with \(W\). A useful exact statement is that the difference-in-differences of \(X\)-slopes across moderator values is
This identity clarifies why a three-way coefficient is not, by itself, the \(X\)-slope at any particular moderator combination. It quantifies how a change in one moderator’s relationship to the \(X\)-slope differs across values of the other moderator. If both moderators are binary indicators coded 0 and 1, this difference-in-differences equals \(\beta_7\).
Worked Example: Two Continuous Moderators
Suppose a hypothetical fitted model relates an outcome \(Y\), measured in points, to study time \(X\), measured in hours, and two continuous moderators: practice intensity \(W\), measured in sessions per week, and support \(Z\), measured in scale units. The estimated terms involving \(X\) are \(\hat{\beta}_1=1.20\), \(\hat{\beta}_4=0.30\), \(\hat{\beta}_5=-0.20\), and \(\hat{\beta}_7=0.08\). Calculate the estimated study-time slope at \(W=2\), \(Z=3\), then compare it with the slope at \(W=2\), \(Z=0\).
At \(W=2\) and \(Z=3\), substitute the values into the conditional-slope formula:
The estimated slope is 1.68 outcome points per additional study hour at that moderator combination. At \(W=2\), \(Z=0\), the estimated slope is
The difference, defined as the slope at \(Z=3\) minus the slope at \(Z=0\), is \(1.68-1.80=-0.12\) outcome points per study hour. Checking with the fixed-\(W\) comparison formula gives \((3-0)[-0.20+(0.08)(2)]=3(-0.04)=-0.12\). The negative difference means the estimated study-time slope is 0.12 points per hour smaller at \(Z=3\) than at \(Z=0\), when \(W=2\).
Binary Moderators: Slopes in Four Cells
The same formula applies when moderators are categorical and represented by indicator variables. If \(W\) and \(Z\) are each coded 0 for a reference category and 1 for a comparison category, the conditional \(X\)-slope is evaluated at four combinations. In this coding, \(\beta_1\) is the slope in the reference-reference cell. Other slopes add the relevant interaction terms. Changing the reference category or coding changes coefficient interpretations, but not the fitted cell-specific slopes when the model is represented consistently.
Worked Example: Two Binary Moderators
In a hypothetical analysis of 120 participants, \(X\) is weekly activity in hours, and \(Y\) is a score in points. Let \(W=1\) indicate membership in a comparison group rather than the reference group, and let \(Z=1\) indicate a second condition rather than its reference condition. Suppose the fitted estimates relevant to the \(X\)-slope are \(\hat{\beta}_1=2.00\), \(\hat{\beta}_4=-0.50\), \(\hat{\beta}_5=0.80\), and \(\hat{\beta}_7=0.60\). Find the \(X\)-slope in each group-condition cell.
For the reference group and reference condition, \((W,Z)=(0,0)\):
For the comparison group and reference condition, \((W,Z)=(1,0)\), the slope is \(2.00-0.50=1.50\) points per activity hour. For the reference group and second condition, \((W,Z)=(0,1)\), it is \(2.00+0.80=2.80\) points per hour. In the comparison group and second condition, \((W,Z)=(1,1)\):
The comparison-group minus reference-group slope difference is \(-0.50\) in the reference condition, and \(2.90-2.80=0.10\) in the second condition. The difference-in-differences is \(0.10-(-0.50)=0.60\), equal to \(\hat{\beta}_7\). In context, the estimated group difference in the activity-score slope is 0.60 points per activity hour larger in the second condition than in the reference condition. This is a comparison of slopes, not a comparison of predicted scores.
A Continuous and a Categorical Moderator
A common arrangement has one continuous moderator and one binary group indicator. With \(Z\) coded 0 or 1, the difference between the two groups’ \(X\)-slopes at a specified \(W=w\) is \(S(w,1)-S(w,0)=\beta_5+\beta_7w\). The group slope difference therefore changes with \(W\) at rate \(\beta_7\). The following calculation makes that dependence explicit.
Worked Example: Group Slope Differences at Two Moderator Values
Suppose a hypothetical fitted model uses \(X\), treatment hours, to predict \(Y\), a score in points; \(W\) is workload in units; and \(Z=1\) denotes a comparison group, with \(Z=0\) the reference group. The estimated coefficients relevant to the \(X\)-slope are \(\hat{\beta}_1=4.00\), \(\hat{\beta}_4=-0.30\), \(\hat{\beta}_5=1.10\), and \(\hat{\beta}_7=0.25\). Calculate both group slopes at \(W=2\) and \(W=6\), and compare the group differences.
At \(W=2\), the reference-group slope is
points per treatment hour. The comparison-group slope is
So the comparison-minus-reference difference at \(W=2\) is \(5.00-3.40=1.60\) points per treatment hour. At \(W=6\), the reference-group slope is \(4.00+(-0.30)(6)=2.20\), and the comparison-group slope is
The group difference at \(W=6\) is \(4.80-2.20=2.60\) points per treatment hour. It is \(2.60-1.60=1.00\) point per treatment hour larger than at \(W=2\). This also follows from \(\hat{\beta}_7(6-2)=0.25(4)=1.00\). Each slope is conditional on its stated workload and group; neither is a general slope for all participants.
Assumptions and Scope of the Calculation
The slope formulas are consequences of the stated conditional-mean model. They are appropriate when that model is the one being used: the conditional mean is represented by the included linear and product terms, and the predictors and moderators are measured and coded as specified. For the standard regression interpretation of fitted coefficients, the model’s errors are assumed to have conditional mean zero given the predictors; usual standard errors and tests additionally rely on their relevant sampling and variance assumptions. The examples calculate fitted slopes only and do not claim that any slope is statistically distinguishable from zero.
A moderator value of zero has a special role in coefficient interpretation. In an uncentered continuous model, \(\beta_1\) is the \(X\)-slope when \(W=0\) and \(Z=0\). If those values are not meaningful in the application, centering can make the corresponding reference values more interpretable. Centering changes the meanings of lower-order coefficients, but the fitted conditional slopes at a given original-variable combination remain the quantities of interest when the values are translated consistently.
Common Mistakes and Why the Distinction Matters
- Treating \(\beta_1\) as the slope everywhere. It is the slope only at \(W=0\) and \(Z=0\) for the continuous-moderator model, or in the 0-0 cell for two binary indicators. Add the applicable interaction terms for other values.
- Reading \(\beta_7\) as a conditional slope. It is not the \(X\)-slope in a particular subgroup. It describes how a slope difference changes across moderator values; with two binary indicators it is a difference-in-differences of slopes.
- Confusing slopes with predicted outcomes. A slope is a change in the model’s mean outcome per unit increase in \(X\), holding moderators fixed. A predicted outcome is the model’s mean at specified values of \(X\), \(W\), and \(Z\).
- Substituting values without checking arithmetic. Evaluate each product term, keep the signs, and subtract slopes in the stated order. A reversed subtraction reverses the interpretation of the difference.
- Turning an association into a causal claim. An interaction describes how a modeled association varies with moderator values. Causal language requires design and assumptions beyond the algebra of the regression model.
These calculations matter because a single coefficient rarely summarizes a three-way interaction well. Reporting conditional slopes and explicit slope differences at meaningful moderator combinations makes clear which comparisons are being made and in what units. If uncertainty about those slopes is at issue, it must be evaluated for the particular linear combination of coefficients; the numerical slope alone does not communicate its precision.
Check Your Understanding
Use the conditional-slope formula and show the key arithmetic for each question.
- In the continuous-moderator model, derive the \(X\)-slope at \(W=w\) and \(Z=z\) by differentiating the conditional mean with respect to \(X\).
- Suppose \(\hat{\beta}_1=1.5\), \(\hat{\beta}_4=0.2\), \(\hat{\beta}_5=-0.1\), and \(\hat{\beta}_7=0.05\). Calculate the estimated slope at \(W=4\), \(Z=2\).
- For two binary moderators, explain why the difference-in-differences of the four \(X\)-slopes equals the three-way coefficient.
- With one continuous moderator \(W\) and a binary group indicator \(Z\), write the group difference in \(X\)-slopes at \(W=w\).
- Explain why the \(X\)-slope at \(W=0,Z=0\) need not describe the slope at other moderator values.