Tutorials › Nonlinear Mixed-Effects Models (NLME) › Random-Effects Structures for Binary Outcomes

Categorical, Count and Time-to-Event Responses · Tutorial 423 of 797

Random-Effects Structures for Binary Outcomes

Learn how random-effects choices describe differences in baseline response and dose sensitivity across clusters, and how to interpret their covariance in a binary NLME model.

Advanced 12 min read

What You'll Learn

  • Write binary dose-response models with random intercepts, random slopes, or both.
  • Interpret cluster-specific intercepts and dose effects on the link scale.
  • Calculate how intercept–slope covariance changes heterogeneity across dose.
  • Distinguish random-effect covariance from association between random effects and covariates.
  • Identify assumptions, diagnostics, and practical limits of these structures.
  • Compare random-effects models with simpler and alternative approaches.

Why the Random-Effects Structure Matters

In a clustered dose-response study, participants may differ both in their underlying probability of response and in how strongly that probability changes with dose. A binary mixed-effects model represents those differences through random effects. Choosing which random effects to include is therefore a scientific modeling decision: it determines which aspects of the response are allowed to vary across participants or other clusters.

The examples below use repeated binary outcomes, such as whether a hypothetical participant responds at each dose level. The aim is not simply to fit a more flexible model. It is to choose a structure that represents plausible between-cluster variation and is supported by the dose information in the data.

Definition: Let \(Y_{ij}\) be a binary outcome for cluster \(i\) at observation \(j\), with \(Y_{ij}=1\) indicating response and \(Y_{ij}=0\) otherwise. Let \(x_{ij}\) be dose, expressed in specified units. Write \(p_{ij}=P(Y_{ij}=1\mid b_i)\), where \(b_i\) is the cluster-specific random-effects vector. A logistic mixed-effects model uses \(\operatorname{logit}(p_{ij})=\log\{p_{ij}/(1-p_{ij})\}\) as its link.

For the models in this tutorial, the outcomes are assumed to be Bernoulli conditional on the random effects and covariates: \(Y_{ij}\mid b_i\sim\operatorname{Bernoulli}(p_{ij})\). A common assumption is conditional independence of observations within and between clusters given the random effects and model covariates. Cluster-level random effects are typically assumed to follow a mean-zero multivariate normal distribution with covariance matrix \(\Omega\), and to be independent across clusters. These are modeling assumptions, not consequences of the binary data format.

Three Structures for Clustered Dose Response

A random-intercept model allows the baseline response tendency to differ by cluster but keeps the dose effect common. A random-slope model allows dose sensitivity to differ. Including both allows the two cluster-specific features to vary together.

$$ \begin{aligned} \text{Random intercept:}\quad &\operatorname{logit}(p_{ij})=\beta_0+\beta_1x_{ij}+b_{0i},\\ \text{Random slope:}\quad &\operatorname{logit}(p_{ij})=\beta_0+\beta_1x_{ij}+b_{1i}x_{ij},\\ \text{Random intercept and slope:}\quad &\operatorname{logit}(p_{ij})=\beta_0+\beta_1x_{ij}+b_{0i}+b_{1i}x_{ij}. \end{aligned} $$

Here \(\beta_0\) and \(\beta_1\) are population-level fixed effects on the log-odds scale. The random effect \(b_{0i}\) shifts cluster \(i\)'s log odds; \(b_{1i}\) changes its dose slope. A random-slope-only model forces all clusters to have the same log odds at \(x=0\), so it is not always a sensible choice unless that constraint is scientifically appropriate. In practice, a random slope is often paired with a random intercept.

For the model with both terms, a standard distributional specification is

$$ \begin{pmatrix}b_{0i}\\b_{1i}\end{pmatrix} \sim N\left[ \begin{pmatrix}0\\0\end{pmatrix}, \begin{pmatrix} \omega_{00}&\omega_{01}\\ \omega_{01}&\omega_{11} \end{pmatrix} \right]. $$

The variances \(\omega_{00}\) and \(\omega_{11}\) describe between-cluster variation in intercepts and slopes. The covariance \(\omega_{01}\) describes whether clusters with higher-than-average intercepts tend to have higher or lower-than-average slopes. If both variances are positive, the corresponding correlation is \(\rho_{01}=\omega_{01}/\sqrt{\omega_{00}\omega_{11}}\). A positive value indicates that larger intercept deviations tend to occur with larger slope deviations; a negative value indicates the reverse.

“Correlated random effects” in this comparison means correlated random intercept and slope. It does not mean that the random effects are necessarily correlated with dose or other observed covariates. The usual random-effects formulation assumes the random effects are independent of the covariates in the model. If that assumption is not credible, changing \(\omega_{01}\) alone does not resolve the issue.

Worked Example: Interpreting a Random Intercept

Suppose a hypothetical binary response model has \(\beta_0=-2.0\), \(\beta_1=0.80\) per 10 mg, and a particular participant's illustrative random intercept is \(b_{0i}=0.70\). Let \(x\) be dose in units of 10 mg. Under a random-intercept model, calculate this participant's conditional response probabilities at 0 mg and 20 mg.

At 0 mg, \(x=0\), so the conditional log odds are \(-2.0+0.80(0)+0.70=-1.30\). Thus \(p_{i}=\exp(-1.30)/\{1+\exp(-1.30)\}=0.2142\).

At 20 mg, \(x=2\), so the conditional log odds are \(-2.0+0.80(2)+0.70=0.30\). The probability is \(\exp(0.30)/\{1+\exp(0.30)\}=0.5744\).

The random intercept raises this participant's log odds by 0.70 at every dose, but it does not change the slope of 0.80 log-odds units per 10 mg. These are conditional probabilities for the specified random effect, not population-averaged probabilities.

How Intercept–Slope Covariance Changes Dose-Dependent Variation

In the model with both random effects, the random contribution to the linear predictor at dose \(x\) is \(b_{0i}+xb_{1i}\). Its variance across clusters is obtained by applying the variance formula for a linear combination:

$$ \operatorname{Var}(b_{0i}+xb_{1i}) =\omega_{00}+2x\omega_{01}+x^2\omega_{11}. $$

This equation is central to interpreting the structure. With a random intercept alone, variation in the linear predictor is constant across dose. With a random slope, the \(x^2\omega_{11}\) term makes it dose-dependent. When intercept and slope are correlated, the additional \(2x\omega_{01}\) term can either increase or decrease variation depending on the dose and the sign of the covariance.

Justification: For random variables \(A\) and \(B\), \(\operatorname{Var}(A+B)=\operatorname{Var}(A)+\operatorname{Var}(B)+2\operatorname{Cov}(A,B)\). Set \(A=b_{0i}\) and \(B=xb_{1i}\). Then \(\operatorname{Var}(A)=\omega_{00}\), \(\operatorname{Var}(B)=x^2\omega_{11}\), and \(\operatorname{Cov}(A,B)=x\omega_{01}\), giving the stated result.

Worked Example: Comparing Heterogeneity at Two Doses

Suppose the hypothetical intercept variance is \(\omega_{00}=0.36\), the slope variance is \(\omega_{11}=0.16\), and the intercept–slope correlation is \(-0.50\). Calculate the variance of the random contribution to log odds at \(x=-2\) and \(x=2\), where dose is centered at a reference dose.

First, the covariance is \(\omega_{01}=\rho_{01}\sqrt{\omega_{00}\omega_{11}}=-0.50\sqrt{0.36(0.16)}=-0.50(0.24)=-0.12\).

At \(x=2\), the variance is \(0.36+2(2)(-0.12)+(2^2)(0.16)=0.36-0.48+0.64=0.52\).

At \(x=-2\), it is \(0.36+2(-2)(-0.12)+(-2)^2(0.16)=0.36+0.48+0.64=1.48\).

Thus the random contribution to log odds is more variable at \(x=-2\) than at \(x=2\) under these parameters. The negative covariance reduces variation on the positive-dose side and increases it on the negative-dose side. This comparison is on the linear-predictor scale; it does not imply that the probability variance has the same numerical values.

Centering dose changes the interpretation of the intercept and can change the numerical intercept–slope covariance, even though it does not change the fitted model's predictions when the transformation is handled consistently. With \(x^*=x-c\), the intercept at the new reference is the old intercept plus \(c\) times the old slope. Choose a reference dose with scientific meaning, such as a clinically relevant dose or the center of the observed dose range, so the intercept has a useful interpretation and is not an extrapolation.

Worked Example: What a Correlated Intercept and Slope Represent

Consider a hypothetical model with \(\beta_0=-1.50\), \(\beta_1=0.60\) per 10 mg, and random effects \(b_{0i}\) and \(b_{1i}\). For illustration, compare two clusters with random-effect values \((-0.40,-0.20)\) and \((0.40,0.20)\). These values are illustrative deviations, not estimated results from a real study.

For the first cluster, at \(x=0\), the linear predictor is \(-1.50-0.40=-1.90\), giving \(p=\exp(-1.90)/\{1+\exp(-1.90)\}=0.1301\). Its dose slope is \(0.60-0.20=0.40\) log-odds units per 10 mg.

For the second cluster, at \(x=0\), the linear predictor is \(-1.50+0.40=-1.10\), giving \(p=0.2497\). Its dose slope is \(0.60+0.20=0.80\) log-odds units per 10 mg.

Here the cluster with the higher intercept also has the higher slope, matching the direction of a positive intercept–slope association. A fitted positive covariance would describe that tendency across the distribution of clusters; it would not assert that every individual cluster follows the pattern exactly.

Assumptions, Diagnostics, and Model Choice

The random-effects structure is meaningful only alongside its assumptions. Dose and other predictors must be encoded correctly, and the chosen fixed-effects form must reasonably represent the average dose-response trend. The random-effects distribution is commonly taken to be multivariate normal, with mean zero and covariance \(\Omega\). Conditional on those random effects and the included predictors, the Bernoulli outcomes are assumed independent under the model. If outcomes remain dependent for reasons not represented by the random effects, the stated likelihood may not describe the data adequately.

Check whether the data can support the added flexibility. A random slope needs dose variation within enough clusters to distinguish individual slopes from individual intercepts. If each participant contributes outcomes at only one dose, intercept and slope variation may be difficult or impossible to separate without additional design information. Sparse observations, few clusters, or a narrow dose range can also make slope variances and correlations poorly determined.

  • Inspect fitting behavior. Nonconvergence, unstable estimates across starting values, or a covariance estimate near a boundary can signal weak information or an overly complex structure.
  • Examine the estimated covariance. A correlation near \(1\) or \(-1\), especially with a very small variance, can indicate that the data do not reliably identify both random effects.
  • Check predictions across dose and cluster. Look for systematic mismatches in response frequencies or in the spread of cluster-level patterns. Conditional predictions can help assess cluster patterns, while population predictions average over the random-effects distribution.
  • Consider the dose scale. Extreme predictions at unobserved doses may reflect extrapolation or an inadequate functional form, not simply a need for another random effect.

A random-intercept model is a reasonable simpler choice when clusters differ in baseline log odds but there is little evidence or scientific reason to expect differing dose slopes. A random-intercept-and-slope model is appropriate when dose sensitivity plausibly varies and the design supplies enough within-cluster dose information. An uncorrelated intercept-and-slope model sets \(\omega_{01}=0\); it can be a useful simplification when the correlation is unsupported or difficult to estimate, but it asserts zero covariance rather than proving independence from the data.

A model with fixed cluster indicators can represent separate cluster baselines, but does not provide the same distributional description of between-cluster variation and can use many parameters. Population-averaged approaches target a different interpretation of effects and are not interchangeable with a conditional random-effects model. These alternatives should be chosen based on the scientific estimand and data structure, not just which model converges most easily.

Common Pitfall and Practical Limits

A common mistake is to say that a random intercept means “the response probability is shifted by the same amount at every dose.” The random intercept shifts the log odds by a constant amount; because the inverse-logit transformation is nonlinear, the probability difference is not constant across dose. Another mistake is to interpret a random-slope variance as evidence that every cluster's dose effect is positive or negative. The variance describes a distribution of slopes around the fixed effect; the signs and sizes of individual slopes depend on the fitted distribution.

More parameters do not guarantee a better representation. Random slopes and their correlations may be weakly identified in small or unbalanced studies, and estimated normal random-effects distributions can be a poor approximation if cluster differences are highly unusual or multimodal. Results should be interpreted within the observed dose range and in light of the model's conditional-independence and distributional assumptions.

Key takeaway: A random intercept represents between-cluster baseline variation on the link scale; a random slope represents between-cluster variation in dose response; and their covariance determines how those two features vary together. The design and scientific question should justify each component.

Check Your Understanding

Answer each question, then compare with the brief solutions.

  1. In a random-intercept-only logistic model, what aspect of the response varies across clusters, and what remains common?
  2. If \(\omega_{00}=0.25\), \(\omega_{11}=0.09\), and \(\omega_{01}=0\), calculate the variance of the random contribution to log odds at \(x=2\).
  3. What does a negative intercept–slope covariance indicate, and why can its effect on heterogeneity depend on dose?
  4. Why might random slopes be difficult to estimate when there is little within-cluster dose variation?

Solutions. (1) Baseline log odds vary through the random intercept; the dose slope is common across clusters. (2) The variance is \(0.25+2(2)(0)+2^2(0.09)=0.25+0.36=0.61\) on the log-odds scale. (3) Clusters with higher intercept deviations tend to have lower slope deviations. The covariance term is \(2x\omega_{01}\), so its contribution changes sign with \(x\). (4) Without sufficient dose variation within clusters, observed baseline differences and slope differences are difficult to distinguish, so the slope variance may be weakly identified.