Tutorials › Regression Analysis (Undergraduate) › Worked Centering Problems With Interactions

Units, Scaling, and Centering · Tutorial 171 of 991

Worked Centering Problems With Interactions

Learn to recenter both predictors in a fitted interaction model and interpret the resulting coefficients and predictions in context.

Intermediate 10 min read

What You'll Learn

  • Rewrite a two-predictor interaction model around specified reference values
  • Calculate the centered intercept, main effects, and interaction coefficient
  • Interpret main effects as conditional slopes at the reference values
  • Find conditional slopes away from the reference values
  • Calculate predictions in centered form and check them against the original model

Why Work Through Centering With an Interaction?

In a regression model with an interaction, the slope for one predictor depends on the value of the other predictor. That makes the coefficients of the original model easy to misread: each main-effect coefficient describes a slope when the other predictor equals zero. If zero is not a useful or typical value, centering both predictors at meaningful reference values can make the fitted model easier to interpret.

Centering changes the coordinates used to describe the same fitted relationship. It does not change the fitted predictions for individuals whose predictor values are unchanged. The key is to transform every coefficient, including the intercept, rather than simply changing the labels on the predictors.

Model and conditions: Suppose a fitted model for a quantitative outcome \(Y\) and two quantitative predictors \(X_1\) and \(X_2\) is $$ \hat{Y}=b_0+b_1X_1+b_2X_2+b_3X_1X_2. $$ Here \(\hat{Y}\) is the fitted outcome, and \(b_0,b_1,b_2,b_3\) are the fitted coefficients. To center at reference values \(a\) for \(X_1\) and \(c\) for \(X_2\), define \(U=X_1-a\) and \(V=X_2-c\). The calculations below require that the fitted model includes both main effects and the product \(X_1X_2\), and that the same terms are retained after centering. The resulting equation is an algebraic rewrite of this fitted model; it does not by itself establish that the model is suitable for the data or that the predictors have causal effects.

The Centering Formula

Because \(X_1=U+a\) and \(X_2=V+c\), substitute these expressions into the original equation and collect the constant, \(U\), \(V\), and \(UV\) terms. This gives the centered equation

$$ \hat{Y} = (b_0+b_1a+b_2c+b_3ac) +(b_1+b_3c)U +(b_2+b_3a)V +b_3UV. $$

The centered intercept is the fitted outcome at \(X_1=a\) and \(X_2=c\), since those reference values make \(U=V=0\). The coefficient of \(U\) is the slope for \(X_1\) when \(X_2=c\); the coefficient of \(V\) is the slope for \(X_2\) when \(X_1=a\). The interaction coefficient stays \(b_3\). Its presence means the slope for either predictor changes as the other predictor changes.

Interpretation rule: In the centered model, each main-effect coefficient is a conditional slope evaluated at the other predictor's centering value. It is not an average slope across all values of the other predictor. The intercept is the fitted outcome at the pair of centering values, not necessarily the mean outcome.

Worked Examples

Worked Example: Centering at Two Meaningful Reference Values

Suppose a hypothetical model predicts a machine's output, in output units, from operating time \(X_1\), measured in hours, and temperature \(X_2\), measured in degrees. Its fitted equation is

$$ \hat{Y}=40+3X_1+2X_2+0.5X_1X_2. $$

Recenter operating time at 5 hours and temperature at 7 degrees. Define \(U=X_1-5\) and \(V=X_2-7\). The model includes both main effects and their product, as required for the centering formula. No residual assumption is needed for this algebraic transformation.

The centered intercept is

$$ b_0'=40+(3)(5)+(2)(7)+(0.5)(5)(7) =40+15+14+17.5=86.5. $$

The coefficient of \(U\) is \(3+(0.5)(7)=6.5\), and the coefficient of \(V\) is \(2+(0.5)(5)=4.5\). The interaction coefficient remains \(0.5\). Thus,

$$ \hat{Y}=86.5+6.5U+4.5V+0.5UV. $$

At 5 hours and 7 degrees, the fitted output is 86.5 output units. At 7 degrees, one additional hour of operating time corresponds to a fitted increase of 6.5 output units; at 5 hours, one additional degree corresponds to a fitted increase of 4.5 output units. These are conditional slopes at the stated reference values, not claims that either change causes an output change.

For a machine running 7 hours at 9 degrees, \(U=7-5=2\) and \(V=9-7=2\). The centered prediction is

$$ \hat{Y}=86.5+(6.5)(2)+(4.5)(2)+(0.5)(2)(2) =86.5+13+9+2=110.5. $$

As a check, the original equation gives \(40+(3)(7)+(2)(9)+(0.5)(7)(9)=40+21+18+31.5=110.5\) output units. The agreement confirms that centering has preserved this prediction.

Worked Example: Finding a Conditional Slope Away From the Reference Values

A hypothetical model predicts a process's output, in units, from input amount \(X_1\) and ambient temperature \(X_2\), with both predictors measured in their stated units:

$$ \hat{Y}=120+4X_1-3X_2+0.2X_1X_2. $$

Recenter at \(X_1=10\) and \(X_2=15\), defining \(U=X_1-10\) and \(V=X_2-15\). The original model has the two main effects and their product, so the exact centering formula applies.

The intercept is \(120+(4)(10)-(3)(15)+(0.2)(10)(15)=120+40-45+30=145\). The coefficient of \(U\) is \(4+(0.2)(15)=7\). The coefficient of \(V\) is \(-3+(0.2)(10)=-1\), and the interaction coefficient remains \(0.2\). Therefore,

$$ \hat{Y}=145+7U-V+0.2UV. $$

At \(X_2=15\), the fitted slope for \(X_1\) is 7 output units per input unit. At \(X_1=10\), the fitted slope for \(X_2\) is \(-1\) output unit per temperature unit. The negative coefficient of \(V\) does not say that the slope for temperature is negative at every input amount.

For example, at \(X_2=12\), the slope for \(X_1\) is \(4+(0.2)(12)=6.4\) output units per input unit. In centered coordinates, \(V=12-15=-3\), so the same slope is \(7+(0.2)(-3)=6.4\). Both calculations agree. The interaction coefficient indicates that the slope for \(X_1\) changes by \(0.2\) output units per input unit for each one-unit increase in \(X_2\).

To predict output at \(X_1=14\) and \(X_2=12\), use \(U=4\) and \(V=-3\):

$$ \hat{Y}=145+(7)(4)-(-3)+(0.2)(4)(-3) =145+28+3-2.4=173.6. $$

In the original equation, the prediction is \(120+(4)(14)-(3)(12)+(0.2)(14)(12)=120+56-36+33.6=173.6\) output units. The centered and original forms again produce the same fitted value.

Worked Example: Choosing Reference Values and Checking Each Coefficient

Consider a hypothetical model for a device's response, in response units, with \(X_1\) measured in minutes and \(X_2\) in degrees:

$$ \hat{Y}=18-2X_1+5X_2-0.4X_1X_2. $$

Center at \(X_1=3\) minutes and \(X_2=4\) degrees. Set \(U=X_1-3\) and \(V=X_2-4\). This fitted equation contains the required main effects and interaction; we can therefore transform its coefficients without refitting.

The intercept is \(18+(-2)(3)+(5)(4)+(-0.4)(3)(4)=18-6+20-4.8=27.2\) response units. The \(U\) coefficient is \(-2+(-0.4)(4)=-3.6\) response units per minute. The \(V\) coefficient is \(5+(-0.4)(3)=3.8\) response units per degree. The \(UV\) coefficient remains \(-0.4\). Thus,

$$ \hat{Y}=27.2-3.6U+3.8V-0.4UV. $$

At the reference temperature of 4 degrees, one additional minute corresponds to a fitted decrease of 3.6 response units. At the reference time of 3 minutes, one additional degree corresponds to a fitted increase of 3.8 response units. The interaction is negative, so the slope for time becomes more negative as temperature increases.

At \(X_1=5\) minutes and \(X_2=6\) degrees, \(U=2\) and \(V=2\). The centered prediction is \(27.2-(3.6)(2)+(3.8)(2)-(0.4)(2)(2)=27.2-7.2+7.6-1.6=26.0\) response units. The original equation gives \(18-(2)(5)+(5)(6)-(0.4)(5)(6)=18-10+30-12=26.0\) response units.

Why the Transformation Works

The coefficient changes follow directly from substitution. Starting with \(X_1=U+a\) and \(X_2=V+c\), expand the product:

$$ X_1X_2=(U+a)(V+c)=UV+cU+aV+ac. $$

Substituting both predictors and this product into the original fitted equation gives

$$ \begin{aligned} \hat{Y} &=b_0+b_1(U+a)+b_2(V+c)+b_3(UV+cU+aV+ac)\\ &=(b_0+b_1a+b_2c+b_3ac) +(b_1+b_3c)U+(b_2+b_3a)V+b_3UV. \end{aligned} $$

The terms in the second line are exactly the constant, \(U\), \(V\), and \(UV\) terms. This also shows why the interaction coefficient stays unchanged: the coefficient multiplying \(UV\) is still \(b_3\). Since \(U=X_1-a\) and \(V=X_2-c\), each original pair of predictor values maps to a corresponding centered pair. Substitution reverses exactly, so the fitted value at every pair of predictor values is unchanged.

Common Mistakes and Practical Checks

A common mistake is to treat centering as if it changed only the intercept. For an interaction model, centering also changes both main-effect coefficients. For instance, the centered slope for \(X_1\) includes \(b_3c\), so it depends on the reference value chosen for \(X_2\). Leaving the main effects untouched would not be an algebraically equivalent model.

Another mistake is to interpret a main-effect coefficient as an unconditional slope. In the centered model, the \(U\) coefficient is specifically the slope for \(X_1\) when \(X_2=c\); the \(V\) coefficient is the slope for \(X_2\) when \(X_1=a\). Away from those reference values, calculate the conditional slope from the relevant main effect plus the interaction contribution. Keep the predictor units in the interpretation: the slope for \(X_1\), for example, is measured in outcome units per \(X_1\) unit.

Before reporting a centered interaction model, check that the reference values are stated, that the intercept matches the fitted outcome at those values, and that the interaction term is retained. Then choose any convenient predictor pair and verify that the centered equation and the original equation give the same prediction. These checks catch sign errors, especially when a centered value lies below its reference and \(U\) or \(V\) is negative.

Key takeaway: Centering an interaction model changes the intercept and both main effects according to the selected reference values, while leaving the interaction coefficient and all fitted predictions unchanged. The centered main effects are conditional slopes at the reference values.

Check Your Understanding

Use the centering formula and interpret each result in the units of the situation.

  1. For \(\hat{Y}=10+2X_1+X_2+0.5X_1X_2\), write the equation centered at \(X_1=4\) and \(X_2=2\).
  2. In the centered equation from Question 1, what does the coefficient of \(U\) represent?
  3. For \(\hat{Y}=8+3X_1-2X_2-0.25X_1X_2\), find the slope for \(X_1\) when \(X_2=6\).
  4. Explain why the coefficient of \(UV\) is unchanged when both predictors are centered.
  5. At \(X_1=a\) and \(X_2=c\), what fitted value does the centered intercept represent?