From an Interaction Model to a Predicted Outcome
An interaction model describes how the conditional mean of an outcome depends on predictor values, including how the association with one predictor may change across values of another. Once the model has been fitted, a practical question is often much more specific: what fitted outcome corresponds to this combination of predictor values? That combination is called a predictor profile.
Evaluating the model at a profile is a matter of careful substitution. The important details are to use the model’s actual coding, include every relevant interaction term, and keep the result distinct from an observed individual outcome. This tutorial focuses on calculating fitted conditional means, not on testing or comparing them.
The Model and Its Assumptions
For a quantitative predictor \(x\) and a binary categorical predictor \(G\), coded as 0 for the reference group and 1 for the other group, a linear interaction model is
Here \(Y_i\) is the outcome for observation \(i\), and \(\varepsilon_i\) is the part of that outcome not represented by the model’s conditional mean. The model assumes that, at each predictor profile, the conditional mean has the stated form and that \(E(\varepsilon_i\mid x_i,G_i)=0\). Consequently,
After fitting the model, the coefficients are replaced by their estimates. The fitted conditional mean at \(x=x_0\) and \(G=g_0\) is therefore
This calculation presumes that the model is an appropriate description of the conditional mean and that the predictor values have been coded as specified. To interpret a fitted value as relevant to the data, the profile should also be represented by the data used to fit the model. Substituting values outside the observed range still produces a number, but the model may not describe that region reliably.
The formula gives a fitted mean, not a guarantee about any one observation. An individual outcome may differ from the fitted mean because of its residual variation. The arithmetic of evaluating the fitted mean does not require adding an error term, and it does not by itself give a confidence or prediction interval.
Worked Example: A Quantitative Predictor and a Binary Group
Suppose a hypothetical fitted model relates a symptom score \(Y\), measured in points, to treatment dose \(x\), measured in milligrams. The group indicator \(G\) is 0 for the reference group and 1 for the other group. Assume the fitted equation is
Calculate the fitted conditional mean for a dose of 10 mg in the group coded \(G=1\). The profile is \(x=10\), \(G=1\), so the product term is \(xG=10(1)=10\). Substitution gives
The fitted conditional mean is 9 symptom-score points for this profile. This is a model-based mean, not a claim that every individual in the group at this dose has a score of 9. The calculation assumes that the fitted interaction equation is suitable at 10 mg and that the group has been coded as stated. If 10 mg is far beyond the doses represented in the fitting data, the numerical result may be an unreliable extrapolation.
Substituting Profiles with Centered Predictors
A quantitative predictor may be centered before fitting a model. If \(x_c=x-c\), where \(c\) is a chosen reference value, then a profile stated in the original units must first be converted to \(x_c\). The model is evaluated using the centered value because that is the variable appearing in its equation. Centering changes the meaning of some coefficients, but it does not prevent calculation of the fitted mean.
For two quantitative predictors, an interaction model can include their product. For example,
The product term must be calculated from the predictor values used in the model. In particular, if the predictors are centered, multiply the centered values, not the original values.
Worked Example: Two Centered Quantitative Predictors
Consider a hypothetical model for a quiz score \(Y\), measured in points, using weekly study hours \(x\) and tutoring sessions per week \(z\). The predictors are centered at 5 study hours and 2 tutoring sessions: \(x_c=x-5\) and \(z_c=z-2\). Suppose the fitted equation is
Find the fitted conditional mean for a student profile with 7 study hours and 3 tutoring sessions per week. Convert each original value to the model’s centered scale:
The interaction term at this profile is \(x_cz_c=2(1)=2\). Substituting the centered values,
The fitted conditional mean is 77 quiz-score points at the stated profile. The intercept 70 is the fitted mean at the centering values \(x=5\) and \(z=2\), because both centered predictors are then zero. This interpretation follows directly from substituting \(x_c=z_c=0\) into the equation. The result is relevant as an in-range fitted mean only if the study-hour and tutoring-session values are adequately represented in the data and the specified linear interaction is appropriate.
Including More Than Two Categorical Levels
For a categorical predictor with more than two levels, a common approach is to choose one level as the reference and create an indicator for each other level. In an interaction model, each non-reference level can have both an indicator term and an interaction with a quantitative predictor. To evaluate a profile, set the indicator for its category to 1 and the other category indicators to 0. This coding rule applies to the interaction terms as well.
Worked Example: A Quantitative Predictor and Three Categories
Suppose a hypothetical model predicts a performance score \(Y\), in points, from weekly practice sessions \(x\) and program category. Category A is the reference; \(I_B=1\) for category B and \(I_C=1\) for category C, with both indicators 0 for category A. The fitted equation is
Find the fitted conditional mean for a profile in category C with 6 practice sessions per week. Category C has \(I_C=1\) and \(I_B=0\), and the product terms are \(xI_B=6(0)=0\) and \(xI_C=6(1)=6\). Therefore,
The fitted conditional mean is 28.8 performance-score points for category C at 6 practice sessions per week. Setting \(I_B=0\) matters: including the category B terms would describe a different profile. As in the previous examples, the calculation assumes the chosen category coding and an appropriate fitted model; 6 sessions should also be within a range supported by the data for category C.
Why Substitution Works
The fitted conditional mean is obtained by evaluating the model’s conditional-mean expression at the requested values. For the binary interaction model, the conditional-mean assumption states
At a specified profile \((x_0,g_0)\), replacing the predictor values gives the mean for that profile. Replacing the unknown coefficients by their fitted estimates gives the fitted conditional mean:
Thus each term has a direct role: the intercept, the contributions associated with the predictor values, and the contribution from their product. Omitting the product term would evaluate a different model, not a simplified way to evaluate the same interaction model.
Common Mistakes and a Reliable Procedure
A frequent mistake is to treat a fitted conditional mean as the observed or guaranteed outcome for an individual. The fitted value represents the model’s mean at the profile; individual outcomes can vary around it. Another mistake is to substitute the correct predictor values but omit an interaction term, or to use original values in a model fitted with centered predictors. Either error changes the calculation.
A useful check is to write down the profile in the same coding as the fitted equation before substituting anything. Then calculate each product term explicitly. This helps catch errors such as assigning both category indicators the value 1 when the model uses mutually exclusive category indicators.
Keep all main-effect and interaction terms shown in the model.
Center quantitative predictors if the equation uses centered values, and set categorical indicators according to their definitions.
Multiply the predictor values that actually appear in that interaction term.
Show the arithmetic, report the fitted mean with its outcome units, and identify the profile to which it applies.
Always report the result in context. A bare value such as 28.8 does not say what outcome is measured, in what units, or for which predictor profile. Also check whether the profile is supported by the data: evaluating the equation is straightforward, but a fitted value far outside the observed predictor region may be scientifically unhelpful.
Check Your Understanding
Use the fitted equations and show the substitutions needed for each answer.
- For \(\widehat{Y}=8+2x-G+0.5xG\), calculate the fitted conditional mean at \(x=4\) and \(G=1\).
- A model uses \(x_c=x-10\) and \(z_c=z-3\). At the original profile \(x=12\), \(z=5\), what values should be substituted for \(x_c\) and \(z_c\)?
- In a model with category A as the reference, \(I_B=1\) for B and \(I_C=1\) for C. What indicator values describe a category A profile? What values describe category C?
- Explain why a fitted conditional mean at a profile is not necessarily the outcome observed for an individual with that profile.
- Why should a fitted value calculated for predictor values well outside the data’s observed range be interpreted cautiously?