From Cluster-Specific Trajectories to Curves
A random-intercept, random-slope GLMM describes how the conditional mean response changes with a covariate within a cluster. Plotting selected conditional curves makes that model structure visible: an intercept deviation can move a curve, while a slope deviation changes how it develops across the predictor range. The curves are model-based conditional means, not the individual outcomes themselves.
Let \(Y_{ij}\) be the response for observation \(j\) in cluster \(i\), and let \(x_{ij}\) be the predictor of interest. Write \(\mu_{ij}=E(Y_{ij}\mid b_{0i},b_{1i},x_{ij})\). A random-intercept, random-slope model with one predictor has the form below. Other fixed predictors can be held at specified values while the curve is drawn.
Here, \(\beta_0\) and \(\beta_1\) are fixed effects, while \(b_{0i}\) and \(b_{1i}\) are cluster-level deviations. In the usual model, the random-effect pair is drawn from a joint distribution with mean zero and covariance matrix \(D\); its two components need not be independent. Within a cluster, the same pair applies across its observations. The link \(g\) must be specified, and \(g^{-1}\) maps the linear predictor to the response scale.
To construct a plot, select the random-effect pair or pairs of interest, choose a useful grid of \(x\) values, calculate the linear predictor at every grid point, and apply the inverse link. Use the same fixed effects, link, and horizontal scale for every curve being compared. If the predictor is centered, the intercept deviation is relative to the chosen reference value, not necessarily to raw \(x=0\).
What the Curves Show
On the link scale, the conditional intercept at \(x=0\) is \(\beta_0+b_0\), and the conditional slope is \(\beta_1+b_1\). Thus, \(b_0\) shifts the link-scale starting value and \(b_1\) changes its rate of change across \(x\). If the predictor has been centered at \(c\), the link-scale intercept instead describes the value at \(x=c\), and the formula should be written using the centered predictor.
On the response scale, these effects depend on the link. With the identity link, the response curve is a straight line. With the log link, it is an exponential curve; with the logit link, it is a probability curve. Consequently, a random slope is additive on the link scale, but it does not necessarily create a constant additive change in the response per unit of \(x\).
This follows directly from the chain rule: differentiate \(g^{-1}\{\eta(x)\}\), then use \(d\eta(x)/dx=\beta_1+b_1\). For an identity link, the derivative is just \(\beta_1+b_1\). For a log link it is \(\mu(x\mid b_0,b_1)(\beta_1+b_1)\); for a logit link it is \(p(x)\{1-p(x)\}(\beta_1+b_1)\), where \(p(x)=\mu(x\mid b_0,b_1)\). These formulas explain why curves under nonlinear links can bend even though the link-scale predictor is linear.
Worked Example: Straight-Line Curves With the Identity Link
Suppose a hypothetical continuous-response model is \( \mu_i(x)=12+2x+b_{0i}+b_{1i}x \), with response measured in units. Consider the reference pair \((0,0)\), cluster A’s selected pair \((3,-0.5)\), and cluster B’s selected pair \((-2,0.75)\). These are illustrative random-effect values used to draw curves, not estimates from observed clusters.
For the reference pair, the curve is \(12+2x\). For A, it is \(12+2x+3-0.5x=15+1.5x\). For B, it is \(12+2x-2+0.75x=10+2.75x\). The identity link leaves each linear predictor unchanged on the response scale.
At \(x=0,2,4\), the reference curve gives \(12,16,20\). Curve A gives \(15+1.5(0)=15\), \(15+1.5(2)=18\), and \(15+1.5(4)=21\). Curve B gives \(10+2.75(0)=10\), \(10+2.75(2)=15.5\), and \(10+2.75(4)=21\). Plotting these coordinates produces three straight lines in response units. A is above the reference at \(x=0\), but its smaller slope means the difference narrows; B starts below the reference and, with its larger slope, is above it by \(x=4\).
Nonlinear Links and Response-Scale Shape
For a log link, response means are positive and multiplicative. A selected pair changes both the scale at which the curve begins and its rate of exponential growth or decline. For a logit link, the response is a probability between zero and one, and changes in the linear predictor are compressed near the boundaries. The calculations below use the same plotting procedure: evaluate the linear predictor at the selected grid points, then apply the inverse link.
Worked Example: Exponential Curves With the Log Link
Consider the hypothetical mean model \( \log\{\mu_i(x)\}=\log(20)+0.10x+b_{0i}+b_{1i}x \), where \(\mu_i(x)\) is a conditional mean count. Draw curves for the reference pair \((0,0)\), pair A \((\log(1.2),0.05)\), and pair B \((\log(0.8),-0.05)\). Their response-scale formulas are \(20\exp(0.10x)\), \(24\exp(0.15x)\), and \(16\exp(0.05x)\), respectively.
For example, A’s starting mean is \(20\exp\{\log(1.2)\}=24\), and its link-scale slope is \(0.10+0.05=0.15\). B starts at \(20\exp\{\log(0.8)\}=16\) and has slope \(0.10-0.05=0.05\). These transformations show why the intercept deviation changes the starting level and the slope deviation changes the exponential rate.
At \(x=4\), the reference mean is \(20\exp(0.40)\approx29.84\). A’s mean is \(24\exp(0.15(4))=24\exp(0.60)\approx43.73\). B’s mean is \(16\exp(0.05(4))=16\exp(0.20)\approx19.55\). The plotted vertical axis is in mean-count units, not log-mean units. A is highest at this predictor value, but these conditional curves alone do not establish that any observed cluster has exactly the selected random effects.
Worked Example: Probability Curves With the Logit Link
Suppose a hypothetical binary-response model has conditional log odds \( \operatorname{logit}\{p_i(x)\}=-1+0.5x+b_{0i}+b_{1i}x \), where \(p_i(x)\) is the conditional probability of the outcome. Compare the reference pair \((0,0)\), an upper pair \((0.4,0.2)\), and a lower pair \((-0.4,-0.2)\).
The response probability is \(p_i(x)=1/\{1+\exp[-\eta_i(x)]\}\). At \(x=4\), the reference predictor is \(-1+0.5(4)=1\), so its probability is \(1/\{1+\exp(-1)\}\approx0.7311\). For the upper pair, the predictor is \(-1+0.5(4)+0.4+0.2(4)=2.2\), giving probability \(1/\{1+\exp(-2.2)\}\approx0.9002\).
For the lower pair, the predictor is \(-1+0.5(4)-0.4-0.2(4)=-0.2\), giving probability \(1/\{1+\exp(0.2)\}\approx0.4502\). Thus, at \(x=4\), the three plotted probabilities are approximately \(0.7311\), \(0.9002\), and \(0.4502\). These are conditional probabilities at that covariate value, not probabilities that a cluster belongs to one of the selected pairs.
The examples also illustrate why a graph should label both axes and identify the link and the selected random-effect values. A response-scale vertical axis makes predictions interpretable in the outcome’s units, while the legend states which conditional curves are being compared. If a link-scale plot is useful for checking linearity, label it clearly as a plot of the linear predictor rather than the response mean.
Assumptions, Diagnostics, and Comparisons
A plotted curve inherits the assumptions of the fitted model. The conditional mean and link must be appropriate for the response; the linear predictor must have the specified form; and the selected random effects must represent the intended cluster-level deviations. The random-effect distribution, commonly a mean-zero multivariate normal distribution with covariance matrix \(D\), is a model assumption, not a property established by drawing curves. In particular, chosen pairs should be described as selected values; if they are intended to represent plausible combinations, their compatibility with the assumed joint distribution should be considered.
A plot is a diagnostic aid, not a test of those assumptions. Compare fitted curves with observed cluster trajectories or suitable summaries, while remembering that individual outcomes vary around their conditional means. Look for systematic curvature on the link scale, clusters whose patterns are not captured by the specified slope structure, and curves that imply implausible means or probabilities. Check whether apparent crossings are supported by data in that predictor region. A curve that changes sharply outside the observed range may be a consequence of extrapolation rather than useful evidence about cluster behavior.
Three common displays answer different questions. A curve at \(b_0=b_1=0\) shows the conditional mean for zero random effects; it is not generally the population-average mean, because applying a nonlinear inverse link and averaging over random effects do not generally give the same result as setting the random effects to zero. Curves for selected pairs show how conditional means vary across specified cluster deviations. Observed trajectories show data, including sampling variation, rather than model means. The earlier material on GLM covers fixed-effect mean curves; here the defining addition is the cluster-specific random-effect pair.
A useful plot can still mislead if the selected values are arbitrary, if the horizontal range hides a crossover, or if a response-scale curve is mistaken for observed data. A curve without uncertainty bands also does not communicate uncertainty in the fitted fixed effects or in cluster-specific estimates. Avoid describing illustrative pairs as actual cluster estimates unless they were estimated from data, and do not interpret a conditional curve as a causal effect. The curve represents model-based association conditional on the stated random effects and covariates.
Common Mistakes
- Plotting the linear predictor as if it were the response. With a log or logit link, transform every calculated predictor using \(g^{-1}\) before labeling the vertical axis as a mean or probability.
- Changing only the intercept when the selected slope differs. The term \(b_1x\) changes the curve across the entire predictor range; omitting it can erase a change in direction or rate.
- Calling the zero-random-effect curve the population average. It is conditional on \(b_0=b_1=0\). With a nonlinear link, it need not equal a mean averaged over the random-effect distribution.
- Treating selected values as observed clusters. A curve for an illustrative pair is a model-based scenario, not evidence that a real cluster has those values.
Check Your Understanding
Try each problem, then compare your reasoning with the brief solutions below.
- For an identity-link model with \(\mu(x)=5+1.2x+b_0+b_1x\), what is the curve for \((b_0,b_1)=(2,-0.4)\), and what is its mean at \(x=3\)?
- For a log-link model with \(\log\{\mu(x)\}=0.3+0.2x+b_0+b_1x\), find the response-scale curve for \((b_0,b_1)=(\log 2,0.1)\). Does the selected slope increase or decrease the exponential rate compared with the reference curve?
- In a logit model, explain why a positive \(b_0\) raises the conditional probability at a fixed \(x\), but does not add the same probability amount at every \(x\).
- Why is a curve with \(b_0=b_1=0\) not necessarily the population-average response curve?
Solutions. (1) The curve is \(7+0.8x\), since \(5+2=7\) and \(1.2-0.4=0.8\); at \(x=3\), it is \(7+0.8(3)=9.4\) response units. (2) The curve is \(\exp(0.3+\log 2+0.3x)=2\exp(0.3+0.3x)\). Its link-scale slope is \(0.2+0.1=0.3\), greater than the reference slope \(0.2\), so its exponential rate is higher. (3) At fixed \(x\), positive \(b_0\) raises the linear predictor, and the inverse logit is increasing, so it raises probability. But the probability-scale change depends on the starting probability through the curvature of the inverse logit. (4) In general, averaging \(g^{-1}(\eta)\) over random effects is not the same as evaluating \(g^{-1}(\eta)\) at zero random effects when \(g^{-1}\) is nonlinear.