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.
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.
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\).
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.
Keep the intercept, both predictor terms, and the product term visible.
Record the selected value of each quantitative predictor and its units.
Evaluate each term, including the product term, and add the results.
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\):
The fitted mean is 49.4 exam points. For a class of 30, substitute \(x_1=4\) and \(x_2=30\):
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\).
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:
At age 60:
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:
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.
Check Your Understanding
Work through these questions using the fitted equation and predictor values given.
- 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\).
- 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\).
- 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?
- Explain why the fitted mean at a predictor profile is not necessarily the outcome for each individual at that profile.
- Why should a prediction far outside the predictor values used to fit a model be treated cautiously, even when its arithmetic is straightforward?