Tutorials › Multiple Imputation by Chained Equations (MICE) › Random Slopes In Imputation Models

Nested and Multilevel Data · Tutorial 351 of 497

Random Slopes In Imputation Models

Specify a random-slope conditional imputation model, interpret its variance and covariance components, and recognize evidence that a random intercept is inadequate.

Advanced 13 min read

What You'll Learn

  • Write a two-level normal imputation model with a cluster-varying within-cluster slope.
  • Distinguish the random-intercept variance, random-slope variance, and their covariance.
  • Calculate how random slopes affect the covariance between two observations in one cluster.
  • Identify data patterns and diagnostics that can signal a need for random slopes.
  • Compare random-slope, random-intercept, and cluster-indicator approaches, including their limitations.

Why a Random Slope Can Matter

In multilevel imputation, a random intercept lets clusters differ in their baseline levels while retaining a common relationship between a level-1 predictor and the variable being imputed. That common-slope assumption can be too restrictive. For example, the association between a person-level measure and an incomplete health score might be weak in some clinics and strong in others. If the imputation model forces one slope, it can miss real within-cluster structure and distort associations in completed data.

This tutorial specifies a random-slope model for a continuous level-1 variable being imputed. It focuses on what the model assumes, what its covariance parameters mean, and when the extra slope variation is substantively justified. It does not follow that every imputation model should include every possible random effect: the choice should reflect the data structure and the analysis the imputations must support.

Definition: A random-slope imputation model allows the conditional association between a level-1 predictor and the incomplete level-1 variable to vary across clusters. In addition to a cluster-specific intercept, it includes a cluster-specific deviation from the average slope.

Model Specification and Assumptions

Let \(X_{ij}\) be a continuous level-1 variable with missing values for individual \(i\) in cluster \(j\). Suppose \(W_{ij}\) is a level-1 predictor included in the conditional imputation model, and \(Z_j\) is a vector of cluster-level predictors. Write \(W_{ij}-\bar W_j\) for the within-cluster deviation of \(W_{ij}\) from its cluster mean. A useful normal random-intercept-and-slope specification is:

$$ X_{ij} = \beta_0 + \beta_W(W_{ij}-\bar W_j) + \beta_B\bar W_j + \boldsymbol{\gamma}^{T}Z_j + u_{0j} + u_{1j}(W_{ij}-\bar W_j) + \varepsilon_{ij}. $$

The fixed coefficient \(\beta_W\) is the average within-cluster association: the expected change in \(X\) for a one-unit increase in \(W\) relative to the cluster mean, holding the other model terms fixed. The coefficient \(\beta_B\) represents the association with the cluster mean of \(W\). The term \(u_{0j}\) is cluster \(j\)'s deviation from the average intercept, and \(u_{1j}\) is its deviation from the average within-cluster slope. Thus the cluster-specific within-cluster slope is \(\beta_W+u_{1j}\). Centering \(W\) makes the intercept deviation correspond to the expected cluster departure at the cluster mean of \(W\), rather than at an arbitrary zero of the original scale.

$$ \begin{pmatrix}u_{0j}\\u_{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), \qquad \varepsilon_{ij}\sim N(0,\sigma^2). $$

The random effects are assumed independent across clusters and independent of the residuals. Conditional on the random effects and included predictors, residuals are independent across individuals, have mean zero, and share variance \(\sigma^2\). The random-effects covariance matrix must be positive semidefinite; in particular, \(\tau_{00}\geq 0\), \(\tau_{11}\geq 0\), and \(\tau_{01}^2\leq\tau_{00}\tau_{11}\). These assumptions describe a normal linear mixed model for the conditional distribution used to impute \(X\). They do not, by themselves, justify the missingness assumption: the included observed information must also be adequate for the missingness and analysis context.

In an iterative imputation procedure, the other variables in the conditional model may include observed variables and current imputations. Any cluster means used in the model must be defined consistently from the available or current completed values. Including a random slope is useful only if the predictor's within-cluster variation is relevant and the data contain information about how its association varies between clusters.

Worked Example: Reading the Model for a Hypothetical Clinic Dataset

Suppose a hypothetical dataset has patients nested in clinics. The incomplete variable \(X_{ij}\) is a symptom score, \(W_{ij}\) is a patient-level exposure, and \(Z_j\) is a clinic-level indicator. Consider a clinic with \(\bar W_j=4\), \(W_{ij}=6\), \(Z_j=0\), random-intercept deviation \(u_{0j}=-1\), and random-slope deviation \(u_{1j}=0.4\). Let \(\beta_0=10\), \(\beta_W=2\), \(\beta_B=0.5\), and \(\gamma=1\).

The within-clinic deviation is \(W_{ij}-\bar W_j=6-4=2\). Substitution into the conditional mean gives:

$$ 10 + 2(2) + 0.5(4) + 1(0) - 1 + 0.4(2) = 10 + 4 + 2 + 0 - 1 + 0.8 = 15.8. $$

The model's conditional mean for this patient's symptom score is 15.8 points. The clinic-specific within-clinic slope is \(\beta_W+u_{1j}=2+0.4=2.4\) score points per exposure unit. The number 15.8 is a conditional mean, not a completed imputed value: a stochastic imputation also reflects residual and parameter uncertainty.

What the Covariance Structure Means

The two random effects can vary together. The parameter \(\tau_{00}\) is the between-clinic variance in intercept deviations, \(\tau_{11}\) is the between-clinic variance in slope deviations, and \(\tau_{01}\) is their covariance. A positive \(\tau_{01}\) means clusters with higher-than-average intercepts tend, under the model, to have higher-than-average slopes; a negative value means the deviations tend to move in opposite directions. The covariance is not itself a correlation. When both variances are positive, the correlation is \(\tau_{01}/\sqrt{\tau_{00}\tau_{11}}\).

A short derivation shows why this structure matters. Put \(w_{ij}=W_{ij}-\bar W_j\), and condition on the predictors. The shared random part of \(X_{ij}\) is \(u_{0j}+u_{1j}w_{ij}\). For two distinct individuals \(i\) and \(k\) in the same cluster, independence of their residuals from each other and from the random effects gives:

$$ \begin{aligned} \operatorname{Cov}(X_{ij},X_{kj}\mid W,Z) &=\operatorname{Cov}(u_{0j}+u_{1j}w_{ij},u_{0j}+u_{1j}w_{kj})\\ &=\tau_{00}+(w_{ij}+w_{kj})\tau_{01}+w_{ij}w_{kj}\tau_{11}. \end{aligned} $$

For one individual, the conditional variance also includes the individual residual variance:

$$ \operatorname{Var}(X_{ij}\mid W,Z) =\tau_{00}+2w_{ij}\tau_{01}+w_{ij}^{2}\tau_{11}+\sigma^2. $$

Unlike a random-intercept-only model, the random-slope model generally gives different covariance and variance values at different predictor values. This is the key covariance implication of allowing the within-cluster association to vary.

Worked Example: Calculating Within-Cluster Covariances

Use the hypothetical covariance parameters \(\tau_{00}=4\), \(\tau_{11}=0.25\), \(\tau_{01}=-0.5\), and \(\sigma^2=9\). These are admissible because \(4(0.25)-(-0.5)^2=1-0.25=0.75\geq 0\). Consider two distinct individuals with centered predictor values \(w_{ij}=-1\) and \(w_{kj}=2\).

Their conditional covariance is:

$$ 4+(-1+2)(-0.5)+(-1)(2)(0.25) =4-0.5-0.5 =3. $$

For the individual at \(w=-1\), the conditional variance is:

$$ 4+2(-1)(-0.5)+(-1)^2(0.25)+9 =4+1+0.25+9 =14.25. $$

For the individual at \(w=2\), it is:

$$ 4+2(2)(-0.5)+(2)^2(0.25)+9 =4-2+1+9 =12. $$

The model therefore assigns a covariance of 3 score-squared units to this pair and different conditional variances at the two predictor values. These are model-implied quantities, not empirical guarantees that the model fits the hypothetical data.

When a Random Intercept Alone Is Inadequate

A random-intercept-only model permits clinic baselines to differ but requires a common within-clinic slope. Under the assumptions above, its covariance between distinct individuals in the same cluster is constant across their predictor values. A random slope is worth considering when the scientific context or observed data indicate that cluster-specific associations differ, not merely because individuals are clustered.

For example, residual patterns may show that a common-slope fit systematically overpredicts \(X\) at high values of \(W\) in some clusters and underpredicts it in others. Estimates of cluster-specific slopes may also show substantial variation beyond what would be expected from sampling noise. Such patterns are diagnostic clues, not a rule that a random-slope model must be selected. Examine whether the model is identifiable and stable, whether there is meaningful within-cluster variation in \(W\), and whether conclusions for the substantive analysis depend on representing slope variation.

Worked Example: A Common Slope Misses Cluster-Specific Trends

In a hypothetical dataset, two clinics have similar average symptom scores near the cluster mean of an exposure, but their estimated symptom-score changes differ. Suppose the fitted average within-clinic slope is 0.7 points per exposure unit. Clinic A's slope is 0.1, and Clinic B's slope is 1.3. Thus their slope deviations are \(u_{1A}=0.1-0.7=-0.6\) and \(u_{1B}=1.3-0.7=0.6\).

Compare predicted changes between a patient at \(w=-2\) and one at \(w=2\), a difference of four exposure units. In Clinic A the change is \(0.1(2-(-2))=0.4\) symptom-score points. In Clinic B it is \(1.3(2-(-2))=5.2\) points. A common-slope model instead forces the change to be \(0.7(4)=2.8\) points in both clinics. A random intercept cannot repair this mismatch: it shifts both predicted values in a clinic by the same amount and therefore cancels when their difference is calculated. This pattern supports considering a random slope, subject to adequate information and model checking.

Choice, Diagnostics, and Limitations

The alternatives differ in what kinds of cluster variation they represent. Cluster indicators can allow cluster-specific intercepts, but a common predictor slope remains unless cluster-by-predictor terms are added. A random intercept is more parsimonious but still imposes a common slope. A random-slope model estimates a distribution of cluster slopes, requiring more information and stronger distributional assumptions.

ApproachCluster structure representedImportant limitation
Cluster indicatorsSeparate cluster baselinesDoes not allow slope variation unless interactions are added; many cluster parameters may be needed
Random interceptBetween-cluster baseline variationForces one common within-cluster slope
Random intercept and slopeBaseline and within-cluster slope variation, including their covarianceRequires enough information to estimate slope variation and its covariance reliably

Useful checks include reviewing within-cluster ranges of \(W\), inspecting residual patterns by cluster and predictor value, and checking whether estimated slope variation is plausible and stable. A random slope is difficult to learn when many clusters have little or no within-cluster variation in \(W\); a singleton cluster, for example, cannot by itself reveal a within-cluster slope. Sparse information across clusters can also produce unstable variance or covariance estimates. A near-zero estimate of \(\tau_{11}\) suggests little estimated slope variation in that fit, but it is not proof that the true variation is exactly zero.

The normal model is not automatically suitable for every target variable. It assumes a continuous target with a conditionally linear mean and normal residual and random-effect distributions. A random slope does not fix a misspecified functional form, omitted predictors, or an unsuitable outcome distribution. It also cannot compensate for missingness assumptions or lack of overlap that are not addressed by the variables and model. Model choice should be considered alongside the relationships needed in the analysis, rather than made from a single fit statistic.

Common pitfall: “The clusters have different average levels, so a random intercept captures all important cluster differences.” This conclusion confuses variation in baselines with variation in associations. A random intercept changes the fitted level for every individual in a cluster by the same amount; it cannot change the within-cluster difference in predicted \(X\) across values of \(W\). If that difference varies across clusters, a random slope or another justified representation of slope heterogeneity is needed.
Key takeaway: A random slope adds a cluster-specific deviation to a fixed within-cluster association. Its variance measures slope heterogeneity, its covariance with the random intercept describes how baselines and slopes co-vary, and both components alter the model-implied dependence of observations within clusters.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. In the model, what does \(\tau_{11}\) measure, and what does \(\tau_{01}\) measure?
  2. Suppose \(\tau_{11}=0\). What does this imply about the model's cluster-specific slopes?
  3. For two individuals in the same cluster, why can a random intercept alone not produce different predicted changes across values of \(W\)?
  4. What information is particularly weak when a cluster has no within-cluster variation in \(W\)?

Solutions. (1) \(\tau_{11}\) is the variance of cluster-specific slope deviations; \(\tau_{01}\) is the covariance between intercept and slope deviations. (2) The random slope deviation has zero variance, so the model reduces to a common within-cluster slope, apart from any other explicitly specified interactions. (3) A random intercept adds the same amount to both predictions, so it cancels in their difference; the common slope fixes that difference for all clusters. (4) The cluster provides little or no information about its within-cluster association between \(W\) and \(X\), so it cannot independently identify a cluster-specific slope.

Clinical Biostats