Why an Interaction Matters in This Example
A household’s energy use may change with outdoor temperature, but not by the same amount for every home. Insulation could make a household less sensitive to temperature changes. A regression model with a temperature-by-insulation interaction represents this possibility by allowing the temperature slope to depend on insulation rating.
This worked example uses hypothetical monthly energy data for 40 households. Its purpose is to show how to calculate and interpret predictions and slopes from an interaction model, then test whether the difference between two temperature slopes is distinguishable from zero. The calculations describe fitted associations; they do not establish that changing a home’s insulation would cause the predicted energy-use change.
Model, Variables, and Conditions
Let \(Y\) be monthly household energy use, measured in kilowatt-hours (kWh). Let \(x\) be the household’s average outdoor temperature in degrees Celsius minus \(10^\circ\text{C}\), so \(x=0\) represents an average temperature of \(10^\circ\text{C}\). Let \(z\) be an insulation rating measured in points. In this hypothetical example, the observed ranges include \(x=-5\) to \(x=5\) and insulation ratings from \(z=2\) to \(z=8\).
For the model-based calculations and the exact \(t\) inference below, assume that the conditional mean of energy use is correctly represented by this equation; errors are independent, have mean zero and constant variance, and are normally distributed; and the predictors contain enough independent variation to estimate the coefficients. The hypothetical analysis has 40 households and estimates four coefficients, giving residual degrees of freedom \(df=40-4=36\). Predictions and interpretations should stay within the observed predictor coverage rather than rely on extrapolation.
Suppose the hypothetical fitted model is \(\hat{Y}=220-8x-4z+0.50xz\). The estimated coefficients are hypothetical results, not measurements from an actual energy study. The intercept and main-effect coefficients must be interpreted with their predictor values in mind: for example, \(-8\) is the estimated temperature slope when \(z=0\), which is outside the insulation ratings observed here. The conditional slopes at observed insulation ratings are more directly relevant.
Worked Example: Predict Energy Use at Two Predictor Combinations
Worked Example: Predict Energy Use at Two Predictor Combinations
Compare fitted monthly energy use for a home at \(5^\circ\text{C}\) with insulation rating 2 and a home at the same temperature with rating 8. Since \(x\) is temperature minus \(10^\circ\text{C}\), the temperature \(5^\circ\text{C}\) corresponds to \(x=-5\).
For the rating-2 home, substitute \(x=-5\) and \(z=2\):
For the rating-8 home at the same temperature:
The fitted difference is \(208-247=-39\) kWh per month: at this temperature, the model predicts 39 kWh per month less energy use for the home with rating 8 than for the home with rating 2. This is a model-based comparison at the specified predictor values, not evidence that insulation alone caused the difference. Both values lie within the stated predictor coverage.
Conditional Slopes and the Interaction Contrast
To find the temperature slope at a particular insulation rating, hold \(z\) fixed and collect the terms involving \(x\). The fitted equation can be written as \(\hat{Y}=(220-4z)+(-8+0.50z)x\). Thus, the conditional slope for temperature is \(\hat{\beta}_1+\hat{\beta}_3z\), measured in kWh per month for a one-degree Celsius increase in average temperature. The interaction coefficient determines how much this slope changes for a one-point increase in insulation rating.
The contrast formula follows by subtracting the two conditional slopes:
This subtraction removes the common temperature component \(\hat{\beta}_1\). It leaves the part of the slope difference associated with the change in insulation rating.
Worked Example: Calculate Temperature Slopes at Two Insulation Ratings
Find the fitted temperature slopes at ratings 2 and 8, then compare them.
At rating 2, the conditional slope is
At rating 8, it is
The slope difference, rating 8 minus rating 2, is \((-4)-(-7)=3\) kWh per month per degree Celsius. Equivalently, the contrast formula gives \(0.50(8-2)=3\). Both slopes are negative, so the model predicts lower energy use as average temperature rises. The slope is less negative at rating 8: over a one-degree rise, the predicted decrease is 4 rather than 7 kWh per month.
Testing the Slope Difference
Suppose the fitted interaction coefficient has standard error \(SE(\hat{\beta}_3)=0.16\). The scientific question is whether the temperature slope at rating 8 differs from the slope at rating 2. The contrast is \(6\beta_3\), so its estimate is \(6(0.50)=3\), and its standard error is \(6(0.16)=0.96\). Multiplication by the fixed positive value 6 scales both the estimate and its standard error by 6.
The null hypothesis states that the two conditional temperature slopes are equal. The alternative states that they differ. Because the contrast is \(6\beta_3\), testing this null is equivalent to testing whether \(\beta_3=0\).
Worked Example: Test Whether the Temperature Slopes Differ
Use a two-sided test at significance level \(\alpha=0.05\). The hypotheses for the slope contrast are
The test statistic is the estimated contrast minus its null value, divided by its standard error:
Under \(H_0\) and the model conditions for the \(t\) test, the two-sided p-value is \(2P(T_{36}\geq |3.125|)\approx 0.003505\), where \(T_{36}\) has a \(t\) distribution with 36 degrees of freedom. Since \(0.003505<0.05\), reject \(H_0\). The result provides evidence that the temperature slopes differ between insulation ratings 2 and 8. It does not give the probability that \(H_0\) is true.
For a sense of estimation uncertainty, a 95% confidence interval for the slope contrast is approximately \(3\pm 2.028(0.96)\), or \((1.053,\ 4.947)\) kWh per month per degree Celsius. Under repeated sampling and the model conditions, intervals constructed by this procedure would cover the true contrast 95% of the time. This interval is wholly above zero, consistent with the test’s conclusion.
Judging the Practical Size
Statistical evidence of a nonzero interaction does not by itself tell us whether the change matters in practice. The estimated contrast is 3 kWh per month per degree Celsius across a six-point insulation difference. For a ten-degree Celsius increase within the example’s predictor range, the model’s predicted energy-use change differs by \(3\times10=30\) kWh per month between the two insulation ratings.
This 30 kWh figure concerns the difference in the two predicted changes over that temperature span; it is not the predicted energy use of either home, nor is it the difference between the homes’ energy use at a single temperature. The confidence interval for the slope contrast corresponds, over ten degrees, to a difference in changes from about \(10.53\) to \(49.47\) kWh per month. Whether this range is practically important depends on the relevant household energy scale, costs, and decision context.
Worked Example: Translate the Contrast Into a Temperature-Range Change
Consider the change from \(5^\circ\text{C}\) to \(15^\circ\text{C}\), so \(x\) changes from \(-5\) to \(5\), a ten-degree increase. At rating 2, the fitted slope is \(-7\), so the predicted change is \((-7)(10)=-70\) kWh per month. At rating 8, the slope is \(-4\), so the predicted change is \((-4)(10)=-40\) kWh per month.
The difference between those changes is \((-40)-(-70)=30\) kWh per month. This agrees with the interaction contrast calculation \(3(10)=30\). In this model, energy use is predicted to fall across that temperature increase for both homes, with a smaller predicted fall for the higher-rated home. These are fitted comparisons over a temperature interval covered by the example, not causal effects.
Common Pitfalls
- Reading a main-effect coefficient as an unconditional slope. The coefficient \(-8\) is the temperature slope at \(z=0\), not at every insulation rating. Use \(-8+0.50z\) for a stated rating.
- Reversing the contrast order. Rating 8 minus rating 2 gives \(+3\); rating 2 minus rating 8 gives \(-3\). State the order before interpreting the sign.
- Confusing the p-value with practical importance. The p-value evaluates the data’s compatibility with a zero contrast under the null model. It does not determine whether 3 kWh per month per degree is important in a particular decision.
- Claiming a causal insulation effect from fitted predictions. A regression association alone does not rule out other differences between households that may be related to insulation rating and energy use.
- Extrapolating the fitted lines. The model describes the predictor combinations represented in the data most reliably. A calculation far beyond observed temperatures or insulation ratings may be misleading.
Check Your Understanding
Use the hypothetical fitted model \(\hat{Y}=220-8x-4z+0.50xz\).
- What does \(x=3\) mean in terms of average outdoor temperature?
- Calculate the fitted temperature slope at insulation rating 5, with units.
- What is the estimated rating-8 minus rating-2 temperature-slope contrast?
- Why does a two-sided p-value of 0.003505 not mean there is a 0.3505% probability that the null hypothesis is true?
- Explain why the predicted 30 kWh per month difference in energy-use changes over a ten-degree increase is not the predicted difference in energy use at one temperature.