Tutorials › Regression Analysis (Undergraduate) › Deriving the Coefficient Changes in a Centered Interaction

Units, Scaling, and Centering · Tutorial 163 of 991

Deriving the Coefficient Changes in a Centered Interaction

See how centering both predictors changes three coefficients in an interaction model while leaving its fitted predictions and interaction coefficient unchanged.

Intermediate 9 min read

What You'll Learn

  • Write a two-predictor regression model that includes an interaction term.
  • Expand the model after shifting both predictors by chosen constants.
  • Calculate the transformed intercept and main-effect coefficients.
  • Explain algebraically why the interaction coefficient does not change.
  • Check that original and centered equations give the same fitted value.
  • Recover original coefficients from centered coefficients.

Why Derive the Coefficient Changes?

Centering predictors means subtracting chosen constants from their values. In a model with an interaction, changing the reference points of both predictors changes more than the intercept: it also changes each main-effect coefficient. The interaction coefficient, however, remains the same. These changes can be derived directly by expanding the model, rather than memorized as separate rules.

The distinction matters because the centered and uncentered equations are two ways to write the same fitted relationship. If their coefficients are compared without accounting for the shifts, it can look as though the fitted model itself has changed. The derivation below shows exactly which coefficients change and why.

Model and Centering Notation

Consider two quantitative predictors, \(X_1\) and \(X_2\), and an outcome \(Y\). The model includes both predictors, their product, and an error term:

$$ Y=\beta_0+\beta_1X_1+\beta_2X_2+\beta_3X_1X_2+\varepsilon. $$

Here, \(\beta_0\) is the intercept, \(\beta_1\) and \(\beta_2\) are the main-effect coefficients, \(\beta_3\) is the interaction coefficient, and \(\varepsilon\) is the error. For interpreting the equation as a model for the conditional mean, assume \(E(\varepsilon\mid X_1,X_2)=0\). The algebraic result about coefficient changes does not require errors to be normally distributed or to have constant variance.

Choose centering constants \(c_1\) and \(c_2\), expressed in the same units as \(X_1\) and \(X_2\). Define the centered predictors \(Z_1=X_1-c_1\) and \(Z_2=X_2-c_2\). Thus, \(X_1=Z_1+c_1\) and \(X_2=Z_2+c_2\). The centered interaction model uses the product \(Z_1Z_2\), along with both centered predictors:

$$ Y=\gamma_0+\gamma_1Z_1+\gamma_2Z_2+\gamma_3Z_1Z_2+\varepsilon. $$
Definition: The centered coefficients \(\gamma_0,\gamma_1,\gamma_2,\gamma_3\) are the coefficients obtained when the same interaction model is expressed using \(Z_1=X_1-c_1\) and \(Z_2=X_2-c_2\). The centering constants specify the shifts; they do not remove either predictor or the interaction term.

Deriving the Transformation

Substitute \(X_1=Z_1+c_1\) and \(X_2=Z_2+c_2\) into the original equation. In particular, expand the product as well as the two main-effect terms:

$$ \begin{aligned} Y &=\beta_0+\beta_1(Z_1+c_1)+\beta_2(Z_2+c_2) +\beta_3(Z_1+c_1)(Z_2+c_2)+\varepsilon\\ &=\beta_0+\beta_1Z_1+\beta_1c_1+\beta_2Z_2+\beta_2c_2\\ &\quad+\beta_3Z_1Z_2+\beta_3c_2Z_1+\beta_3c_1Z_2 +\beta_3c_1c_2+\varepsilon. \end{aligned} $$

Now collect terms according to whether they are constant, multiply \(Z_1\), multiply \(Z_2\), or multiply \(Z_1Z_2\). Matching the resulting equation to the centered model gives:

$$ \begin{aligned} \gamma_0&=\beta_0+\beta_1c_1+\beta_2c_2+\beta_3c_1c_2,\\ \gamma_1&=\beta_1+\beta_3c_2,\\ \gamma_2&=\beta_2+\beta_3c_1,\\ \gamma_3&=\beta_3. \end{aligned} $$

The intercept collects every term that has no centered predictor in it. The coefficient of \(Z_1\) collects the original \(X_1\) coefficient and the \(Z_1\) term created when the interaction is expanded; the \(Z_2\) coefficient changes for the corresponding reason. The coefficient of \(Z_1Z_2\) has no additional terms to collect, so it remains \(\beta_3\).

Key result: When both predictors are shifted and the model retains both main effects and their product, \(\gamma_0=\beta_0+\beta_1c_1+\beta_2c_2+\beta_3c_1c_2\), \(\gamma_1=\beta_1+\beta_3c_2\), \(\gamma_2=\beta_2+\beta_3c_1\), and \(\gamma_3=\beta_3\).

Worked Transformations

Worked Example: Shifting Both Predictors by Fixed Amounts

Suppose a hypothetical fitted model, with \(Y\) measured in points, is

$$ \hat{Y}=12+1.5X_1-2X_2+0.4X_1X_2. $$

Here, \(X_1\) is measured in hours and \(X_2\) in units. Center \(X_1\) at 3 hours and \(X_2\) at 5 units, so \(c_1=3\), \(c_2=5\), \(Z_1=X_1-3\), and \(Z_2=X_2-5\).

Apply the intercept formula:

$$ \gamma_0=12+(1.5)(3)+(-2)(5)+(0.4)(3)(5) =12+4.5-10+6=12.5. $$

The coefficient of \(Z_1\) is \(\gamma_1=1.5+(0.4)(5)=3.5\). The coefficient of \(Z_2\) is \(\gamma_2=-2+(0.4)(3)=-0.8\). Finally, \(\gamma_3=0.4\). The centered fitted equation is therefore

$$ \hat{Y}=12.5+3.5Z_1-0.8Z_2+0.4Z_1Z_2. $$

Check the equations at \(X_1=4\) hours and \(X_2=7\) units. The original equation gives \(12+(1.5)(4)-2(7)+(0.4)(4)(7)=15.2\) points. At these values, \(Z_1=1\) and \(Z_2=2\), so the centered equation gives \(12.5+(3.5)(1)-(0.8)(2)+(0.4)(1)(2)=15.2\) points. The fitted value is unchanged.

Worked Example: Centering at Two Sample Means

Suppose a hypothetical regression fitted to a set of observations has the equation

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

Suppose the sample means of the predictors are 8 and 30 in their respective units, and the goal is to center at these values. Set \(c_1=8\) and \(c_2=30\). The transformed intercept is

$$ \gamma_0=40+(2)(8)+(0.5)(30)+(-0.1)(8)(30) =40+16+15-24=47. $$

The two transformed main-effect coefficients are

$$ \begin{aligned} \gamma_1&=2+(-0.1)(30)=2-3=-1,\\ \gamma_2&=0.5+(-0.1)(8)=0.5-0.8=-0.3. \end{aligned} $$

The interaction coefficient remains \(\gamma_3=-0.1\). With \(Z_1=X_1-8\) and \(Z_2=X_2-30\), the new equation is \(\hat{Y}=47-Z_1-0.3Z_2-0.1Z_1Z_2\).

As a check, take \(X_1=10\) and \(X_2=40\), giving \(Z_1=2\) and \(Z_2=10\). The original equation gives \(40+20+20-40=40\). The centered equation gives \(47-2-3-2=40\). Both equations predict 40 outcome units at this pair of predictor values.

Worked Example: Recovering the Original Coefficients

Suppose a centered model, with predictors \(Z_1=X_1-2\) and \(Z_2=X_2-6\), is

$$ \hat{Y}=18+4Z_1-Z_2+0.25Z_1Z_2. $$

The interaction coefficient is unchanged by centering, so \(\beta_3=\gamma_3=0.25\). Rearranging the main-effect formulas gives \(\beta_1=\gamma_1-\gamma_3c_2\) and \(\beta_2=\gamma_2-\gamma_3c_1\). Substitution gives

$$ \begin{aligned} \beta_1&=4-(0.25)(6)=2.5,\\ \beta_2&=-1-(0.25)(2)=-1.5. \end{aligned} $$

To recover the original intercept, rearrange the intercept formula:

$$ \begin{aligned} \beta_0 &=\gamma_0-\beta_1c_1-\beta_2c_2-\beta_3c_1c_2\\ &=18-(2.5)(2)-(-1.5)(6)-(0.25)(2)(6)\\ &=18-5+9-3=19. \end{aligned} $$

Thus, the original equation is \(\hat{Y}=19+2.5X_1-1.5X_2+0.25X_1X_2\). At \(X_1=3\) and \(X_2=8\), the centered model gives \(18+(4)(1)-2+(0.25)(1)(2)=20.5\); the original gives \(19+(2.5)(3)-(1.5)(8)+(0.25)(3)(8)=20.5\). This check confirms the reverse transformation.

Why the Fitted Model Is Preserved

The derivation is an identity: replacing \(X_1\) and \(X_2\) by \(Z_1+c_1\) and \(Z_2+c_2\) and collecting terms does not change the value of the model equation for any observation. Consequently, the original and centered equations give identical fitted values when their coefficients are related by the formulas above.

The same point applies when the coefficients are estimated by least squares. If a model includes the intercept, both main effects, and the interaction, shifting predictors only rewrites the same collection of possible fitted values. The fitted values therefore stay the same. With a full-rank design, the coefficient representation is unique and the transformed coefficients follow the formulas directly. If the design is not full rank, coefficients may not be unique, although the algebraic re-expression of a given equation still holds.

The result depends on retaining all four terms in the model. For example, omitting a main effect while keeping the interaction changes the model specification; one cannot assume the same coefficient transformation applies to that reduced model. The equation’s terms must be checked before using the formulas.

Common Mistakes

  • Assuming centering changes only the intercept. The product expansion creates an extra \(Z_1\) term involving \(c_2\) and an extra \(Z_2\) term involving \(c_1\). Include these contributions in both main-effect coefficients.
  • Changing the interaction coefficient. When both predictors are shifted, the coefficient multiplying \(Z_1Z_2\) is still \(\beta_3\). Other parts of the product expansion contribute to the intercept or main effects, not to another \(Z_1Z_2\) term.
  • Using the wrong centering constant. The \(Z_1\) coefficient uses \(c_2\), while the \(Z_2\) coefficient uses \(c_1\). This follows from expanding the product, not from matching each predictor to its own constant.
  • Forgetting units. Each centering constant must be measured in the units of the predictor it shifts. A constant measured in hours cannot be subtracted from a predictor recorded in days unless the units are first made consistent.
Key takeaway: Expand the interaction after writing each original predictor as its centered version plus its centering constant. Collect the constant, single-predictor, and product terms. This gives the new intercept and main effects while showing directly that the interaction coefficient is unchanged.

Check Your Understanding

Use the coefficient formulas and the expansion in this tutorial to answer the questions.

  1. For a model with coefficients \(\beta_0,\beta_1,\beta_2,\beta_3\), which centering constant appears in the formula for \(\gamma_1\), and why?
  2. If \(\beta_3=0\), what do the transformation formulas imply about \(\gamma_1\) and \(\gamma_2\) after centering?
  3. A researcher centers \(X_1\) at \(c_1\) and \(X_2\) at \(c_2\). Write the formula for the transformed intercept.
  4. Why does the coefficient of \(Z_1Z_2\) remain equal to the original interaction coefficient?
  5. What must be checked about the model terms before applying the formulas to a fitted regression?