Tutorials › Generalized Linear Mixed Models (GLMM) › Centering Predictors in Random-Slope Models in GLMMs

Random Intercepts and Slopes · Tutorial 53 of 698

Centering Predictors in Random-Slope Models in GLMMs

Learn how shifting a predictor’s origin transforms the fixed and random intercepts, changes their covariance structure, and leaves fitted cluster-specific trajectories unchanged.

Intermediate 10 min read

What You'll Learn

  • Derive the fixed- and random-effect transformations when a predictor is centered at a constant value.
  • Calculate the resulting intercept variance and intercept-slope covariance.
  • Verify that cluster-specific linear predictors and conditional responses are unchanged.
  • Recognize why a zero-covariance restriction may depend on the predictor’s origin.
  • Distinguish a change of origin from rescaling a predictor or centering it within groups.

Why the Predictor’s Origin Matters

In a random-slope GLMM, the random intercept describes a cluster’s deviation from the population linear predictor at the predictor’s value zero. If zero is far outside the observed range or has no useful meaning, that intercept can be difficult to interpret. Subtracting a constant from the predictor changes the point represented by zero. This is a change of parameterization, not a change to the cluster-specific fitted trajectory—provided the intercept, slope, and their covariance are transformed together.

The transformation matters because an intercept at the new origin combines the old intercept and a portion of the old random slope. As a result, the random-intercept variance and intercept-slope covariance generally change. The random-slope variance does not change when only the origin is shifted.

Definition: For cluster \(j\) and observation \(i\), consider the random-intercept, random-slope GLMM $$ g\{E(Y_{ij}\mid b_{0j},b_{1j})\} =\beta_0+\beta_1x_{ij}+b_{0j}+b_{1j}x_{ij}, \qquad \begin{pmatrix}b_{0j}\\b_{1j}\end{pmatrix} \sim N\left( \begin{pmatrix}0\\0\end{pmatrix}, \begin{pmatrix}\tau_{00}&\tau_{01}\\\tau_{01}&\tau_{11}\end{pmatrix} \right). $$ Here \(g\) is the link function, \(x_{ij}\) is the predictor, \(\beta_0\) and \(\beta_1\) are fixed effects, and \(b_{0j}\) and \(b_{1j}\) are cluster-specific random effects. For a fixed constant \(c\), define the centered predictor \(x_{ij}^{*}=x_{ij}-c\). Centering transforms the intercepts and covariance parameters so the linear predictor for every observation and cluster remains the same.

Assume the conditional response distribution and link remain unchanged; the linear predictor contains the stated intercept and slope terms; and the random effects have mean zero with the stated covariance matrix. The same fixed constant \(c\) is subtracted for every observation and cluster. The covariance matrix must be positive semidefinite, as required for a valid random-effects distribution. Under these assumptions, the transformation is exact. It does not depend on whether the response is binary, a count, or continuous.

Deriving the Transformation

Since \(x_{ij}=x_{ij}^{*}+c\), substitute this expression into the original linear predictor and collect the terms multiplying the new predictor and the terms that do not depend on it.

$$ \begin{aligned} \eta_{ij} &=\beta_0+\beta_1(x_{ij}^{*}+c)+b_{0j}+b_{1j}(x_{ij}^{*}+c)\\ &=(\beta_0+c\beta_1)+(b_{0j}+cb_{1j}) +(\beta_1+b_{1j})x_{ij}^{*}. \end{aligned} $$

Thus the fixed slope and random slope are unchanged, while the fixed and random intercepts become \(\beta_0^{*}=\beta_0+c\beta_1\) and \(b_{0j}^{*}=b_{0j}+cb_{1j}\). The new random intercept is the old cluster deviation evaluated at \(x=c\). In particular, it is no longer the deviation at the old value \(x=0\).

Result: Under \(x^{*}=x-c\), the transformed random effects are \(b_{0j}^{*}=b_{0j}+cb_{1j}\) and \(b_{1j}^{*}=b_{1j}\). Their covariance parameters are $$ \tau_{00}^{*}=\tau_{00}+2c\tau_{01}+c^2\tau_{11}, \qquad \tau_{01}^{*}=\tau_{01}+c\tau_{11}, \qquad \tau_{11}^{*}=\tau_{11}. $$ The fixed effects become \(\beta_0^{*}=\beta_0+c\beta_1\) and \(\beta_1^{*}=\beta_1\).

To justify the covariance formulas, use the variance and covariance rules for linear combinations. The variance of \(b_{0j}+cb_{1j}\) is \(\operatorname{Var}(b_{0j})+2c\operatorname{Cov}(b_{0j},b_{1j})+c^2\operatorname{Var}(b_{1j})\). Its covariance with \(b_{1j}\) is \(\operatorname{Cov}(b_{0j},b_{1j})+c\operatorname{Var}(b_{1j})\). The variance of \(b_{1j}\) itself is unchanged. Equivalently, with \(A=\begin{pmatrix}1&c\\0&1\end{pmatrix}\), the transformed covariance matrix is \(D^{*}=ADA^{T}\). This transformation preserves positive semidefiniteness: for any vector \(v\), \(v^{T}D^{*}v=(A^{T}v)^{T}D(A^{T}v)\geq 0\) whenever \(D\) is positive semidefinite.

Worked Examples

Worked Example: Checking a Cluster’s Linear Predictor

Suppose a hypothetical Gaussian GLMM uses a predictor measured in years and has \(\beta_0=1.2\), \(\beta_1=0.4\), \(b_{0j}=-0.3\), and \(b_{1j}=0.1\). Center the predictor at \(c=5\) years. Check the linear predictor for a cluster observation at \(x_{ij}=7\) years.

The centered value is \(x_{ij}^{*}=7-5=2\) years. The transformed intercepts are \(\beta_0^{*}=1.2+5(0.4)=3.2\) and \(b_{0j}^{*}=-0.3+5(0.1)=0.2\). The slopes remain \(0.4\) and \(0.1\).

On the original scale, the linear predictor is \(\eta_{ij}=1.2+0.4(7)-0.3+0.1(7)=4.4\). On the centered scale, it is \(\eta_{ij}^{*}=3.2+0.4(2)+0.2+0.1(2)=4.4\).

The two calculations agree. For a Gaussian model with the identity link, this is also the conditional mean response. For another link, the conditional response mean is obtained by applying the same inverse link to this unchanged linear predictor.

Worked Example: Transforming the Covariance Matrix

Suppose a hypothetical model has \(\tau_{00}=4\) link-units squared, \(\tau_{01}=-0.3\) link-units squared per year, and \(\tau_{11}=0.25\) link-units squared per year squared. Shift the origin by \(c=2\) years and find the transformed covariance parameters.

Substitution gives \(\tau_{00}^{*}=4+2(2)(-0.3)+(2^2)(0.25)=4-1.2+1=3.8\) link-units squared. The transformed covariance is \(\tau_{01}^{*}=-0.3+2(0.25)=0.2\) link-units squared per year, and \(\tau_{11}^{*}=0.25\) link-units squared per year squared.

The covariance has changed from negative to positive, but that does not indicate a change in the cluster trajectories. It describes the association between the random intercept and slope at a different predictor origin. As a validity check, the original determinant is \(4(0.25)-(-0.3)^2=0.91\), and the transformed determinant is \(3.8(0.25)-(0.2)^2=0.91\). Both matrices are positive definite; the unchanged determinant is consistent with the transformation’s determinant-one matrix \(A\).

Worked Example: Preserving a Conditional Probability

In a hypothetical logistic random-slope model, let \(\beta_0=-1\), \(\beta_1=0.03\) per year, \(b_{0j}=0.2\), and \(b_{1j}=-0.01\) per year. At age \(x=60\) years, compare the conditional probability before and after centering at \(c=50\) years.

The original linear predictor is \(-1+0.03(60)+0.2-0.01(60)=0.4\). For a logit link, the conditional probability is \(1/(1+\exp(-0.4))\approx0.5987\).

After centering, \(x^{*}=10\), \(\beta_0^{*}=-1+50(0.03)=0.5\), and \(b_{0j}^{*}=0.2+50(-0.01)=-0.3\). The slopes remain \(0.03\) and \(-0.01\). Thus \(\eta^{*}=0.5+0.03(10)-0.3-0.01(10)=0.4\), giving the same conditional probability, approximately \(0.5987\). This is a conditional probability for the specified cluster random effects, not a marginal probability averaged over the random-effects distribution.

What Changes, and What Does Not

Centering changes the reference point for both the fixed and cluster-specific intercepts. At \(x=c\), the centered predictor is zero, so \(\beta_0^{*}\) is the fixed linear predictor at that value, and \(b_{0j}^{*}\) is cluster \(j\)’s random deviation there. The slope still describes change in the linear predictor per unit of the original predictor. Because the random intercept now contains part of the random slope, its variance and its covariance with the slope can change substantially.

The entire conditional linear predictor is unchanged for each observation when the random effects are transformed along with the fixed effects. Therefore, its conditional fitted response under the inverse link is unchanged too. Since the transformed random effects are a linear transformation of the original jointly Gaussian random effects, they remain jointly Gaussian, with the transformed covariance matrix given above. The implied distribution of linear predictors and responses is therefore also unchanged when the model is re-expressed without additional constraints.

This equivalence has an important qualification: a restriction on the covariance structure may not be preserved. For example, requiring \(\tau_{01}=0\) imposes zero intercept-slope covariance at the chosen origin. After centering, \(\tau_{01}^{*}=\tau_{01}+c\tau_{11}\), which need not be zero. A model that restricts the covariance to zero before centering is not generally the same restricted model after centering. This issue is different from the unrestricted reparameterization above.

Diagnostics, Alternatives, and Limitations

Centering can make the fixed intercept more interpretable and may improve numerical conditioning when the predictor’s original zero is far from its observed values. It does not change the scale of the predictor or make large units smaller; dividing by a scale factor is a separate rescaling operation, with its own slope and covariance transformations. Nor is subtracting one common constant the same as subtracting a different mean for each cluster. Such within-cluster transformations change the model’s predictor structure and interpretation; they are not the origin shift derived here.

Useful checks include confirming that \(x=x^{*}+c\) for every record, verifying that the stated coefficient and covariance transformations are applied together, and comparing linear predictors for selected clusters before and after recentering. Under an unrestricted covariance structure and otherwise identical model, fitted linear predictors should agree up to numerical precision. If they do not, check the coding, the value and units of \(c\), and whether a covariance constraint, prior, or other modeling restriction differs between fits.

An estimated intercept-slope correlation near \(1\) or \(-1\), a nearly zero variance, or convergence problems may indicate a weakly identified or nearly singular random-effects structure. Centering can change the reported intercept-slope correlation and sometimes improve computation, but it cannot create information absent from the data or guarantee that the random-effects structure is estimable. Interpret changes in covariance parameters in light of the changed reference point rather than as evidence that the clusters themselves have changed.

Common pitfall: “The intercept-slope covariance changed after centering, so the clusters’ fitted trajectories must have changed.” This is incorrect for the unrestricted model when the fixed and random intercepts and covariance matrix are transformed consistently. The covariance describes intercept and slope deviations relative to a particular origin; check the linear predictor at matching original and centered values to verify that the trajectories are preserved.

Check Your Understanding

Answer each question, then compare with the concise solutions below.

  1. If \(x^{*}=x-4\), what are the transformed fixed intercept, random intercept, and random-intercept variance?
  2. If \(\tau_{01}=-0.2\), \(\tau_{11}=0.1\), and \(c=3\), what is \(\tau_{01}^{*}\)?
  3. When only the origin is shifted, does the random-slope variance change? Explain.
  4. Why might a model that forces the intercept-slope covariance to zero give different results after centering?

Solutions. (1) \(\beta_0^{*}=\beta_0+4\beta_1\), \(b_{0j}^{*}=b_{0j}+4b_{1j}\), and \(\tau_{00}^{*}=\tau_{00}+8\tau_{01}+16\tau_{11}\). (2) \(\tau_{01}^{*}=-0.2+3(0.1)=0.1\). (3) No: \(b_{1j}^{*}=b_{1j}\), so \(\tau_{11}^{*}=\tau_{11}\). (4) Zero covariance is defined relative to the chosen origin; after shifting, \(\tau_{01}^{*}=\tau_{01}+c\tau_{11}\), which generally is not zero even if \(\tau_{01}=0\).

Clinical Biostats