Tutorials › Generalized Linear Models › Centering Continuous Predictors in Interaction Models

Factors Contrasts and Interactions · Tutorial 150 of 981

Centering Continuous Predictors in Interaction Models

Learn how centering changes the reference point for main effects in an interaction model without changing its fitted linear predictors or interaction slope differences.

Intermediate 9 min read

What You'll Learn

  • Derive the coefficient transformation when a continuous predictor is centered at a chosen value
  • Interpret factor main effects as comparisons at the centering point
  • Verify that fitted linear predictors and factor-specific slopes are preserved
  • Work through Gaussian, logistic, and multi-level factor examples
  • Avoid the common error of adjusting the intercept but not the factor main effects

Why Center a Predictor in an Interaction Model?

In a factor-by-continuous interaction model, the coefficient for a factor describes a comparison at a particular value of the continuous predictor: the value coded as zero. If zero is far outside the data or has no useful scientific meaning, that comparison can be hard to interpret. Centering replaces zero with a chosen reference value, such as a clinically meaningful measurement or the sample mean.

Centering is a change of coordinates, not a change to the modeled relationship. The factor-specific slopes, their differences, and the fitted linear predictors can all be preserved. What changes is the interpretation—and numerical value—of the intercept and factor main-effect coefficients.

Coefficient Transformation

Consider a GLM with link function \(g\), where \(g(\mu_i)=\eta_i\). Let \(z_i\) be a vector of coded columns for a factor, and let \(x_i\) be a continuous predictor. A factor-by-continuous interaction model can be written as

$$ \eta_i=\alpha+z_i^{\mathsf T}\gamma+\beta x_i+z_i^{\mathsf T}\delta x_i. $$

Here \(\alpha\) is the intercept, \(\gamma\) contains factor main-effect coefficients, \(\beta\) is the continuous-predictor coefficient for the reference factor profile, and \(\delta\) contains interaction coefficients. For a binary factor under reference coding, \(z_i\) is a single indicator: it is zero for the reference group and one for the other group.

Definition: Centering \(x_i\) at a constant \(c\) means defining \(x_{c,i}=x_i-c\). The value \(c\) becomes the zero point of the centered predictor. It may be chosen for scientific interpretation or convenience; centering does not itself change the units of \(x_i\).

Since \(x_i=x_{c,i}+c\), substitution gives

$$ \eta_i=(\alpha+c\beta)+z_i^{\mathsf T}(\gamma+c\delta) +\beta x_{c,i}+z_i^{\mathsf T}\delta x_{c,i}. $$

Thus the centered coefficients are \(\alpha_c=\alpha+c\beta\), \(\gamma_c=\gamma+c\delta\), \(\beta_c=\beta\), and \(\delta_c=\delta\). In particular, the factor main-effect coefficients generally change because the factor comparison is now evaluated at \(x=c\). The interaction coefficients do not change.

Worked Example: Centering a Binary-Factor Model

Suppose a Gaussian identity-link model with binary factor \(A\) is

$$ \eta=10+4A+2x+3Ax. $$

Center \(x\) at \(c=5\), so \(x_c=x-5\) and \(x=x_c+5\). Substitution gives

$$ \eta=10+4A+2(x_c+5)+3A(x_c+5) =20+19A+2x_c+3Ax_c. $$

The intercept changes from \(10\) to \(20\). The factor coefficient changes from \(4\) to \(19=4+3(5)\). The slope coefficient \(2\) and interaction coefficient \(3\) are unchanged.

Check the fitted linear predictors at \(x=7\), for which \(x_c=2\). For \(A=0\), the original predictor is \(10+2(7)=24\), and the centered predictor is \(20+2(2)=24\). For \(A=1\), the original predictor is \(10+4+2(7)+3(7)=49\), and the centered predictor is \(20+19+2(2)+3(2)=49\).

The reference-group slope is \(2\), while the \(A=1\) slope is \(2+3=5\); their difference is \(3\). The main-effect coefficient \(19\) is the difference between the groups’ linear predictors specifically at \(x=5\), not at \(x=0\).

What the Coefficients Mean After Centering

Under reference coding, the reference group has \(z_i=0\), so its linear predictor is \(\alpha+\beta x_i\). A group represented by \(z_i\) has linear predictor \(\alpha+z_i^{\mathsf T}\gamma+(\beta+z_i^{\mathsf T}\delta)x_i\). Its slope is therefore \(\beta+z_i^{\mathsf T}\delta\), and the slope difference from the reference group is \(z_i^{\mathsf T}\delta\).

At the centering value \(x_i=c\), the difference between that group’s and the reference group’s linear predictors is \(z_i^{\mathsf T}(\gamma+c\delta)\). This is why the centered factor coefficient is \(\gamma+c\delta\): it describes the factor contrast at the chosen reference point on the linear-predictor scale. In a logistic model, for example, this is a contrast in log odds, not a constant difference in probabilities.

Worked Example: Centering in a Logistic Interaction Model

Suppose a logistic regression has the linear predictor

$$ \eta=-2+0.6A+0.4x-0.2Ax, $$

where \(A=0\) is the reference group. Center at \(c=10\), so \(x_c=x-10\). Substituting \(x=x_c+10\) yields

$$ \eta=(-2+0.4(10))+(0.6-0.2(10))A+0.4x_c-0.2Ax_c =2-1.4A+0.4x_c-0.2Ax_c. $$

The factor coefficient is now \(-1.4\), the log-odds contrast between groups at \(x=10\). For a direct check at \(x=12\), \(x_c=2\). When \(A=0\), both forms give \(\eta=-2+0.4(12)=2+0.4(2)=2.8\). When \(A=1\), both give \(\eta=-2+0.6+0.4(12)-0.2(12)=1.0\) and \(\eta=2-1.4+0.4(2)-0.2(2)=1.0\).

The corresponding probabilities are \(1/(1+e^{-2.8})\approx0.943\) for \(A=0\) and \(1/(1+e^{-1})\approx0.731\) for \(A=1\). The reference-group slope on the log-odds scale is \(0.4\); the other group’s is \(0.4-0.2=0.2\). The slope difference, \(-0.2\), is unchanged by centering.

Why the Fitted Linear Predictors Are Preserved

Result: For any fixed centering constant \(c\), the centered model has exactly the same linear predictor for every observation as the uncentered model when its coefficients are transformed as \(\alpha_c=\alpha+c\beta\), \(\gamma_c=\gamma+c\delta\), \(\beta_c=\beta\), and \(\delta_c=\delta\).

Proof. By definition, \(x_i=x_{c,i}+c\). Substituting this identity into the original predictor and collecting terms gives

$$ \begin{aligned} \eta_i &=\alpha+z_i^{\mathsf T}\gamma+\beta(x_{c,i}+c) +z_i^{\mathsf T}\delta(x_{c,i}+c)\\ &=(\alpha+c\beta)+z_i^{\mathsf T}(\gamma+c\delta) +\beta x_{c,i}+z_i^{\mathsf T}\delta x_{c,i}. \end{aligned} $$

The final expression is precisely the centered model with the stated transformed coefficients. It equals the original \(\eta_i\) for each observation. Therefore the model’s implied mean, as specified by its link, is also unchanged. The transformation is reversible: \(\alpha=\alpha_c-c\beta_c\) and \(\gamma=\gamma_c-c\delta_c\), while \(\beta=\beta_c\) and \(\delta=\delta_c\). Thus centering re-expresses the same linear predictors rather than restricting the model. \(\square\)

This equality also explains why fitting the same GLM with \(x\) or \(x_c\) gives the same attainable fitted linear predictors, provided the model includes the same factor terms and interactions and the coefficient space is unrestricted. The statement is about reparameterization; it does not assert that numerical algorithms must follow identical computational paths.

Result: Centering leaves each factor-specific slope and every difference between such slopes unchanged.

Derivation. For factor code \(z\), the coefficient of \(x_i\) in its linear predictor is \(\beta+z^{\mathsf T}\delta\). After centering, the coefficient of \(x_{c,i}\) is \(\beta_c+z^{\mathsf T}\delta_c=\beta+z^{\mathsf T}\delta\). For two factor profiles \(z_a\) and \(z_b\), their slope difference is

$$ (\beta+z_a^{\mathsf T}\delta)-(\beta+z_b^{\mathsf T}\delta) =(z_a-z_b)^{\mathsf T}\delta. $$

The centered model has the same expression because \(\delta_c=\delta\). Hence both slopes and their difference are preserved. \(\square\)

Worked Example: A Three-Level Factor

Let \(A\) be the reference level and let \(B\) and \(C\) be indicator variables for the other two levels. Suppose

$$ \eta=1+0.5B-1C+2x+0.3Bx-0.4Cx. $$

Center at \(c=4\), giving \(x_c=x-4\). The transformed coefficients are: intercept \(1+2(4)=9\); \(B\) main effect \(0.5+0.3(4)=1.7\); \(C\) main effect \(-1-0.4(4)=-2.6\). The continuous slope coefficient remains \(2\), and the interaction coefficients remain \(0.3\) and \(-0.4\). Thus

$$ \eta=9+1.7B-2.6C+2x_c+0.3Bx_c-0.4Cx_c. $$

The slopes for levels \(A\), \(B\), and \(C\) are \(2\), \(2+0.3=2.3\), and \(2-0.4=1.6\), respectively. Their differences from \(A\) remain \(0.3\) and \(-0.4\). To check a fitted value, take level \(C\) at \(x=5\), so \(C=1\) and \(x_c=1\). The original predictor is \(1-1+2(5)-0.4(5)=8\); the centered predictor is \(9-2.6+2(1)-0.4(1)=8\).

Common Mistake and Practical Use

A frequent error is to update only the intercept when centering, while leaving the factor main-effect coefficients unchanged. That misses the contribution of the interaction at the new zero point. In the binary-factor example, changing the intercept from \(10\) to \(20\) but keeping the factor coefficient at \(4\) would claim that the groups differ by \(4\) at \(x=5\). The actual difference there is \(4+3(5)=19\). The correct centered factor coefficient must include the interaction coefficient multiplied by the centering constant.

Centering is useful when zero is not a meaningful predictor value, when a comparison at a scientifically relevant value is desired, or when a predictor’s numerical scale makes the intercept difficult to read. It does not remove the interaction, change the link, or make the factor contrast constant across values of \(x\). It simply states the main effects at a different reference value.

Key takeaway: Centering \(x\) at \(c\) shifts the intercept by \(c\beta\) and the factor main-effect vector by \(c\delta\). It leaves the continuous slope and interaction coefficients—and therefore fitted linear predictors and factor slope differences—unchanged.

Check Your Understanding

Use the coefficient transformation and verify your conclusions on the linear-predictor scale.

  1. For \(\eta=3+2A+5x-Ax\), center \(x\) at \(c=2\). What are the centered coefficients?
  2. In a factor-by-continuous interaction model, what contrast does the factor main-effect coefficient represent after centering at \(c\)?
  3. Does centering change the difference between the continuous slopes in two factor groups? Explain using the interaction coefficient.
  4. For the model \(\eta=-1+0.4B+2x+0.5Bx\), center at \(c=3\). Calculate the centered intercept and \(B\) main-effect coefficient.
  5. Why is it incorrect to adjust the intercept but leave the factor main effect unchanged when centering a predictor in an interaction model?
Clinical Biostats