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:
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:
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:
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:
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\).
Worked Transformations
Worked Example: Shifting Both Predictors by Fixed Amounts
Suppose a hypothetical fitted model, with \(Y\) measured in points, is
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:
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
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
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
The two transformed main-effect coefficients are
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
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
To recover the original intercept, rearrange the intercept formula:
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.
Check Your Understanding
Use the coefficient formulas and the expansion in this tutorial to answer the questions.
- 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?
- If \(\beta_3=0\), what do the transformation formulas imply about \(\gamma_1\) and \(\gamma_2\) after centering?
- A researcher centers \(X_1\) at \(c_1\) and \(X_2\) at \(c_2\). Write the formula for the transformed intercept.
- Why does the coefficient of \(Z_1Z_2\) remain equal to the original interaction coefficient?
- What must be checked about the model terms before applying the formulas to a fitted regression?