Tutorials › Regression Analysis (Undergraduate) › Conditional Means Under Quantitative Interactions

Predictions for Conditional Means · Tutorial 699 of 991

Conditional Means Under Quantitative Interactions

Use a product-term regression equation to calculate fitted means at chosen predictor values and describe how the conditional relationship changes.

Beginner 9 min read

What You'll Learn

  • Identify the product term in a model with two quantitative predictors
  • Calculate a fitted mean by substituting both predictor values
  • Rewrite the model to show the conditional relationship at a fixed predictor value
  • Calculate how the conditional slope changes as the other predictor changes
  • Interpret model-based predictions with their units and limits

Why a Product Term Changes a Prediction

A regression equation with two quantitative predictors can include a product term to represent an interaction. With an interaction, the fitted relationship between one predictor and the outcome depends on the value of the other predictor. A single coefficient for the first predictor is therefore not its slope at every possible value of the second.

The practical task is to calculate the fitted mean at a specified pair of predictor values. This requires substituting both values into the whole equation, including the product term. The examples below also show how to compare the fitted relationship at different values of the second predictor.

Definition: A two-predictor linear model with a quantitative interaction has conditional mean \(E(Y\mid x_1,x_2)=\beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_1x_2\). The term \(\beta_3x_1x_2\) is the product term. Given fitted coefficients \(b_0,b_1,b_2,b_3\), the fitted conditional mean at \(x_1\) and \(x_2\) is \(\hat{y}=b_0+b_1x_1+b_2x_2+b_3x_1x_2\).

Here \(Y\) is the outcome, \(x_1\) and \(x_2\) are specified predictor values, and \(\beta_0,\beta_1,\beta_2,\beta_3\) are population model coefficients. The lower-case \(b\) coefficients are the estimates used in a fitted equation. The fitted mean \(\hat{y}\) is the model's predicted average outcome for cases with that predictor profile; it is not a prediction of the exact outcome for every individual with that profile.

How to Read the Conditional Relationship

To understand what the product term does, hold \(x_2\) fixed and collect the terms involving \(x_1\). The equation becomes \(\hat{y}=(b_0+b_2x_2)+(b_1+b_3x_2)x_1\). At that fixed value of \(x_2\), the fitted relationship in \(x_1\) is a straight line: its intercept is \(b_0+b_2x_2\), and its slope is \(b_1+b_3x_2\). Thus, changing \(x_2\) can change both the line's intercept and its slope.

The coefficient \(b_1\) alone is the fitted slope for \(x_1\) specifically when \(x_2=0\), because \(b_1+b_3(0)=b_1\). Similarly, \(b_2\) is the fitted slope for \(x_2\) when \(x_1=0\). If zero is not a meaningful or observed value, these individual coefficients may not describe a practically important profile. The equation can still be used at other specified values, provided those values are appropriate for the fitted model.

$$ \hat{y}=(b_0+b_2x_2)+(b_1+b_3x_2)x_1 $$

The conditional slope can also be understood through a finite change. At a fixed \(x_2\), increasing \(x_1\) by \(\Delta x_1\) changes the fitted mean by \((b_1+b_3x_2)\Delta x_1\). This follows because the conditional line has slope \(b_1+b_3x_2\). The interaction coefficient \(b_3\) determines how much that slope changes for a one-unit increase in \(x_2\).

$$ \begin{aligned} \hat{y}(x_1+\Delta x_1,x_2)-\hat{y}(x_1,x_2) &= (b_1+b_3x_2)\Delta x_1 \end{aligned} $$

Calculating a Fitted Mean

Before substituting values, identify the outcome and the units of each predictor. Then use the fitted equation as written: calculate the product \(x_1x_2\), multiply it by \(b_3\), and include that term along with the intercept and both main-effect terms. The result is a fitted mean in the units of the outcome.

1
Write the fitted equation.
Keep the intercept, both predictor terms, and the product term visible.
2
State the profile.
Record the selected value of each quantitative predictor and its units.
3
Substitute and calculate.
Evaluate each term, including the product term, and add the results.
4
Interpret in context.
Report the model-based fitted mean for that profile, in outcome units, without treating it as a causal effect.

Worked Example: Exam Score at Two Class Sizes

Suppose a hypothetical model predicts exam score in points (\(Y\)) from weekly study hours (\(x_1\)) and class size in students (\(x_2\)). Its fitted equation is \(\hat{y}=42+5.2x_1-0.35x_2-0.08x_1x_2\). For illustration, suppose the model was fitted to classes with sizes from 15 to 35 students and study times from 0 to 8 hours, and model checks were considered adequate for using this equation over those ranges. Calculate fitted means for a student studying 4 hours in classes of 20 and 30 students.

For a class of 20, substitute \(x_1=4\) and \(x_2=20\):

$$ \begin{aligned} \hat{y} &=42+5.2(4)-0.35(20)-0.08(4)(20)\\ &=42+20.8-7.0-6.4\\ &=49.4 \end{aligned} $$

The fitted mean is 49.4 exam points. For a class of 30, substitute \(x_1=4\) and \(x_2=30\):

$$ \begin{aligned} \hat{y} &=42+5.2(4)-0.35(30)-0.08(4)(30)\\ &=42+20.8-10.5-9.6\\ &=42.7 \end{aligned} $$

At 4 study hours, the model's fitted mean is 6.7 points lower for a class of 30 than for a class of 20. This is a comparison of fitted means for two profiles, not a claim that changing a student's class size would cause that score difference.

The conditional slope for study hours is \(5.2-0.08x_2\). It is \(5.2-0.08(20)=3.6\) fitted exam points per additional study hour at class size 20, and \(5.2-0.08(30)=2.8\) points per hour at class size 30. The negative product coefficient means that, in this fitted model, the study-hours slope decreases as class size increases.

Deriving and Using the Conditional Slope

The slope formula is obtained directly by grouping the terms in the fitted equation. This algebra is useful because it shows exactly what changes when the value of \(x_2\) changes; it does not require a separate regression fit at every value of \(x_2\).

Derivation: Start with \(\hat{y}=b_0+b_1x_1+b_2x_2+b_3x_1x_2\). Hold \(x_2\) fixed and group the terms without \(x_1\) and the terms multiplied by \(x_1\): \[ \hat{y}=b_0+b_2x_2+(b_1+b_3x_2)x_1. \] This has the form of a straight line in \(x_1\), with slope \(b_1+b_3x_2\). If \(x_2\) increases by one unit, the slope changes from \(b_1+b_3x_2\) to \(b_1+b_3(x_2+1)\). Their difference is \(b_3\), so \(b_3\) is the change in the fitted \(x_1\)-slope per one-unit increase in \(x_2\).

Worked Example: Exercise and Age

Consider a hypothetical fitted model for resting heart rate in beats per minute, with weekly exercise hours \(x_1\) and age \(x_2\) in years: \(\hat{y}=78-1.1x_1+0.25x_2+0.015x_1x_2\). Suppose the model was fitted over exercise values from 0 to 6 hours per week and ages from 25 to 65 years, with checks supporting use of the equation in that range. Calculate the fitted mean for 3 exercise hours at ages 40 and 60.

At age 40:

$$ \begin{aligned} \hat{y} &=78-1.1(3)+0.25(40)+0.015(3)(40)\\ &=78-3.3+10+1.8\\ &=86.5\text{ beats per minute} \end{aligned} $$

At age 60:

$$ \begin{aligned} \hat{y} &=78-1.1(3)+0.25(60)+0.015(3)(60)\\ &=78-3.3+15+2.7\\ &=92.4\text{ beats per minute} \end{aligned} $$

The fitted means differ by 5.9 beats per minute for these two profiles. The model's conditional slope for exercise is \(-1.1+0.015x_2\) beats per minute per additional weekly exercise hour. At age 40, it is \(-1.1+0.015(40)=-0.5\); at age 60, it is \(-1.1+0.015(60)=-0.2\). Thus, the fitted association between exercise hours and resting heart rate is less negative at age 60 than at age 40. These fitted associations alone do not establish that exercise causes a change in heart rate.

Checking a Prediction at a Specific Profile

The product term must be evaluated using the same predictor values as the other terms. A useful check is to calculate the conditional intercept and slope at the selected \(x_2\), then evaluate that line at \(x_1\). The two approaches must give the same fitted mean.

Worked Example: Cross-Checking an Energy-Use Prediction

Suppose a hypothetical model predicts daily energy use in kilowatt-hours from outdoor temperature \(x_1\) in degrees Celsius and occupancy \(x_2\), measured as the number of people present: \(\hat{y}=120-2.4x_1-3x_2+0.05x_1x_2\). Assume the data covered temperatures from 10 to 30 degrees Celsius and occupancy from 1 to 8 people, and the fitted equation is being used within those ranges. Find the fitted mean at 24 degrees and 6 people.

Direct substitution gives:

$$ \begin{aligned} \hat{y} &=120-2.4(24)-3(6)+0.05(24)(6)\\ &=120-57.6-18+7.2\\ &=51.6\text{ kWh per day} \end{aligned} $$

For a check, hold occupancy at 6. The conditional intercept is \(120-3(6)=102\), and the conditional slope for temperature is \(-2.4+0.05(6)=-2.1\) kilowatt-hours per day per degree Celsius. Evaluating this line at 24 degrees gives \(102-2.1(24)=51.6\) kilowatt-hours per day, the same result.

The \(0.05\) product coefficient means that the fitted temperature slope increases by 0.05 kilowatt-hours per day per degree Celsius for each additional person present. The slope at six people is still negative, \(-2.1\); the positive interaction coefficient does not by itself mean that the fitted outcome increases with temperature.

Model Conditions and Common Pitfalls

The arithmetic for a fitted mean is valid once a fitted equation and a predictor profile are given. Interpreting it as a reasonable estimate of a conditional mean also depends on the model being appropriate for that profile. In particular, the product-term equation assumes that the conditional mean has the stated form over the predictor region in use. A numerical prediction far beyond the values represented in the data may be unreliable, even though substitution produces an answer.

The model's usual regression conditions concern whether the conditional-mean form and error assumptions are adequate for the intended analysis. For calculating the fitted value itself, the key points are that the coefficients belong to the stated fitted model and that the selected predictor values are meaningful and within a region where that model can reasonably be used. The equation describes conditional means; it does not turn an observational association into a causal effect.

  • Omitting the product term. The term \(b_3x_1x_2\) is part of the fitted equation and must be included when calculating \(\hat{y}\).
  • Interpreting \(b_1\) as a universal slope. With an interaction, the slope for \(x_1\) is \(b_1+b_3x_2\), not simply \(b_1\) at every \(x_2\).
  • Assuming a positive interaction means a positive slope. The interaction coefficient describes how a slope changes; the slope itself also depends on the corresponding main-effect coefficient and the selected predictor value.
  • Calling a fitted mean an individual outcome. \(\hat{y}\) is a model-based mean for a predictor profile, not a guarantee that every individual at that profile has that outcome.
  • Extrapolating without warning. Substitution is possible outside the observed predictor range, but the model's form may not remain useful there.
Key takeaway: For a quantitative interaction, calculate a fitted mean by substituting both predictor values into every term, including their product. At fixed \(x_2\), the fitted slope for \(x_1\) is \(b_1+b_3x_2\); the interaction coefficient describes how that conditional slope changes as \(x_2\) changes.

Check Your Understanding

Work through these questions using the fitted equation and predictor values given.

  1. For \(\hat{y}=10+2x_1-0.5x_2+0.1x_1x_2\), calculate the fitted mean at \(x_1=3\) and \(x_2=4\).
  2. For that same equation, what is the fitted slope for \(x_1\) when \(x_2=4\)? Include the slope's expression in terms of \(x_2\).
  3. If \(b_3\) is negative, what does that say about how the fitted \(x_1\)-slope changes as \(x_2\) increases? Does it alone determine whether the slope is positive or negative?
  4. Explain why the fitted mean at a predictor profile is not necessarily the outcome for each individual at that profile.
  5. Why should a prediction far outside the predictor values used to fit a model be treated cautiously, even when its arithmetic is straightforward?