From a Random Slope to a Cluster-Specific Slope
A random slope lets the relationship between a predictor and the outcome vary across clusters. The model expresses each cluster’s slope using two parts: a fixed slope shared as the model’s reference trend, and a cluster-specific random deviation from it. The key algebra is simple, but its interpretation depends on being clear about which scale the slope describes.
In a GLMM, the linear predictor is defined on the link scale. A cluster-specific slope is therefore the rate of change of that conditional linear predictor with the predictor, not automatically the rate of change of the conditional mean outcome. The distinction matters because applying a nonlinear inverse link can change how response-scale differences behave across predictor values and clusters.
Model and Assumptions
Consider observations \(i\) nested within clusters \(j\), with a numerical predictor \(x_{ij}\). Let \(Y_{ij}\) have conditional mean \(\mu_{ij}=E(Y_{ij}\mid b_{0j},b_{1j},x_{ij})\). A GLMM with a random intercept and a random slope for \(x_{ij}\) specifies
Here \(g\) is the link function; \(\eta_{ij}\) is the conditional linear predictor; \(\beta_0\) and \(\beta_1\) are fixed effects; and \(b_{0j}\) and \(b_{1j}\) are cluster \(j\)'s random-intercept and random-slope deviations. The conditional mean is defined given the random effects. Other fixed-effect covariates can be included in the linear predictor; the slope derived below is then the effect of increasing \(x_{ij}\) while holding those covariates fixed.
The derivation requires that the linear predictor be linear in \(x_{ij}\), with the displayed random-slope term \(b_{1j}x_{ij}\). The usual GLMM setup also specifies a conditional response distribution from an exponential-family model, conditional on the random effects and covariates. Responses are assumed conditionally independent given those quantities. A common distributional assumption is that the random-effects vectors \((b_{0j},b_{1j})\) are independent across clusters and follow a mean-zero bivariate normal distribution with an estimated covariance matrix. The algebra for the slope itself does not require normal random effects, but the assumed random-effects distribution matters for the full model and its estimation.
As with other random-effects models, interpretation relies on the specified conditional mean structure being appropriate and the modeled random effects being independent of the covariates, or independent conditional on any covariates or structure explicitly included in the model. A random slope does not repair an incorrect link, omitted systematic predictors, or a poorly chosen functional form.
Deriving the Slope
Fix a cluster \(j\), so its values \(b_{0j}\) and \(b_{1j}\) are held constant as \(x_{ij}\) changes. Collect the terms that do and do not multiply \(x_{ij}\):
This is a straight line in \(x_{ij}\) on the link scale. Its intercept is \(\beta_0+b_{0j}\), and its slope is \(\beta_1+b_{1j}\). Equivalently, differentiating with respect to \(x_{ij}\) gives the same result.
The random intercept disappears from this derivative because it does not multiply \(x_{ij}\). It shifts the cluster’s conditional linear predictor up or down by the same amount at every value of \(x_{ij}\), whereas the random slope changes the rate at which that predictor moves.
For a predictor measured in years, for example, the slope has units of link-scale units per year. If the predictor increases by \(\Delta x\), then the corresponding change in the conditional linear predictor for cluster \(j\) is \((\beta_1+b_{1j})\Delta x\). If \(x\) is binary, the same coefficient sum is the conditional link-scale contrast between \(x=1\) and \(x=0\); describing it as a derivative is unnecessary because the predictor only takes two values.
Worked Example: A Continuous Predictor Measured in Years
Suppose a hypothetical GLMM uses age in years as \(x_{ij}\). Its estimated fixed slope is \(\beta_1=0.40\) link-scale units per year. For a particular hypothetical cluster, the random-slope deviation is \(b_{1j}=-0.15\) link-scale units per year. Find that cluster’s conditional slope and the link-scale change over four years.
Substitute the values into the cluster-specific slope:
Thus, within this cluster, a one-year increase in age corresponds to a 0.25-unit increase in the conditional linear predictor, holding the other covariates fixed. For a four-year increase, \(\Delta x=4\):
This calculation describes change on the link scale. It does not establish that the conditional mean outcome increases by 1.00 response units.
Worked Example: A Negative Cluster-Specific Slope
In another hypothetical model, \(x\) is measured in ten-unit increments of a laboratory measurement. The fixed slope is \(\beta_1=-0.30\) link-scale units per increment. A cluster has \(b_{1j}=0.08\) link-scale units per increment. Its conditional linear predictor at \(x=2\) is given as \(\eta_j(2)=0.50\). Find its slope and the predictor’s link-scale change from \(x=2\) to \(x=5\), then verify the change using the two linear-predictor values.
The cluster-specific slope is
The predictor changes by \(5-2=3\) increments, so the implied link-scale change is
Using the supplied value at \(x=2\), the value at \(x=5\) is \(0.50-0.66=-0.16\). Subtracting gives \(\eta_j(5)-\eta_j(2)=-0.16-0.50=-0.66\), which agrees with the slope calculation. The cluster’s slope is negative even though its random deviation is positive: the deviation makes the fixed slope less negative, but does not reverse its sign.
Worked Example: A Binary Predictor as a Conditional Contrast
Suppose a hypothetical GLMM includes a binary predictor \(x\), coded 0 for the reference condition and 1 for the comparison condition. The fixed coefficient is \(\beta_1=0.25\) link-scale units. Two hypothetical clusters have random-slope deviations \(b_{1A}=0.10\) and \(b_{1B}=-0.35\). Calculate and interpret the conditional contrast in each cluster.
Because the predictor changes from 0 to 1, the conditional link-scale contrast is the difference in linear predictors:
For cluster A, the contrast is \(0.25+0.10=0.35\) link-scale units. For cluster B, it is \(0.25+(-0.35)=-0.10\) link-scale units. The modeled comparison-condition shift is positive on the link scale in cluster A and negative in cluster B. The two results do not by themselves give response-scale differences; those require applying the inverse link to the relevant conditional linear predictors.
What the Slope Does, and Does Not, Describe
The sum \(\beta_1+b_{1j}\) is conditional on cluster \(j\)'s random effects. It describes that cluster’s change in the linear predictor as \(x\) changes, with other model quantities held fixed. It is not the same object as the fixed slope alone, nor does it automatically describe the slope of a population-average response curve.
If the inverse link \(g^{-1}\) is differentiable, then the conditional response mean is \(\mu_{ij}=g^{-1}(\eta_{ij})\). The chain rule gives
The response-scale derivative depends not only on the cluster-specific slope but also on the linear predictor through the derivative of the inverse link. For a nonlinear inverse link, it can vary with \(x_{ij}\), even though \(\beta_1+b_{1j}\) is constant across \(x_{ij}\) in this model. The earlier material on link-scale and mean-scale predictions establishes this distinction; here it explains why the derived slope must be labeled as a link-scale slope.
Under the usual mean-zero random-effects assumption, the mean of the random-slope deviations across the modeled distribution is zero, so the mean of the cluster-specific slopes on the link scale is \(\beta_1\). This does not imply that the slope of the marginal mean response is \(\beta_1\). Averaging inverse-link predictions over random effects is generally different from applying the inverse link to an average linear predictor.
Checking the Specification and Choosing an Alternative
The algebra is valid for the stated model, but a calculated slope is useful only if the model is a reasonable description of the data. Relevant checks include whether the predictor’s conditional relationship is plausibly linear on the link scale, whether there is enough within-cluster information to distinguish varying slopes, and whether a small number of clusters or influential observations are driving the fitted random-slope pattern. Residual or predictive checks should be considered on an appropriate scale for the response distribution.
A random-intercept-only model is a more restrictive alternative: it sets the random-slope deviation to zero, making the conditional link-scale slope the same across clusters. A model with separate fixed slopes for each cluster can describe cluster differences but does not use the random-effects structure to represent a shared distribution of deviations. A population-average model targets a different conditional or marginal quantity. These approaches are not interchangeable; the choice depends on the scientific question, the design, and the available data.
A random-slope model can also be difficult to support when clusters have few observations or little variation in \(x\). In those circumstances, cluster-specific deviations may be imprecisely estimated, and model fitting can be unstable. A result that appears to show large cluster-to-cluster slope differences should be checked against the data coverage and the model’s assumptions rather than treated as a precise description of every cluster.
Common Mistakes
- Using only the fixed slope. The fixed slope is the reference value. For cluster \(j\), the conditional slope is \(\beta_1+b_{1j}\).
- Adding the random intercept to the slope. The intercept changes the level of the linear predictor, not its rate of change with \(x\). Differentiating removes \(\beta_0+b_{0j}\).
- Calling the result a response-scale change. The sum is measured in link-scale units per predictor unit. The inverse link is needed to calculate a response-scale prediction or contrast.
- Treating a deviation as the cluster’s full slope. \(b_{1j}\) is a deviation from the fixed slope, not the cluster-specific slope by itself.
- Extrapolating beyond the observed predictor range. The formula follows from the model’s linear structure, but its interpretation outside the data-supported range depends on an extrapolation assumption.
Check Your Understanding
Use the model definition and distinguish link-scale slopes from response-scale changes.
- A model has fixed slope \(0.60\) link-scale units per hour and a cluster deviation of \(-0.20\) link-scale units per hour. What is the cluster-specific slope?
- For the cluster in Question 1, what is the linear-predictor change for a three-hour increase?
- Why does a random intercept not appear in the cluster-specific slope formula?
- If a binary predictor is coded 0 and 1, what does \(\beta_1+b_{1j}\) represent?
- Why is \(\beta_1+b_{1j}\) not generally the response-scale derivative?
Solutions. (1) \(0.60+(-0.20)=0.40\) link-scale units per hour. (2) The change is \(0.40(3)=1.20\) link-scale units. (3) The random intercept is constant as the predictor changes, so its derivative with respect to that predictor is zero. (4) It is the cluster-specific conditional link-scale contrast between predictor values 1 and 0. (5) The response mean is obtained by applying the inverse link, so its derivative is \((g^{-1})'(\eta_{ij})(\beta_1+b_{1j})\), not generally just the slope on the link scale.