Tutorials › Generalized Linear Mixed Models (GLMM) › Conditional Responses at Specified Random Effects

Random Intercepts and Slopes · Tutorial 60 of 698

Conditional Responses at Specified Random Effects

Calculate a cluster’s conditional response at stated random-effect values by forming the linear predictor and applying the model’s inverse link.

Intermediate 10 min read

What You'll Learn

  • Separate fixed-effect contributions from specified cluster-specific intercept and slope contributions.
  • Calculate a conditional mean under the identity link.
  • Transform a log-link linear predictor into an expected count.
  • Transform a logit-link linear predictor into a response probability.
  • Keep random effects fixed across covariate values when calculating a cluster’s trajectory.
  • Distinguish a conditional response from a marginal response averaged over clusters.

From a Cluster’s Effects to Its Conditional Response

A random-intercept and random-slope GLMM describes how a response changes with a predictor while allowing both the baseline level and the predictor’s effect to vary by cluster. Once the random-effect values for a cluster are specified, calculating its conditional response follows a direct sequence: combine the fixed and cluster-specific contributions on the linear-predictor scale, then apply the inverse link. The link determines whether the answer is a mean on the response scale, a probability, or another response quantity.

The key word is conditional. In this tutorial, the cluster’s random effects remain fixed at the stated values throughout a calculation. We do not average over their population distribution. That distinction matters especially for nonlinear links, where transforming an average linear predictor generally does not give the average response.

Definition: For observation \(i\) in cluster \(j\), let \(x_{ij}\) be a predictor and let \(b_{0j}\) and \(b_{1j}\) be the cluster-specific random intercept and random slope. A simple random-intercept and random-slope GLMM has $$ \eta_{ij}=\beta_0+\beta_1x_{ij}+b_{0j}+b_{1j}x_{ij}, \qquad g(\mu_{ij})=\eta_{ij}, \qquad \mu_{ij}=E(Y_{ij}\mid x_{ij},b_{0j},b_{1j})=g^{-1}(\eta_{ij}). $$ Here \(\eta_{ij}\) is the linear predictor, \(g\) is the link function, and \(\mu_{ij}\) is the response mean conditional on the predictor and the specified cluster effects. For a binary response coded \(0/1\), this conditional mean is also the conditional probability that \(Y_{ij}=1\).

The calculation assumes that the stated model form and link are appropriate, that the predictor value is within a range where the model is being used sensibly, and that the specified random effects are the values to condition on. A conventional GLMM also assigns a population distribution to the random effects, often a mean-zero multivariate normal distribution with an estimated covariance matrix. That distribution is relevant when estimating the model or averaging predictions over clusters; for a calculation at supplied values of \(b_{0j}\) and \(b_{1j}\), the values are held fixed. The response distribution must also match the outcome: for example, a normal response for a Gaussian model or a Bernoulli response for a binary model.

A Reliable Calculation Sequence

The random intercept changes a cluster’s linear predictor at every value of \(x\). The random slope changes how quickly that predictor changes as \(x\) changes. Both are added on the linear-predictor scale, not necessarily on the response scale. A useful form for calculation is $$ \eta_{ij}=(\beta_0+b_{0j})+(\beta_1+b_{1j})x_{ij}. $$ This rearrangement shows the cluster-specific intercept and slope for this simple model. It does not mean that the random effects are newly estimated for each observation: within a cluster, the same \(b_{0j}\) and \(b_{1j}\) are used at every observation.

After finding \(\eta_{ij}\), apply the inverse link. With the identity link, the conditional mean equals \(\eta_{ij}\). With the log link, it is \(\exp(\eta_{ij})\). With the logit link, it is \(1/(1+\exp(-\eta_{ij}))\). The arithmetic is similar in each case, but the interpretation and units of the result depend on the response scale.

1
Substitute the predictor and effects.
Use the stated \(x_{ij}\), \(b_{0j}\), and \(b_{1j}\), along with the model’s fixed coefficients.
2
Calculate the linear predictor.
Add the fixed and random contributions on the link scale, keeping signs and products explicit.
3
Apply the inverse link.
Convert the linear predictor to a response mean or, for a binary response, a response probability.
4
State the conditional interpretation.
Name the cluster effects being held fixed, the predictor value, and the units or probability scale of the result.

Worked Example: Conditional Mean With an Identity Link

Suppose a hypothetical Gaussian response is measured in score points, with model \(\eta_{ij}=12+1.5x_{ij}+b_{0j}+b_{1j}x_{ij}\). For one cluster, take \(b_{0j}=-2\) and \(b_{1j}=0.4\). Calculate its conditional mean at \(x_{ij}=3\). Assume the Gaussian conditional mean model and identity link apply at this predictor value.

First substitute all values into the linear predictor: $$ \eta_{ij}=12+(1.5)(3)+(-2)+(0.4)(3) =12+4.5-2+1.2=15.7. $$

Because the link is the identity, \(g^{-1}(\eta)=\eta\). Thus \(\mu_{ij}=15.7\) score points. This is the model’s expected score for an observation at \(x=3\) in a cluster whose random intercept and slope are fixed at \(-2\) and \(0.4\). It is not a guarantee that an individual response equals 15.7; individual Gaussian outcomes can differ from their conditional mean.

Nonlinear Links: Transform After Adding the Effects

With a nonlinear link, the random effects still enter the linear predictor additively, but they do not generally add a constant amount to the response mean. For example, under a log link, a one-unit change in a cluster’s linear predictor multiplies its conditional mean by \(e\), rather than adding one unit to that mean. Under a logit link, a change in the linear predictor changes the log odds; the corresponding probability change depends on the starting probability. In both cases, calculate the complete linear predictor first and transform it once.

Worked Example: Conditional Expected Count With a Log Link

Consider a hypothetical count response with a Poisson conditional distribution and log link: \(\log(\mu_{ij})=0.2+0.3x_{ij}+b_{0j}+b_{1j}x_{ij}\). For a cluster with \(b_{0j}=-0.4\), \(b_{1j}=0.15\), calculate the conditional mean count at \(x_{ij}=2\). Assume the Poisson mean model and log link apply for this predictor value.

Substitution gives the log-scale linear predictor: $$ \eta_{ij}=0.2+(0.3)(2)-0.4+(0.15)(2) =0.2+0.6-0.4+0.3=0.7. $$ The inverse log link is the exponential function, so $$ \mu_{ij}=\exp(0.7)\approx 2.014. $$

The model therefore gives an expected count of about 2.014 events for an observation at \(x=2\) in this cluster, conditional on the stated effects. The expected count need not be an integer: it is an average across responses under the model, not a prediction that the observed count must equal 2.014.

Worked Example: Conditional Probability With a Logit Link

Suppose a hypothetical binary response \(Y_{ij}\) is coded 1 for an event and 0 otherwise. Its model is \(\operatorname{logit}(p_{ij})=-1+0.8x_{ij}+b_{0j}+b_{1j}x_{ij}\), where \(p_{ij}=P(Y_{ij}=1\mid x_{ij},b_{0j},b_{1j})\). For stated effects \(b_{0j}=0.3\) and \(b_{1j}=-0.2\), calculate the event probability at \(x_{ij}=2\). Assume a Bernoulli conditional response model and the specified logit link.

The logit-scale linear predictor is $$ \eta_{ij}=-1+(0.8)(2)+0.3+(-0.2)(2) =-1+1.6+0.3-0.4=0.5. $$ The inverse logit gives $$ p_{ij}=\frac{1}{1+\exp(-0.5)} \approx \frac{1}{1+0.6065} \approx 0.6225. $$

For an observation at \(x=2\) in a cluster with these fixed effects, the model assigns a conditional event probability of about 0.6225, or 62.25%. This is not a statement that the observed response is 0.6225; an individual binary response is either 0 or 1.

Why the Fixed-Effect and Random-Effect Values Must Stay Together

A calculation at several covariate values for one cluster uses the same random effects at every value. For the log-link model in the count example, the cluster-specific linear predictor can be written \(\eta_{ij}=(0.2-0.4)+(0.3+0.15)x_{ij}=-0.2+0.45x_{ij}\). At \(x=0\), the conditional mean is \(\exp(-0.2)\approx0.8187\); at \(x=2\), it is \(\exp(0.7)\approx2.014\). The change reflects the same cluster’s intercept and slope, not new random effects drawn at each \(x\). If instead the effects were changed between the two calculations, the results would describe different conditional clusters.

This follows directly from the model equation. Holding \(b_{0j}\) and \(b_{1j}\) fixed, the difference between linear predictors at \(x_a\) and \(x_b\) is $$ \eta_j(x_b)-\eta_j(x_a)=(\beta_1+b_{1j})(x_b-x_a). $$ The random intercept cancels from this difference, while the random slope contributes to the cluster-specific change. For an identity link, this is also the difference in conditional means. For nonlinear links, it is a difference on the link scale; the response-scale difference must be calculated by applying \(g^{-1}\) at both predictor values and subtracting the resulting means.

This small derivation also explains a frequent calculation error: adding \(b_{1j}\) once as though it were an intercept. The random-slope contribution is \(b_{1j}x_{ij}\). It is zero at \(x=0\), and its magnitude changes with \(x_{ij}\).

Conditional and Marginal Responses Are Different Targets

A conditional response answers a cluster-specific question at specified random-effect values. A marginal response averages over the distribution of random effects. In general, the marginal mean is $$ E_b\left[g^{-1}\{\beta_0+\beta_1x+b_0+b_1x\}\right], $$ where the expectation is taken over the random-effect distribution. It is not generally equal to \(g^{-1}\{\beta_0+\beta_1x+E(b_0)+E(b_1)x\}\). Even if the random effects have mean zero, a nonlinear inverse link usually prevents replacing the average of transformed values with a transformation of their average.

For example, the probability 0.6225 in the logit example is conditional on \(b_{0j}=0.3\) and \(b_{1j}=-0.2\). It is not automatically the population-average probability at \(x=2\). The distinction is important when deciding what a reported prediction is meant to describe. The specified-effects calculation is appropriate when the target is a cluster with those effects; an average across the random-effect population requires integration rather than simply substituting zero effects.

Checks, Limitations, and Common Mistakes

Before interpreting a result, check the calculation and the model scale. Confirm that the random-slope term was multiplied by \(x\), that the signs of both random effects were retained, and that the inverse link was applied only after all terms were added. Check that a probability lies between 0 and 1, that a log-link mean is positive, and that an identity-link mean has the response’s units. These checks can reveal arithmetic or link-function errors, although plausible-looking output does not establish that the model fits the data well.

A conditional calculation is only as useful as its inputs and model. Values of random effects may be supplied hypothetically or obtained as cluster-specific estimates; either way, the result is conditional on those values and does not by itself quantify their estimation uncertainty. Predictions far outside the observed range of \(x\) may rely on unsupported extrapolation. A GLMM’s assumed response distribution and link may also fail to describe the observed data. Such problems call for model assessment and potentially a different model, not a reinterpretation of the same arithmetic.

  • Mistake: transforming each term separately. For a log-link model, exponentiating the fixed part and adding the random effects afterward is not the model equation. Add all contributions to \(\eta\), then exponentiate.
  • Mistake: omitting the predictor multiplier. The random-slope term is \(b_{1j}x_{ij}\), not \(b_{1j}\) alone. Substitute the predictor value explicitly.
  • Mistake: changing cluster effects across predictor values. That compares different conditional clusters. Keep \(b_{0j}\) and \(b_{1j}\) fixed when tracing one cluster’s response curve.
  • Mistake: calling a conditional output a population average. A response calculated at specified random effects describes those effects. Averaging across clusters generally requires averaging the inverse-link values over the random-effect distribution.
  • Mistake: treating a mean or probability as an observed response. A conditional mean is an expectation, and a conditional probability describes uncertainty in a binary response; neither determines the realized outcome.

The practical value of this calculation is that it translates model coefficients and cluster effects into a response-scale quantity at a meaningful predictor value. It also makes clear what a prediction conditions on. When comparing clusters, use the same predictor value for each calculation; when following one cluster across predictor values, preserve its random effects.

Check Your Understanding

Answer each question, then compare your work with the solutions below.

  1. A Gaussian identity-link model has \(\eta=5+2x+b_0+b_1x\). At \(x=2\), \(b_0=-1\), and \(b_1=0.5\), what is the conditional mean?
  2. A log-link model has \(\log(\mu)=0.1+0.2x+b_0+b_1x\). At \(x=1\), \(b_0=0.2\), and \(b_1=-0.1\), calculate \(\mu\) to three significant figures.
  3. In a logit model, the linear predictor at stated effects is \(-0.4\). What is the conditional probability of \(Y=1\), approximately?
  4. Why must the same random intercept and random slope be used when calculating two predictor values for one cluster?
  5. Is a response calculated at \(b_0=b_1=0\) necessarily the marginal response? Explain.

Solutions. (1) \(\eta=5+4-1+1=9\), so the conditional mean is 9 response units. (2) \(\eta=0.1+0.2+0.2-0.1=0.4\), giving \(\mu=\exp(0.4)\approx1.492\), or 1.49. (3) \(p=1/[1+\exp(0.4)]\approx0.4013\). (4) The random effects characterize that cluster and are held fixed across its observations; changing them would calculate responses for different conditional clusters. (5) No. It is the response conditional on zero random effects. For a nonlinear inverse link, the population-average response generally requires averaging transformed predictions over the random-effect distribution.

Clinical Biostats