Tutorials › Multiple Imputation by Chained Equations (MICE) › Incorporating Level-2 Predictors

Nested and Multilevel Data · Tutorial 342 of 497

Incorporating Level-2 Predictors

You will build and check a level-1 imputation model that uses observed cluster-level predictors while preserving the distinction between cluster and individual information.

Advanced 12 min read

What You'll Learn

  • Specify a level-1 imputation model with an observed level-2 covariate and a random intercept.
  • State the independence assumptions needed for the model’s marginal moments and within-cluster covariance.
  • Calculate how observed cluster members update a random-intercept prediction for a missing value.
  • Distinguish repeated data-table entries for a cluster covariate from independent individual measurements.
  • Diagnose omissions, inappropriate independence assumptions, and weak between-cluster information.
  • Compare multilevel imputation with ordinary regression and cluster-indicator approaches.

Why a Cluster-Level Predictor Belongs in the Model

Suppose a study records a health outcome for patients nested within clinics. Clinic funding is observed for every clinic, while the outcome is missing for some patients. Funding does not vary from patient to patient within a clinic, but it may help explain why outcomes differ across clinics. A level-1 imputation model that omits funding can therefore miss a relevant source of between-clinic variation.

The key distinction is between where a predictor varies and which outcomes it can help predict. A clinic-level predictor can inform the imputation of patient-level values. Its appearance in each patient’s data-table row is a convenient way to join clinic information to patient records; it does not turn that predictor into a separately measured patient characteristic.

Definition: Let \(j\) index clusters and \(i\) index individuals within cluster \(j\). Let \(X_{ij}\) be a level-1 variable to be imputed, \(Z_{ij}\) a vector of level-1 predictors, and \(W_j\) an observed level-2 predictor that is constant for all individuals in cluster \(j\). Incorporating a level-2 predictor means including \(W_j\) in the conditional model for \(X_{ij}\), while retaining the fact that its value is shared by the cluster.

A Model and Its Assumptions

A common model for a continuous, approximately normal level-1 variable is a random-intercept model:

$$ X_{ij}=\beta_0+\beta_W W_j+\boldsymbol{\beta}_Z^\mathsf{T}Z_{ij}+b_j+\varepsilon_{ij}. $$

Here \(\beta_W\) is the association between the cluster-level predictor and the outcome, conditional on the other included terms. The random intercept \(b_j\) represents residual cluster differences not explained by the predictors. The level-1 residual is \(\varepsilon_{ij}\). For the usual normal-model calculations below, assume \(b_j\sim N(0,\tau^2)\), \(\varepsilon_{ij}\sim N(0,\sigma^2)\), and that random intercepts are independent across clusters.

The independence conditions matter. Assume that the random intercepts are independent of the predictors, and that the residuals are independent of the random intercepts and predictors and mutually independent across individuals. These assumptions imply that, conditional on the predictors and averaging over the random intercept and residual, the mean and variance are:

$$ E(X_{ij}\mid W_j,Z_{ij})= \beta_0+\beta_W W_j+\boldsymbol{\beta}_Z^\mathsf{T}Z_{ij}, \qquad \operatorname{Var}(X_{ij}\mid W_j,Z_{ij})=\tau^2+\sigma^2. $$

For two distinct individuals \(i\) and \(k\) in the same cluster, their only shared random component is \(b_j\). Under the stated independence assumptions, their conditional covariance is \(\tau^2\). Thus the model represents both the relationship with \(W_j\) and residual dependence among outcomes in the same cluster. If residuals and random intercepts are correlated, these moment and covariance expressions need not hold.

For an imputation model, also require that the conditional distribution is an adequate description of the variable being imputed, that the predictors used are appropriate for the analysis, and that the missingness assumptions are credible given the information included. In particular, including an observed \(W_j\) can make missingness more plausibly conditionally independent of the unobserved \(X_{ij}\), but does not guarantee that assumption. There must also be enough between-cluster information to estimate the effect of \(W_j\); many individual rows cannot substitute for a small number of distinct clusters.

How the Predictor Informs an Imputation

The fixed effect \(\beta_W W_j\) shifts the expected value for every member of a cluster according to its observed predictor value. The random intercept then lets observed outcomes in that same cluster provide additional information about the cluster’s residual level. For an individual with missing \(X_{ij}\), the imputation can therefore use both the predictors and the observed outcomes of other members of the cluster.

To make this borrowing explicit, suppose model parameters are known and the other predictors are observed. Subtract the fixed part of the model from each observed value in cluster \(j\), giving residuals \(r_{ij}=x_{ij}-(\beta_0+\beta_W W_j+\boldsymbol{\beta}_Z^\mathsf{T}Z_{ij})\). If there are \(n_j^{\mathrm{obs}}\) observed outcomes in that cluster, normal updating gives:

$$ b_j\mid \text{observed values and predictors} \sim N(m_j,V_j), \qquad V_j=\left(\frac{1}{\tau^2}+\frac{n_j^{\mathrm{obs}}}{\sigma^2}\right)^{-1}, \qquad m_j=V_j\frac{\sum_{i\ \mathrm{observed}}r_{ij}}{\sigma^2}. $$

A missing value with fixed part \(f_{ij}=\beta_0+\beta_W W_j+\boldsymbol{\beta}_Z^\mathsf{T}Z_{ij}\) then has predictive distribution \(N(f_{ij}+m_j,\sigma^2+V_j)\), under these known-parameter assumptions. This is a prediction conditional on the observed outcomes in that cluster, not merely the marginal distribution conditional on \(W_j\) and \(Z_{ij}\). In practice, a proper multiple-imputation procedure also represents uncertainty in model parameters; the known-parameter calculation isolates the role of the cluster information.

Worked Example: The Fixed Effect of an Observed Cluster Predictor

Suppose the fitted fixed part of a hypothetical level-1 model is \(10+3W_j+2Z_{ij}\), where \(W_j\) is a clinic funding category coded 0 or 1 and \(Z_{ij}\) is a centered patient predictor. For a patient with \(Z_{ij}=0\), compare the fixed-part predictions for the two funding categories.

For \(W_j=0\), the fixed part is \(10+3(0)+2(0)=10\). For \(W_j=1\), it is \(10+3(1)+2(0)=13\). Thus the model assigns the second category a fixed-part prediction 3 outcome units higher, conditional on the other included terms.

These are not final predictions for every patient in the two clinics: each patient’s model value also includes the cluster intercept and individual residual. The calculation shows how an observed cluster-level covariate informs the imputation without claiming that funding varies among patients within a clinic.

Worked Example: Updating a Cluster Prediction From Observed Members

Consider a hypothetical model with known parameters \(\beta_0=10\), \(\beta_W=3\), \(\beta_Z=2\), \(\tau^2=4\), and \(\sigma^2=9\). In a clinic with \(W_j=1\), two patients have \(Z_{ij}=0\) and observed outcomes 17 and 20. A third patient also has \(Z_{ij}=0\), but the outcome is missing. Calculate the predictive mean and variance for that missing outcome, conditional on the two observed outcomes.

The fixed part for each patient is \(10+3(1)+2(0)=13\). The two observed residuals are \(17-13=4\) and \(20-13=7\). There are \(n_j^{\mathrm{obs}}=2\) observations, so:

$$ V_j=\left(\frac{1}{4}+\frac{2}{9}\right)^{-1} =\left(\frac{17}{36}\right)^{-1} =\frac{36}{17}\approx 2.118. $$

The posterior mean of the cluster intercept is:

$$ m_j=V_j\frac{4+7}{9} =\frac{36}{17}\cdot\frac{11}{9} =\frac{44}{17}\approx 2.588. $$

The missing patient’s predictive mean is \(13+2.588=15.588\) outcome units, and the predictive variance is \(9+2.118=11.118\) squared outcome units. Its predictive standard deviation is \(\sqrt{11.118}\approx 3.334\) outcome units. A stochastic imputation draws from this predictive distribution (and, in an actual analysis, also accounts for parameter uncertainty); entering 15.588 for every such missing value would omit predictive variation.

Worked Example: Repeated Rows Do Not Create More Clusters

In a hypothetical data set, three clinics have predictor values \(W_j=0,1,2\), respectively. Each clinic has two patients, and their observed outcome values are 5 and 5 in the first clinic, 7 and 7 in the second, and 9 and 9 in the third. Calculate the ordinary row-level least-squares slope of outcome on \(W_j\), and identify what the calculation does and does not establish.

Across the six rows, the mean predictor is \(\bar{x}_W=(0+0+1+1+2+2)/6=1\), and the mean outcome is \(\bar{x}_X=(5+5+7+7+9+9)/6=7\). The slope numerator is \(2[(-1)(-2)]+2[(0)(0)]+2[(1)(2)]=8\). The denominator is \(2(-1)^2+2(0)^2+2(1)^2=4\). Therefore the slope is \(8/4=2\) outcome units per unit of \(W_j\).

The arithmetic describes the observed between-clinic pattern: the mean outcome rises by 2 units for each one-unit increase in the clinic predictor in this small example. But there are only three distinct predictor values, one per clinic. The six rows are not six independent measurements of \(W_j\), and an ordinary regression’s row-independent standard error would not account for within-clinic dependence. A multilevel model represents that dependence; the example alone does not establish precise or generalizable evidence for the slope.

Implementation, Checks, and Alternatives

In a chained-equations setting, the conditional imputation model for \(X_{ij}\) should include the observed \(W_j\), relevant level-1 predictors, and the cluster structure required by the analysis. The value of \(W_j\) is joined to each individual record in its cluster, but its coefficient is learned from comparisons across clusters. For a continuous normal model, the random-intercept specification above is one way to preserve residual clustering while using \(W_j\). The imputation procedure should generate stochastic values rather than replacing missing outcomes by conditional means alone.

Useful checks include the following:

  • Check that \(W_j\) is constant within each cluster and correctly linked to all its individual records.
  • Compare observed and imputed \(X_{ij}\) distributions across values or categories of \(W_j\). Large unexplained discrepancies can indicate a misspecified effect, coding problem, or poor overlap.
  • Inspect whether clusters with observed outcomes show residual patterns that remain after the included predictors and random intercept are considered.
  • Check the number of distinct clusters and the spread of \(W_j\) across them. A coefficient based on very few distinct clusters can be unstable even when the row count is large.
  • Check that imputed values are plausible for the outcome’s scale and that repeated imputations vary. Implausible values or nearly identical imputations can signal a poor conditional model or insufficient stochastic uncertainty.

Ignoring \(W_j\) can leave systematic between-cluster differences unexplained when it is associated with \(X_{ij}\). Ordinary regression with an independent residual for every row may include \(W_j\), but it does not represent shared cluster variation and can give inappropriate uncertainty. Cluster indicators can account for observed cluster-specific differences, but they use a separate indicator for each cluster and cannot estimate a general effect for a level-2 predictor that is constant within each cluster alongside a full set of cluster indicators. A random-intercept model instead allows residual cluster variation while estimating the common association with \(W_j\).

No model choice removes the need for judgment. A linear term may be inadequate if the relationship with \(W_j\) is nonlinear; a normal conditional model may be unsuitable for a strongly non-normal variable; and a level-2 predictor with little variation across clusters offers little information for its effect. This tutorial treats \(W_j\) as observed. It does not address imputing missing cluster-level predictors, nor does adding \(W_j\) alone guarantee a correctly specified imputation model or make a nonignorable missingness process ignorable.

Common Mistake

Common mistake: “The clinic predictor appears on 200 patient rows, so it has been measured independently 200 times and can be treated as a patient-level predictor.” The correction is that those entries repeat one clinic-level value. They may be used to construct each patient’s conditional model, but the predictor varies across clinics, and uncertainty and residual dependence must reflect the clustering. A second error is to assert the marginal variance \(\tau^2+\sigma^2\) or within-cluster covariance \(\tau^2\) without specifying independence of random intercepts, residuals, and predictors. Those expressions rely on the independence assumptions stated above.
Key takeaway: An observed level-2 covariate can explain between-cluster differences in a level-1 variable. Include it at its true cluster level in a model that represents within-cluster dependence; repeating its value across rows does not create individual-level replication.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. In the random-intercept model, what information does \(\beta_W W_j\) provide, and what additional information does \(b_j\) represent?
  2. Why are the usual marginal variance and within-cluster covariance formulas not justified unless the residuals are independent of the random intercepts?
  3. A cluster has one observed residual \(r=3\), with \(\tau^2=2\) and \(\sigma^2=8\). Calculate \(V_j\) and \(m_j\).
  4. A clinic-level variable has the same value on every patient row within each clinic. What is the relevant replication for learning its association with the outcome?
  5. Name one reason that including an observed cluster-level predictor does not by itself guarantee valid imputations.

Solutions. (1) \(\beta_W W_j\) shifts the fixed-part expectation according to the observed cluster predictor; \(b_j\) represents residual cluster-specific deviation after the included predictors. (2) If residuals correlate with the random intercept, their covariance contributes to the total variance and within-cluster covariance, so the formulas based only on \(\tau^2\) and \(\sigma^2\) need not hold. (3) \(V_j=(1/2+1/8)^{-1}=(5/8)^{-1}=1.6\). Then \(m_j=1.6(3/8)=0.6\). (4) The predictor varies across clusters, so its association is informed by the distinct clusters and their predictor values, not by treating repeated entries as independent measurements. (5) For example, the conditional model may be misspecified, there may be too few clusters or insufficient predictor variation, or missingness may depend on unobserved values even after conditioning on included information.

Clinical Biostats