Tutorials › Regression Analysis (Undergraduate) › Derive the Conditional Slope of One Predictor

Quantitative Predictor Interactions · Tutorial 323 of 991

Derive the Conditional Slope of One Predictor

Learn how differentiation turns a two-predictor interaction equation into the fitted slope for one predictor at a specified value of the other.

Intermediate 10 min read

What You'll Learn

  • Write the product-term regression model for two quantitative predictors.
  • Differentiate its fitted mean with respect to one predictor while holding the other fixed.
  • Identify which terms contribute to the conditional slope and why.
  • Substitute a specified value of the other predictor into the slope formula.
  • Interpret the resulting slope with the correct outcome and predictor units.
  • Distinguish a fitted-mean slope from the change in an individual observed outcome.

Why a Predictor’s Slope Can Depend on Another Predictor

In a regression model with two quantitative predictors and their product, the fitted relationship between the outcome and one predictor is not necessarily the same at every value of the other predictor. A useful way to express that relationship is to find the slope of the fitted mean with respect to the predictor of interest, while holding the other predictor fixed.

This is a derivative of the model’s fitted mean, not a claim that changing a predictor causes an outcome to change. The derivative describes the model’s fitted association at a specified value of the other predictor. To interpret it well, identify which predictor is being varied, which is being held fixed, and the units of all three variables.

The Model and the Conditional Slope

Let \(Y\) be a quantitative outcome, and let \(x\) and \(z\) be two quantitative predictors. The product-term model for the conditional mean is

$$ E(Y\mid x,z)=\beta_0+\beta_1x+\beta_2z+\beta_3xz. $$

Here \(\beta_0,\beta_1,\beta_2,\beta_3\) are model parameters. In a fitted model, the estimated conditional mean is

$$ \widehat{E}(Y\mid x,z)=\hat{\beta}_0+\hat{\beta}_1x+\hat{\beta}_2z+\hat{\beta}_3xz. $$

The conditional mean is the model’s mean outcome at specified predictor values. The fitted conditional mean is its estimate, calculated using estimated coefficients. For the rest of this tutorial, “fitted mean” refers to this estimated quantity unless stated otherwise.

Definition: The conditional slope of \(x\) at \(z=z_0\) is the derivative of the fitted mean with respect to \(x\), evaluated while \(z\) is held fixed at \(z_0\). It describes the fitted change in mean outcome per unit of \(x\) at that value of \(z\).

The model is a statement about the conditional mean. A standard regression formulation writes \(Y_i\) as this mean plus an error, with errors having conditional mean zero: \(E(\varepsilon_i\mid x_i,z_i)=0\). This condition connects the regression equation to the conditional mean. Independent observations and suitable variance assumptions are relevant to standard regression inference, but normal errors are not needed for the algebraic derivative derived below.

Deriving the Conditional Slope

Differentiate the fitted mean with respect to \(x\), treating \(z\) as a constant. The intercept has derivative zero. The term \(\hat{\beta}_1x\) contributes \(\hat{\beta}_1\), and \(\hat{\beta}_2z\) contributes zero because it does not vary with \(x\). In the product term \(\hat{\beta}_3xz\), the factor \(\hat{\beta}_3z\) is constant with respect to \(x\), so the derivative is \(\hat{\beta}_3z\).

$$ \begin{aligned} \frac{\partial \widehat{E}(Y\mid x,z)}{\partial x} &=\frac{\partial}{\partial x} \left(\hat{\beta}_0+\hat{\beta}_1x+\hat{\beta}_2z+\hat{\beta}_3xz\right)\\ &=0+\hat{\beta}_1+0+\hat{\beta}_3z\\ &=\hat{\beta}_1+\hat{\beta}_3z. \end{aligned} $$

At a particular value \(z_0\), substitute that value into the derivative:

$$ \left.\frac{\partial \widehat{E}(Y\mid x,z)}{\partial x}\right|_{z=z_0} =\hat{\beta}_1+\hat{\beta}_3z_0. $$

The result does not depend on \(x\). Thus, for a fixed \(z_0\), the model’s fitted mean has a constant slope as \(x\) varies. The slope can depend on \(z_0\), because the product term contributes a quantity involving \(z_0\).

The units provide a useful check. If \(Y\) is measured in points, \(x\) in hours, and \(z\) in tutoring sessions, then \(\hat{\beta}_1\) has units of points per hour. The product coefficient \(\hat{\beta}_3\) has units of points per hour per session; multiplying it by \(z\), measured in sessions, gives points per hour. Both terms in the conditional-slope formula therefore have matching units.

Worked Examples

Worked Example: Study Hours at a Fixed Number of Tutoring Sessions

A hypothetical analysis models quiz score in points using study hours \(x\) and tutoring sessions \(z\). The fitted equation is

$$ \widehat{E}(Y\mid x,z)=42+3.2x+1.5z+0.4xz. $$

Find and interpret the fitted slope for study hours when a student has attended \(z=2\) tutoring sessions. Assume the model is being used for predictor values represented in the data.

Step 1: Differentiate with respect to study hours. Holding tutoring sessions fixed, the derivative is

$$ \frac{\partial \widehat{E}(Y\mid x,z)}{\partial x} =3.2+0.4z. $$

Step 2: Substitute the specified value.

$$ 3.2+0.4(2)=3.2+0.8=4.0. $$

At two tutoring sessions, the fitted mean quiz score has a slope of 4.0 points per additional study hour. This describes the model’s fitted mean, not the exact score change for every individual student. Study hours and tutoring sessions are the quantitative predictors in the stated model, and the interpretation holds the tutoring-session value fixed at two.

Worked Example: A Negative Conditional Slope

In a hypothetical manufacturing analysis, the outcome \(Y\) is operating lifetime in hours, \(x\) is the number of completed operating cycles in hundreds, and \(z\) is temperature in degrees Celsius. A fitted equation is

$$ \widehat{E}(Y\mid x,z)=900-18x+2z+0.6xz. $$

Find the fitted slope with respect to operating cycles when the temperature is \(z=20\) degrees Celsius.

Step 1: Differentiate with respect to \(x\). The terms involving \(x\) are \(-18x\) and \(0.6xz\), so

$$ \frac{\partial \widehat{E}(Y\mid x,z)}{\partial x} =-18+0.6z. $$

Step 2: Evaluate at 20 degrees Celsius.

$$ -18+0.6(20)=-18+12=-6. $$

At 20 degrees Celsius, the fitted mean operating lifetime has a slope of \(-6\) hours per additional hundred operating cycles. The negative sign indicates a downward fitted relationship at this temperature. It does not mean every item’s observed lifetime decreases by exactly 6 hours; observed outcomes can differ from the fitted mean.

Worked Example: Evaluating the Slope When the Other Predictor Is Negative

A hypothetical study models a quantitative performance score \(Y\) using practice hours \(x\) and a standardized fatigue measure \(z\). The fitted equation is

$$ \widehat{E}(Y\mid x,z)=70+2.5x-4z-0.3xz. $$

Find the fitted slope for practice hours when the fatigue measure is \(z=-1.5\).

Step 1: Differentiate the fitted mean with respect to practice hours.

$$ \frac{\partial \widehat{E}(Y\mid x,z)}{\partial x} =2.5-0.3z. $$

Step 2: Substitute \(z=-1.5\), preserving the sign.

$$ 2.5-0.3(-1.5)=2.5+0.45=2.95. $$

At a fatigue value of \(-1.5\), the fitted mean score has a slope of 2.95 score points per additional practice hour. The negative value of \(z\) matters in the substitution: multiplying \(-0.3\) by \(-1.5\) produces \(+0.45\). A negative predictor value is valid when it is part of the predictor’s scale; it should not be replaced by its absolute value.

A Reliable Calculation Process

For any fitted equation of this form, keep the differentiation and the contextual interpretation as separate steps. This reduces errors such as differentiating with respect to the wrong predictor or forgetting to hold the other predictor fixed.

1
Identify the predictor of interest.
For the conditional slope of \(x\), differentiate with respect to \(x\), not \(z\).
2
Hold the other predictor fixed.
During differentiation with respect to \(x\), treat \(z\) as a constant.
3
Differentiate each term.
The intercept and the term involving \(z\) alone contribute zero; the \(x\) term and the product term contribute \(\hat{\beta}_1\) and \(\hat{\beta}_3z\).
4
Substitute the requested value.
Evaluate \(\hat{\beta}_1+\hat{\beta}_3z_0\) using the given value \(z_0\), taking care with negative signs.
5
State the slope in context.
Name the fitted mean outcome, the predictor whose slope is being described, the fixed value of the other predictor, and the units.

Common Mistake: Using Only the Main-Effect Coefficient

A frequent error is to report \(\hat{\beta}_1\) as the slope of \(x\) for every value of \(z\). That omits the contribution of the product term. In the fitted model, the derivative includes both the \(x\) term and the product term:

$$ \frac{\partial \widehat{E}(Y\mid x,z)}{\partial x} =\hat{\beta}_1+\hat{\beta}_3z. $$

For example, in the quiz-score equation, reporting 3.2 points per study hour at every tutoring level would ignore \(0.4z\). At \(z=2\), the fitted slope is \(3.2+0.4(2)=4.0\), not 3.2. The coefficient \(\hat{\beta}_1\) is the formula’s value when \(z=0\); a slope at another specified \(z\) requires substitution into the full derivative.

Another mistake is to describe the derivative as the change in a particular person’s observed outcome. The derivative applies to the fitted conditional mean. Individual observations can lie above or below that mean because the regression model includes unexplained variation.

Key takeaway: In a product-term model with fitted mean \(\hat{\beta}_0+\hat{\beta}_1x+\hat{\beta}_2z+\hat{\beta}_3xz\), the conditional slope of \(x\) at \(z=z_0\) is \(\hat{\beta}_1+\hat{\beta}_3z_0\). Differentiate with respect to \(x\), hold \(z\) fixed, then interpret the result in outcome units per unit of \(x\).

Check Your Understanding

For each question, state the relevant derivative or explain the reasoning in context.

  1. For the fitted mean \(\hat{\beta}_0+5x-2z+0.7xz\), derive the conditional slope of \(x\) at \(z=z_0\).
  2. Using the equation in Question 1, calculate the fitted slope of \(x\) at \(z=3\).
  3. In a fitted model with outcome measured in kilograms, \(x\) measured in minutes, and \(z\) measured in days, what are the units of the coefficient of \(xz\)?
  4. Why does the term \(\hat{\beta}_2z\) contribute zero when differentiating the fitted mean with respect to \(x\)?
  5. Explain why the fitted slope at a specified \(z\) describes the fitted mean rather than the exact outcome change for every individual.