Introduction
A fitted regression equation can be used to calculate an outcome prediction for a particular combination of predictor values. When the equation includes a product term, the calculation must include that term for each specified pair. Omitting it changes the prediction, sometimes substantially.
This tutorial focuses on evaluating the equation and comparing the resulting predictions. A numerical prediction is an output of the fitted equation for the inputs supplied; it is not, by itself, evidence that a predictor caused an outcome to change.
The Fitted Interaction Equation
For two quantitative predictors \(X_1\) and \(X_2\), an interaction regression model with a product term can be written as
Here, \(Y_i\) is the outcome for observation \(i\), \(X_{1i}\) and \(X_{2i}\) are that observation's predictor values, the \(\beta\) terms are model coefficients, and \(\varepsilon_i\) is the error. After fitting the model, the estimated coefficients are used to form the fitted equation:
The lower-case \(x_1\) and \(x_2\) denote the particular predictor values at which a prediction is requested. The \(b\) terms are the estimated coefficients from the fitted model. To calculate a fitted outcome, use the same predictor units and coefficient values as in that fitted equation, multiply the two predictor values to form \(x_1x_2\), and evaluate the whole expression.
The model's mean structure and error assumption explain why the fitted equation represents an outcome prediction. The model specifies a mean that has the displayed product-term form, with the error having conditional mean zero. In fitting and using a regression model, observations are also ordinarily treated as independent; more detailed distributional assumptions are relevant to inference, but are not needed simply to substitute values into an already fitted equation.
Replacing the unknown coefficients in this conditional mean with their fitted estimates gives \(\hat{y}\). Thus, the plug-in calculation estimates a mean outcome at the supplied pair. It does not remove the natural variation of individual outcomes around that mean.
A Reliable Calculation Procedure
Before doing the arithmetic, write down the exact predictor pair and the fitted equation. Then calculate the product term separately, substitute every term with its sign, and simplify. When comparing two pairs, calculate each fitted outcome independently before subtracting or describing the difference. This makes it easier to catch mistakes such as carrying the product from one pair into another.
Write the values of \(x_1\) and \(x_2\), with their units, in the order used by the equation.
Find \(x_1x_2\) using the two values for this prediction.
Include the intercept, both individual predictor terms, and the product term, preserving coefficient signs.
Simplify the arithmetic, retain sensible precision, and state the predicted outcome and its units.
State which specified combination has the larger fitted outcome and give the difference in outcome units.
Worked Predictions
Worked Example: Comparing Two Predictor Pairs
Suppose a hypothetical training program has been summarized by the fitted equation below. The outcome is a recovery score in points, \(x_1\) is weekly training hours, and \(x_2\) is a baseline symptom score in points. Calculate and compare the fitted outcomes at \((x_1,x_2)=(2,4)\) and \((5,4)\).
For the first pair, the product is \(2(4)=8\). Substitution gives
For the second pair, the product is \(5(4)=20\). Therefore,
The fitted outcome at \((5,4)\) is \(72-57.6=14.4\) points higher than the fitted outcome at \((2,4)\). This comparison is specific to these two predictor pairs and this fitted equation. It does not say that every person who trains for three additional hours will gain 14.4 points.
Worked Example: Checking Signs and the Product Term
In a hypothetical task study, \(Y\) is the number of errors, \(x_1\) is practice time in hours, and \(x_2\) is a fatigue score in points. The fitted equation is
Calculate the fitted number of errors for the pairs \((4,3)\) and \((4,8)\). For \((4,3)\), the product is \(4(3)=12\), so
For \((4,8)\), the product is \(4(8)=32\), and
The fitted outcome at \((4,8)\) is \(2.0\) errors higher than at \((4,3)\). Both fitted values are mean predictions, so a fractional value such as 7.2 is not an arithmetic error: a fitted mean need not be a whole-number count. Notice also that the product term is negative in both calculations. Dropping its minus sign would yield a different fitted outcome.
Worked Example: Comparing Combinations That Differ in Both Predictors
Suppose a hypothetical assessment model predicts a score in points from study hours \(x_1\) and a preparation rating \(x_2\), measured in rating points. Its fitted equation is
Compare the fitted scores at \((2,2)\) and \((6,5)\). At the first pair, \(x_1x_2=2(2)=4\), giving
At the second pair, \(x_1x_2=6(5)=30\), so
The fitted outcome for \((6,5)\) is \(74-39=35\) points higher than for \((2,2)\). Since both predictor values differ between the pairs, this calculation compares the two combinations as wholes. It does not isolate the contribution of either predictor.
Why the Product Must Be Recalculated
The product term is part of the equation, so it must be evaluated at the same predictor pair as the other terms. For example, in the task-study equation, the pair \((4,3)\) has product \(12\), whereas \((4,8)\) has product \(32\). Using 12 in both predictions would not evaluate the stated equation at \((4,8)\).
A short justification also clarifies what the calculation does and does not deliver. Under the model's conditional-mean assumption, the error contributes zero to the mean outcome at fixed predictor values. Consequently, the model's mean at a pair is its intercept and predictor terms evaluated at that pair. The fitted prediction follows by using estimated rather than unknown coefficients:
This is a fitted mean, not an exact prediction of an individual's observed response. In the model, an observed response also contains an error term:
The equation above expresses the distinction informally: an observed value can differ from its fitted value. The difference for a particular observation is called its residual, \(e_i=y_i-\hat{y}_i\). Knowing \(\hat{y}\) alone does not determine that residual or the individual outcome.
Units, Range, and Interpretation
The fitted outcome is reported in the units of \(Y\). Predictor values must be entered in the units used to fit the equation: if \(x_1\) was recorded in hours, substitute hours rather than minutes unless the equation has been converted accordingly. The product \(x_1x_2\) has the combined units of the two predictors, and its coefficient makes the product term compatible with the outcome units.
A calculation can be arithmetically correct yet give a prediction that should be treated cautiously. In particular, check whether the requested pair is within the range of predictor combinations represented by the data used to fit the model. A prediction far outside those combinations is an extrapolation: the equation supplies a number, but the data may provide little support for the model's behavior there. Also check that the combination is meaningful in context. For example, a mathematical pair of predictor values may not be possible for the people or objects being studied.
The calculation itself does not establish that the model fits well, that the product-term form is appropriate, or that a difference between fitted outcomes is causal. Those are separate questions about model adequacy and study design. For the task here, report the supplied equation's fitted outcomes accurately and describe comparisons as comparisons between those predictions.
Common Mistakes
- Leaving out the product term. The wrong reasoning is to use only the intercept and the two separate predictor terms. The correction is to calculate \(x_1x_2\) for every pair and include \(b_3x_1x_2\).
- Using the wrong product for a pair. A product calculated for one row cannot be reused for another pair unless it happens to have the same value. Recalculate it each time.
- Losing a negative sign. Keep the coefficient sign attached to its term during substitution; for example, \(-0.10(32)=-3.2\), not \(+3.2\).
- Calling a fitted mean an individual's certain outcome. A prediction of 7.2 errors is a model-based mean, not a claim that a particular person will make exactly 7.2 errors.
- Attributing a combined comparison to one predictor. If both coordinates of the compared pairs differ, the difference in fitted outcomes compares both combinations, not the isolated effect of either predictor.
- Ignoring the observed range. Substitution is possible for any numerical pair, but predictions outside the data's supported range may be unreliable.
Check Your Understanding
Use the fitted equation and show the product-term arithmetic in each calculation.
- For \(\hat{y}=10+2x_1+3x_2+0.5x_1x_2\), calculate the fitted outcome at \((x_1,x_2)=(2,4)\).
- Using the same equation, calculate the fitted outcomes at \((1,3)\) and \((3,3)\). Which is higher, and by how much?
- Why can a fitted outcome for a count response be fractional?
- What does it mean if a requested predictor pair is outside the range of combinations represented in the fitting data?
- Two predictor pairs differ in both coordinates. What can be concluded from subtracting their fitted outcomes, and what cannot be isolated from that subtraction alone?