Tutorials › Exam SRM - Statistics for Risk Modeling › Calculating Predictions from an Interaction Model

Exam SRM · Multiple Regression Estimation · Tutorial 51 of 926

Calculating Predictions from an Interaction Model

Use fitted interaction equations to calculate predictions at several predictor combinations and quantify how the interaction changes those predictions.

Intermediate 9 min read

What You'll Learn

  • Calculate fitted values from a model containing a product term
  • Keep predictor values and interaction products aligned during substitution
  • Compare predictions across combinations of two continuous predictors
  • Calculate predictions for binary-group and continuous-predictor combinations
  • Identify the interaction contribution relative to an additive model
  • Use prediction contrasts to check whether combinations show nonadditivity

Predicting from a Fitted Interaction Model

An interaction model is useful when the relationship between one predictor and the response depends on the value of another predictor. Once the equation has been fitted, calculating a prediction is a substitution task: enter the specified predictor values, calculate every product term, and evaluate the entire equation. The main challenge is not the arithmetic alone. It is making sure that each product term uses the correct predictor values and is included exactly once.

A fitted value is the model's predicted response at given predictor values. It is not necessarily the observed response of an individual or the response that will occur in a future case. The predictions in this tutorial use hypothetical fitted equations; the coefficients are supplied and are not estimated from data here.

Definition: For a fitted two-predictor interaction model $$ \widehat{Y}=\hat{\beta}_0+\hat{\beta}_1x_1+\hat{\beta}_2x_2+\hat{\beta}_3x_1x_2, $$ the predicted response at \(x_1=a\) and \(x_2=b\) is $$ \widehat{Y}(a,b)=\hat{\beta}_0+\hat{\beta}_1a+\hat{\beta}_2b+\hat{\beta}_3ab. $$ The term \(\hat{\beta}_3ab\) is the interaction contribution at that particular predictor combination.

This equation is a fitted conditional-mean model: the response is represented by the stated linear combination of predictors and their product, plus an error term with conditional mean zero. The predictor measurements and the response must use the units and coding used to fit the equation. Calculating a fitted value does not require an assumption that a particular future response will equal that value. As with other regression predictions, a result may be unreliable if the requested predictor combination is far outside the data range used to fit the model.

A Reliable Substitution Method

For each requested combination, write down the values of all predictors first. Then calculate the product term separately before substituting it. Keeping the terms visible makes it easier to catch a missing interaction or a product formed from the wrong values.

1
Record the combination.
State the value of every predictor for the case being predicted, including any indicator variable.
2
Calculate product terms.
For an \(x_1x_2\) term, calculate \(x_1x_2\) from the values recorded for this combination.
3
Substitute and evaluate.
Include the intercept, every main-effect term, and every interaction term with its fitted coefficient.
4
Check the result.
Verify the product and arithmetic, retain the response's units, and compare predictions only after evaluating each full equation.

Worked Example: Comparing Two Combinations of Continuous Predictors

A hypothetical model predicts claim-review time \(Y\), in hours, from a complexity score \(x_1\) and an examiner's experience \(x_2\), measured in years. The fitted equation is $$ \widehat{Y}=12+2.4x_1-0.5x_2-0.2x_1x_2. $$ Calculate and compare predictions for \((x_1,x_2)=(3,2)\) and \((3,6)\). Then compare the predicted change when complexity increases from 1 to 3 at each experience level.

Method. Substitute each pair into the complete equation, calculating \(x_1x_2\) separately. The common mistake to avoid is using the same interaction contribution at both experience levels just because complexity is held fixed.

For \(x_1=3\) and \(x_2=2\), the interaction product is \(3(2)=6\), so its contribution is \(-0.2(6)=-1.2\). The prediction is $$ \widehat{Y}(3,2)=12+2.4(3)-0.5(2)-0.2(6) =12+7.2-1.0-1.2=17.0\text{ hours}. $$

For \(x_1=3\) and \(x_2=6\), the product is \(3(6)=18\), and the interaction contribution is \(-0.2(18)=-3.6\). Thus $$ \widehat{Y}(3,6)=12+2.4(3)-0.5(6)-0.2(18) =12+7.2-3.0-3.6=12.6\text{ hours}. $$ The second prediction is \(17.0-12.6=4.4\) hours lower than the first.

Now compare a change in complexity from 1 to 3. At \(x_2=2\), the first prediction is $$ \widehat{Y}(1,2)=12+2.4-1.0-0.4(1)=13.0, $$ and the prediction at \(x_1=3\) is \(17.0\). The change is \(17.0-13.0=4.0\) hours. At \(x_2=6\), $$ \widehat{Y}(1,6)=12+2.4-3.0-1.2=10.2, $$ so the change to the prediction \(12.6\) is \(12.6-10.2=2.4\) hours. The model therefore predicts different complexity-associated changes at the two experience levels. The calculations check: both comparisons used a two-point increase in complexity, but the interaction products differed with \(x_2\).

Why the Interaction Produces Nonadditivity

In an additive model, the effect on the fitted value of changing \(x_1\) by a fixed amount would not depend on \(x_2\). In the interaction model, the predicted change in \(x_1\) from \(a\) to \(a+\Delta\), with \(x_2=b\) held fixed, is $$ \widehat{Y}(a+\Delta,b)-\widehat{Y}(a,b) =\Delta(\hat{\beta}_1+\hat{\beta}_3b). $$ The change depends on \(b\) whenever \(\hat{\beta}_3\ne 0\). This also gives a useful way to verify prediction comparisons.

A second check compares all four corners of a rectangle of predictor values. Let the first predictor change from \(a\) to \(a+\Delta_1\), and the second from \(b\) to \(b+\Delta_2\). The difference of differences is $$ \{\widehat{Y}(a+\Delta_1,b+\Delta_2)-\widehat{Y}(a,b+\Delta_2)\} -\{\widehat{Y}(a+\Delta_1,b)-\widehat{Y}(a,b)\} =\hat{\beta}_3\Delta_1\Delta_2. $$

To justify this identity, first consider the change in \(x_1\) at a fixed value \(x_2=b\). The intercept and the \(x_2\) main-effect term do not change. The change in the \(x_1\) main-effect term is \(\hat{\beta}_1\Delta_1\), and the change in the product term is \(\hat{\beta}_3b\Delta_1\). The total is \(\Delta_1(\hat{\beta}_1+\hat{\beta}_3b)\). At \(x_2=b+\Delta_2\), the corresponding change is \(\Delta_1\{\hat{\beta}_1+\hat{\beta}_3(b+\Delta_2)\}\). Subtracting the first change from the second cancels \(\hat{\beta}_1\) and \(\hat{\beta}_3b\), leaving \(\hat{\beta}_3\Delta_1\Delta_2\). Thus, a nonzero interaction coefficient produces a nonzero difference of differences when both changes are nonzero.

Worked Example: Checking Nonadditivity with Four Predictions

A hypothetical model predicts annual service cost \(Y\), in thousands of dollars, from a workload index \(x_1\) and a case-severity index \(x_2\): $$ \widehat{Y}=30+1.8x_1+0.6x_2+0.15x_1x_2. $$ Calculate predictions at \((2,4)\), \((6,4)\), \((2,8)\), and \((6,8)\). Use them to check the difference of differences, and compare the prediction at \((6,8)\) with the additive-only calculation.

Method. Evaluate the full model at each combination, then form the contrast from the four fitted values. The mistake to avoid is interpreting the interaction coefficient as the whole interaction contribution: at a given combination, the contribution is \(0.15x_1x_2\).

At \((2,4)\), the product is \(2(4)=8\), giving $$ \widehat{Y}(2,4)=30+1.8(2)+0.6(4)+0.15(8) =30+3.6+2.4+1.2=37.2. $$ At \((6,4)\), the product is \(6(4)=24\): $$ \widehat{Y}(6,4)=30+1.8(6)+0.6(4)+0.15(24) =30+10.8+2.4+3.6=46.8. $$ At \((2,8)\), the product is \(2(8)=16\): $$ \widehat{Y}(2,8)=30+1.8(2)+0.6(8)+0.15(16) =30+3.6+4.8+2.4=40.8. $$ At \((6,8)\), the product is \(6(8)=48\): $$ \widehat{Y}(6,8)=30+1.8(6)+0.6(8)+0.15(48) =30+10.8+4.8+7.2=52.8. $$

The predicted change in \(x_1\) from 2 to 6 is \(46.8-37.2=9.6\) when \(x_2=4\), and \(52.8-40.8=12.0\) when \(x_2=8\). Their difference is \(12.0-9.6=2.4\). The formula gives \(0.15(6-2)(8-4)=0.15(4)(4)=2.4\), so the contrast checks.

If the interaction term were wrongly omitted, the prediction at \((6,8)\) would be \(30+10.8+4.8=45.6\), rather than \(52.8\). The difference is \(7.2\), exactly the interaction contribution \(0.15(6)(8)=7.2\). All four fitted values and the difference-of-differences check are consistent.

Predictions with a Binary Predictor

A binary predictor is commonly represented by an indicator \(G\), coded 0 for one group and 1 for another. For a model with a continuous predictor \(t\), an interaction model can be written $$ \widehat{Y}=\hat{\beta}_0+\hat{\beta}_1t+\hat{\beta}_2G+\hat{\beta}_3tG. $$ For the group coded 0, both \(G\) and \(tG\) are zero. For the group coded 1, the interaction product equals \(t\). The fitted prediction must be calculated using the stated coding; changing the coding without changing the equation changes the requested substitution.

Worked Example: Predicting for Two Indicator Groups

A hypothetical training study uses a fitted equation to predict a skills score \(Y\) from practice hours \(t\) and training group \(G\), where \(G=0\) denotes the standard program and \(G=1\) denotes the workshop program: $$ \widehat{Y}=62+4.5t+7G-1.25tG. $$ Calculate predictions for both groups at \(t=4\), and for the workshop group at \(t=6\). Compare the group difference at \(t=4\) with the group difference at \(t=0\).

Method. Substitute the given \(G\) and \(t\), including their product. The common mistake is to include the group main effect \(7G\) but forget the group-by-practice interaction.

For the standard program at \(t=4\), \(G=0\), so \(tG=4(0)=0\): $$ \widehat{Y}(4,0)=62+4.5(4)+7(0)-1.25(0) =62+18+0-0=80. $$ For the workshop program at \(t=4\), \(G=1\), so \(tG=4(1)=4\): $$ \widehat{Y}(4,1)=62+4.5(4)+7(1)-1.25(4) =62+18+7-5=82. $$ The predicted workshop-minus-standard difference at four practice hours is \(82-80=2\) points.

At \(t=0\), the standard-program prediction is \(62\), and the workshop prediction is \(62+7=69\), since \(tG=0\) for both groups. The group difference is \(69-62=7\) points. Thus, the difference at four hours is not the same as the difference at zero hours. At \(t=6\) for the workshop group, \(tG=6\), and $$ \widehat{Y}(6,1)=62+4.5(6)+7-1.25(6) =62+27+7-7.5=88.5. $$ The calculations use scores in points and the specified \(G=0,1\) coding; no rounding is needed.

Common Prediction Errors

Before reporting a predicted value, check the equation term by term. These errors can change a result even when the main-effect arithmetic is correct.

  • Omitting the product term. For a model containing \(x_1x_2\), calculating only the intercept and the two main effects evaluates a different, additive model.
  • Using the coefficient as the contribution. The coefficient \(\hat{\beta}_3\) is multiplied by the product \(x_1x_2\); it is not itself the interaction contribution except when that product equals 1.
  • Using the wrong product. Calculate the product from the predictor values for the particular case, not from values in another row or comparison.
  • Ignoring indicator coding. Set the indicator to the value specified in the fitted equation before calculating any product involving it.
  • Confusing a fitted value with an observed response. The equation supplies a prediction, not a guarantee about an individual outcome.

For a quick arithmetic check, calculate the interaction contribution separately and confirm that it equals \(\hat{\beta}_3\) times the product for that case. When comparing four combinations, the difference-of-differences check can reveal an omitted or incorrectly calculated interaction term.

Key takeaway: A prediction from an interaction model requires the full fitted equation at the requested predictor combination. Calculate each product term explicitly; then compare complete fitted values to see how the interaction changes predictions across combinations.

Check Your Understanding

For each problem, calculate the requested fitted value or contrast using the complete equation.

  1. A fitted model is \(\widehat{Y}=9+2x+3z-0.5xz\). Calculate the prediction at \(x=4,z=2\). (Answer: 19)
  2. A fitted model predicts a score from practice time \(t\) and indicator \(G\), where \(G=0\) is the comparison group and \(G=1\) is the new group: \(\widehat{Y}=40+5t+8G+2tG\). At \(t=3\), calculate the new-group prediction and its difference from the comparison-group prediction. (Answer: new-group prediction \(69\); difference \(14\))
  3. For \(\widehat{Y}=20+1.5x+2z-0.25xz\), calculate the change in prediction when \(x\) increases from 2 to 6 while \(z=4\) remains fixed. (Answer: 2)
  4. A fitted model is \(\widehat{Y}=100+4a-3b+0.5ab\). Calculate the prediction at \(a=5,b=6\), including the interaction contribution. (Answer: 117, with interaction contribution 15)
  5. A fitted model is \(\widehat{Y}=15+2x+z-0.4xz\). At \(x=3,z=5\), calculate the full prediction and the additive-only value obtained by omitting the interaction. State the difference between them. (Answer: full prediction \(20\); additive-only value \(26\); full prediction is 6 lower)
Clinical Biostats