Introduction
A student who begins a course well prepared may gain exam points from additional study at a different rate than a student who begins less prepared. A regression model with an interaction can represent this possibility: instead of requiring one study-time slope for everyone, it allows the expected change in exam score per study hour to depend on prior preparation.
The example below uses hypothetical data for 30 students. It shows how to fit and interpret a study-time-by-prior-preparation interaction, test the product term, and draw fitted relationships. The results describe associations in the hypothetical data; by themselves, they do not establish that studying or prior preparation caused the score differences.
The Model and Its Assumptions
Centering gives the coefficients useful reference points: \(T_i=0\) means 5 study hours, and \(P_i=0\) means a prior-preparation score of 6. In particular, \(b_1\) is the estimated study-time slope at preparation score 6, not a universal slope. The model also includes both lower-order terms, \(T_i\) and \(P_i\), along with their product.
For the usual regression-based tests and standard errors, assume the conditional mean has the stated linear form; errors are independent, have mean zero and constant variance; and the errors are normally distributed for exact small-sample \(t\) inference. The predictors must also provide enough variation to estimate the coefficients separately. Before interpreting fitted lines, check that the displayed combinations of study time and preparation are represented by the data rather than being unsupported extrapolations.
Worked Example: Fitting and Reading the Coefficients
Suppose the hypothetical sample consists of 30 different students, with exam scores from 0 to 100 points, study times from 2 to 8 hours, and prior-preparation scores from 4 to 8. Assume students' errors can reasonably be treated as independent, and that residual checks show no evident curvature or change in spread; assume also that the residual distribution is adequate for the \(t\) procedures used below. A fitted model gives these estimates:
| Term | Estimate | Standard error |
|---|---|---|
| Intercept \(b_0\) | 72.00 | 1.20 |
| Study time \(b_1\) | 2.40 | 0.45 |
| Prior preparation \(b_2\) | 1.10 | 0.38 |
| Study time × prior preparation \(b_3\) | 0.090 | 0.030 |
The fitted equation is
At the reference values of 5 study hours and a preparation score of 6, both centered predictors equal zero. The predicted score is therefore 72 points. At preparation score 6, the study-time slope is \(b_1=2.40\): the fitted mean exam score increases by 2.40 points per additional study hour, at that preparation level. At 5 study hours, the preparation slope is \(b_2=1.10\) points per preparation-score point.
The product coefficient says how the study-time slope changes as preparation changes. For each one-point increase in the preparation score, the fitted study-time slope increases by 0.090 exam-score points per study hour. This is a slope change, not the entire study-time effect and not the predicted score for a student.
Deriving and Calculating Conditional Slopes
To find the study-time slope at a particular preparation level, hold \(P\) fixed and collect the terms involving \(T\). This gives a fitted line for that preparation value:
Thus the conditional study-time slope is \(b_1+b_3P\). Its standard error depends on the uncertainty in both coefficient estimates and on their covariance:
This formula follows from the variance of a sum: for estimates \(b_1\) and \(b_3\), the variance of \(b_1+Pb_3\) is \(\operatorname{Var}(b_1)+P^2\operatorname{Var}(b_3)+2P\operatorname{Cov}(b_1,b_3)\). Taking the square root gives its standard error. The covariance term matters because coefficient estimates from the same fitted model need not be independent.
Worked Example: Study-Time Slopes at Two Preparation Scores
Find the fitted study-time slopes at preparation scores 4 and 8. Suppose the fitted coefficient covariance is \(\operatorname{Cov}(b_1,b_3)=-0.0020\), in the corresponding coefficient units.
At preparation score 4, \(P=4-6=-2\). The conditional slope is
The fitted mean score increases by 2.22 points per additional study hour at preparation score 4. Its standard error is
At preparation score 8, \(P=8-6=2\), so the slope is
points per study hour. Its standard error is
The point estimates differ by \(2.58-2.22=0.36\) exam-score points per study hour. That is also \(0.090\) points per hour for each one-point difference in preparation, multiplied by the four-point preparation contrast.
Testing the Product Term
To test whether the study-time slope changes with preparation, test \(H_0:\beta_3=0\) against \(H_a:\beta_3\ne0\). If \(\beta_3=0\), the fitted study-time slope is the same at every preparation level. For this single coefficient, the test statistic is the estimate divided by its standard error; under the stated assumptions, it follows a \(t\) distribution under \(H_0\), with residual degrees of freedom \(df=n-4\). There are four estimated coefficients, so here \(df=30-4=26\).
Worked Example: Testing Whether the Interaction Is Present
For the product term, the estimate is \(b_3=0.090\) and its standard error is 0.030. The test statistic is
The two-sided \(p\)-value is approximately 0.005885. At significance level \(\alpha=0.05\), \(0.0058<0.05\), so reject \(H_0\). Under the model assumptions, these hypothetical data provide evidence that the study-time slope differs across prior-preparation levels. The estimated interaction is positive: higher preparation is associated with a steeper fitted study-time slope. The test does not show that preparation causes the slope change, nor does it establish that the change is important in practice.
Plotting the Fitted Relationships
For a plot, choose preparation values that are meaningful and supported by the observed data, then calculate the fitted line at each value. At preparation score 4, \(P=-2\), so the model becomes \(\widehat{Y}=69.8+2.22T\). At preparation score 8, \(P=2\), it becomes \(\widehat{Y}=74.2+2.58T\). The intercepts in these expressions are fitted scores at 5 study hours, because \(T=0\) there.
Worked Example: Calculating Points for Two Fitted Lines
Calculate fitted scores at 2, 5, and 8 study hours for preparation scores 4 and 8. At 2 hours, \(T=2-5=-3\); at 5 hours, \(T=0\); and at 8 hours, \(T=3\).
| Study time | Preparation score 4: \(69.8+2.22T\) | Preparation score 8: \(74.2+2.58T\) |
|---|---|---|
| 2 hours (\(T=-3\)) | \(69.8+2.22(-3)=63.14\) points | \(74.2+2.58(-3)=66.46\) points |
| 5 hours (\(T=0\)) | \(69.8+2.22(0)=69.80\) points | \(74.2+2.58(0)=74.20\) points |
| 8 hours (\(T=3\)) | \(69.8+2.22(3)=76.46\) points | \(74.2+2.58(3)=81.94\) points |
Plot each set of points and connect them with a straight line. The lines are not parallel because their slopes, 2.22 and 2.58 points per hour, differ. The fitted difference between the preparation-score-8 and preparation-score-4 lines is 3.32 points at 2 study hours, 4.40 points at 5 hours, and 5.48 points at 8 hours. Those differences grow with study time in this fitted model because the interaction is positive.
Before drawing or interpreting the lines, compare their predictor values with the observed data. For this hypothetical illustration, suppose the scatterplot shows data near preparation scores 4 and 8 across the displayed 2-to-8-hour study-time range. These lines then summarize fitted relationships within the observed coverage. If the data did not include comparable students across that range, extending both lines over the full range would be extrapolation and could be misleading.
Common Mistakes and Why the Interaction Matters
- Calling \(b_1\) the study-time slope for everyone. It is the slope only when \(P=0\), which here means preparation score 6. At another preparation score, use \(b_1+b_3P\).
- Interpreting \(b_3\) as the score increase per study hour. The interaction coefficient is the change in the study-time slope per one-point increase in preparation. The conditional slope itself is \(b_1+b_3P\).
- Ignoring coefficient covariance in a conditional-slope standard error. The variance formula includes \(2P\operatorname{Cov}(b_1,b_3)\); dropping this term generally changes the result.
- Concluding that the interaction proves a causal effect. The fitted model describes an association. A causal claim needs suitable study design and assumptions, not just a small \(p\)-value.
- Drawing fitted lines beyond the data's predictor coverage. A line can be calculated there, but its interpretation relies on an unsupported extension of the fitted relationship.
An interaction is useful when a single additive description would hide meaningful changes in a relationship. Reporting conditional slopes and plotting fitted lines makes the pattern interpretable; stating the reference values, units, and observed coverage prevents the product coefficient from being read in isolation.
Check Your Understanding
Use the model and hypothetical results above to answer these questions.
- At which prior-preparation score does \(b_1=2.40\) directly represent the study-time slope?
- Calculate the fitted study-time slope at preparation score 7.
- In words and units, interpret the interaction estimate of 0.090.
- What does the test of \(H_0:\beta_3=0\) conclude at \(\alpha=0.05\), and what does it not establish?
- Why should the fitted lines at preparation scores 4 and 8 be checked against the observed predictor coverage before interpretation?