Tutorials › Multiple Imputation by Chained Equations (MICE) › Drawing Random Effects For Proper Imputation

Nested and Multilevel Data · Tutorial 363 of 497

Drawing Random Effects For Proper Imputation

See how drawing, rather than plugging in, cluster effects carries cluster-level uncertainty into imputed values and between-imputation variation.

Advanced 10 min read

What You'll Learn

  • Derive the conditional distribution of a random intercept given observed outcomes in a cluster.
  • Draw cluster effects and missing outcomes in the correct sequence.
  • Quantify how random-effect draws contribute to predictive variance and covariance.
  • Compare sampled effects with plug-in predictions and fixed cluster indicators.
  • Diagnose imputation procedures that omit or incorrectly draw cluster effects.

Why Draw a Cluster Effect?

In a multilevel imputation model, observations in the same cluster share a latent effect. That effect represents a cluster-specific departure from the population regression line. When outcomes are missing, the cluster effect helps predict them; but it is not known exactly, even when some outcomes in the cluster are observed. Replacing it with a single estimate treats an uncertain quantity as known and can make the imputations too similar.

The earlier material on updating imputations with latent cluster effects describes how such effects enter a chained-equations update. Here the focus is the next step: drawing an effect for each cluster, rather than fixing it at an estimate, and understanding the uncertainty that draw carries into the completed data.

Definition: A random-effect draw is a simulated value of a cluster-specific latent effect from its conditional distribution given the current model parameters and the available data for that cluster. In multiple imputation, a fresh draw is made for each cluster in each completed-data replicate. The draw represents uncertainty about the effect; it is not merely a different numerical method for calculating a point prediction.

Model and Conditional Distribution

Consider a normal random-intercept model for a continuous variable being imputed:

$$ Y_{ij} = \mathbf{x}_{ij}^{\mathsf T}\boldsymbol{\beta} + u_j + \varepsilon_{ij}, \qquad u_j \sim N(0,\tau^2), \qquad \varepsilon_{ij} \sim N(0,\sigma^2). $$

Here \(i\) indexes individuals and \(j\) indexes clusters. The predictors \(\mathbf{x}_{ij}\) and their coefficients \(\boldsymbol{\beta}\) give the fixed part of the model. The cluster effect \(u_j\) is shared by all individuals in cluster \(j\), while the individual errors \(\varepsilon_{ij}\) are independent across individuals and independent of the random effects. For this derivation, treat \(\boldsymbol{\beta}\), \(\tau^2\), and \(\sigma^2\) as fixed at their current values. The conditional distribution is therefore conditional on those values as well as the current predictor values.

Suppose there are \(n_j^{\mathrm{obs}}\) observed outcomes in cluster \(j\), and define the residual for each observed outcome as \(r_{ij}=y_{ij}-\mathbf{x}_{ij}^{\mathsf T}\boldsymbol{\beta}\). With a normal prior \(u_j\sim N(0,\tau^2)\), the conditional distribution of \(u_j\) given the observed outcomes is normal:

$$ u_j \mid \text{observed outcomes},\boldsymbol{\beta},\tau^2,\sigma^2 \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\in\mathrm{obs}(j)}r_{ij}}{\sigma^2}. $$

The mean \(m_j\) balances the prior mean of zero against the cluster's observed residuals. The variance \(V_j\) is positive when the prior variance is positive and finite; it decreases as the cluster supplies more observed outcomes, because those outcomes provide information about its effect. Even with many observations, \(V_j\) is not generally zero.

Why the Conditional Distribution Has This Form

The prior density for \(u_j\) is proportional to \(\exp[-u_j^2/(2\tau^2)]\). Given \(u_j\), each observed residual has a normal density proportional to \(\exp[-(r_{ij}-u_j)^2/(2\sigma^2)]\). Multiplying prior and likelihood gives the conditional density, up to a factor that does not depend on \(u_j\):

$$ p(u_j\mid \mathbf{r}_j) \propto \exp\left\{-\frac{1}{2} \left[ \frac{u_j^2}{\tau^2} +\frac{\sum_{i\in\mathrm{obs}(j)}(r_{ij}-u_j)^2}{\sigma^2} \right]\right\}. $$

To identify its normal distribution, collect the terms involving \(u_j\) inside the brackets. The quadratic coefficient is \(1/\tau^2+n_j^{\mathrm{obs}}/\sigma^2\), and the linear term is \(-2u_j\sum r_{ij}/\sigma^2\). Completing the square gives:

$$ \left(\frac{1}{\tau^2}+\frac{n_j^{\mathrm{obs}}}{\sigma^2}\right) \left(u_j- \frac{\sum r_{ij}/\sigma^2}{1/\tau^2+n_j^{\mathrm{obs}}/\sigma^2}\right)^2 +\text{a term not involving }u_j. $$

The center of this square is \(m_j\), and the reciprocal of its quadratic coefficient is \(V_j\). This yields the stated conditional normal distribution. The derivation assumes the normal random-intercept model, independent normal individual errors, and the specified prior distribution for \(u_j\). If the imputation model uses random slopes or a different outcome distribution, the relevant conditional distribution changes; this formula should not be transferred unchanged.

Worked Example: Drawing an Effect for One Cluster

Suppose a hypothetical cluster has three observed outcomes. After subtracting each fixed-part fitted value, their residuals are \(2\), \(-1\), and \(3\) outcome units. Let \(\tau^2=4\) and \(\sigma^2=9\), in squared outcome units. Calculate the conditional distribution of \(u_j\), then illustrate two independent draws.

The residual sum is \(2+(-1)+3=4\). The conditional variance is:

$$ V_j=\left(\frac{1}{4}+\frac{3}{9}\right)^{-1} =\left(\frac{7}{12}\right)^{-1} =\frac{12}{7}\approx 1.714. $$

The conditional mean is:

$$ m_j=\frac{12}{7}\frac{4}{9} =\frac{16}{21}\approx 0.7619. $$

Thus \(u_j\) has conditional standard deviation \(\sqrt{12/7}\approx1.309\). To illustrate the simulation, use independent standard-normal values \(z=1.2\) and \(z=-0.7\) for two imputations. The corresponding draws are:

$$ u_j^{(1)}=0.7619+1.309(1.2)\approx 2.333, \qquad u_j^{(2)}=0.7619+1.309(-0.7)\approx -0.1546. $$

These are simulated draws, not two competing estimates of a fixed cluster effect. Each is plausible under the same conditional distribution and reflects uncertainty remaining after the three observed outcomes are used.

Use One Draw for the Whole Cluster

For a missing outcome, draw the cluster effect first, then draw an individual error and form the imputed value. If the fixed-part prediction for that individual is \(\mathbf{x}_{ij}^{\mathsf T}\boldsymbol{\beta}\), then the imputation is:

$$ Y_{ij}^{\mathrm{mis}}= \mathbf{x}_{ij}^{\mathsf T}\boldsymbol{\beta} +u_j^{\mathrm{draw}} +\varepsilon_{ij}^{\mathrm{draw}}, \qquad \varepsilon_{ij}^{\mathrm{draw}}\sim N(0,\sigma^2). $$

The same drawn \(u_j\) must be used for every missing observation in cluster \(j\) within that imputation. The individual errors are separately drawn. Across imputations, draw a new \(u_j\) for each cluster, using its conditional distribution based on the information available in that imputation. In chained equations, that information includes the current values of the other predictors in the conditional model.

Worked Example: Turning an Effect Draw Into an Imputed Value

Continue the hypothetical example above. Suppose the fixed-part prediction for a missing outcome is 20 units. In the first imputation, use the effect draw \(u_j^{(1)}\approx2.333\) and an individual-error draw of \(3(0.5)=1.5\) units. Then:

$$ Y_{ij}^{\mathrm{mis},(1)} =20+2.333+1.5 \approx23.833\text{ units}. $$

In the second imputation, use \(u_j^{(2)}\approx-0.1546\) and an individual-error draw of \(3(-0.4)=-1.2\) units. This gives:

$$ Y_{ij}^{\mathrm{mis},(2)} =20-0.1546-1.2 \approx18.645\text{ units}. $$

Both imputations use the same model and fixed-part prediction. Their difference reflects two sources of predictive variation: uncertainty about the cluster effect and individual-level residual variation. The standard-normal values here make the arithmetic transparent; an actual implementation obtains them from a random-number generator.

Worked Example: Shared Uncertainty for Two Missing Outcomes

Suppose two outcomes are missing in the same cluster, both with fixed-part predictions of 20 units. Use the conditional variance \(V_j=12/7\) from the first example, and assume individual errors are independent with variance \(\sigma^2=9\). Each imputed outcome has conditional predictive variance:

$$ \operatorname{Var}(Y_{ij}^{\mathrm{mis}}\mid\text{observed data}) =V_j+\sigma^2 =\frac{12}{7}+9 =\frac{75}{7} \approx10.714\text{ squared units}. $$

Because the two missing outcomes share the same random effect, their conditional covariance is:

$$ \operatorname{Cov}(Y_{1j}^{\mathrm{mis}},Y_{2j}^{\mathrm{mis}}\mid\text{observed data}) =\operatorname{Var}(u_j\mid\text{observed data}) =\frac{12}{7} \approx1.714\text{ squared units}. $$

The shared effect induces a correlation of \((12/7)/(75/7)=0.16\). If an effect were fixed at its conditional mean and only independent individual errors were drawn, the imputed outcomes would have variance 9 each and covariance zero under this conditional calculation. That procedure would omit both the effect's contribution to predictive variance and the dependence it creates between missing outcomes.

How the Draw Affects Between-Imputation Uncertainty

Multiple imputation carries uncertainty into analysis by producing \(M\) completed data sets, calculating an estimate \(Q_m\) and its estimated variance \(U_m\) in each, and combining the results. For a scalar estimate, the average estimate is \(\bar{Q}=M^{-1}\sum_m Q_m\), the between-imputation variance is \(B=(M-1)^{-1}\sum_m(Q_m-\bar{Q})^2\), and the conventional total variance estimate is \(T=\bar{U}+(1+1/M)B\), where \(\bar{U}=M^{-1}\sum_m U_m\). These quantities are introduced here only to show where random-effect draws matter: changes in completed values can change \(Q_m\), and hence \(B\).

Drawing effects does not guarantee that every finite set of imputations has a larger \(B\) than a plug-in procedure. Random draws can increase or decrease a particular estimate by chance. The point is that effect draws allow the imputations to reflect variation in effects that are uncertain under the model. Fixing effects at estimates removes that source of variation by construction and can understate between-imputation uncertainty.

Worked Example: Comparing Between-Imputation Variance

For a deliberately hypothetical scalar analysis estimate, suppose four proper imputations give \(Q_m=12,13,11,14\). Their mean is \(\bar{Q}=12.5\), and:

$$ B=\frac{(12-12.5)^2+(13-12.5)^2+(11-12.5)^2+(14-12.5)^2}{4-1} =\frac{5}{3}\approx1.667. $$

For comparison, suppose a plug-in-effect procedure gives \(Q_m=12,12.5,11.5,13\). Its mean is \(12.25\), and its between-imputation variance is:

$$ B_{\mathrm{plug\text{-}in}} =\frac{(12-12.25)^2+(12.5-12.25)^2+(11.5-12.25)^2+(13-12.25)^2}{3} =\frac{1.25}{3}\approx0.4167. $$

If both procedures had the same \(\bar{U}=4\), the corresponding total variance estimates would be \(4+1.25(1.667)\approx6.083\) and \(4+1.25(0.4167)\approx4.521\), respectively. These stipulated values illustrate how suppressed between-imputation variation can affect a pooled standard error; they do not establish that the first procedure must produce a larger \(B\) in every finite run.

Assumptions, Checks, and Alternatives

A random-effect draw is useful only within a defensible imputation model. For the normal formula above, check that the continuous outcome is reasonably represented by the conditional normal model, that the random-intercept structure is appropriate for the clustering, and that the residual assumptions are plausible. In a missing-data application, the conditional imputation model must also be suitable for the observed variables and missingness assumptions relevant to the analysis. Drawing an effect does not repair a misspecified model or make an unsuitable missingness assumption valid.

Useful diagnostics include checking convergence and mixing of the imputation chains, the distribution of drawn effects across clusters and imputations, and the distribution of observed and imputed outcomes within clusters. Compare cluster means and within-cluster variation in observed and completed data. Investigate effects that are extreme, implausibly concentrated near zero, or inconsistent with the observed cluster patterns. Such patterns may signal poor model fit, coding problems, or inadequate information; they should not be addressed by simply forcing the draws toward a preferred result.

A common mistake is to use the conditional mean \(m_j\), or a best linear unbiased prediction (BLUP), as though it were the known effect. The correction is to sample \(u_j\) from its conditional distribution so that residual uncertainty remains in each imputation. Another mistake is to draw a separate effect for each missing individual. That destroys the shared cluster contribution and fails to preserve the within-cluster dependence implied by the model.

ApproachWhat it doesMain consequence
Draw a conditional random effectSamples a shared cluster effect for each cluster and imputationRetains cluster-effect uncertainty and induced dependence, conditional on the model parameters used
Plug in a conditional mean or BLUPUses one estimated cluster effect throughoutOmits uncertainty about that effect from the imputed values
Use fixed cluster indicatorsFits a separate fixed parameter for each represented clusterDoes not provide the same random-effects distribution for cluster effects and may not suit the intended multilevel model
Set the effect to zeroUses only the fixed part of the modelIgnores observed cluster departures and the clustering structure

The conditional draw described here isolates uncertainty in the random effects while treating model parameters as fixed. A fully proper procedure must also account for relevant uncertainty in estimated parameters. In particular, uncertainty in variance components is a separate issue; drawing random effects conditional on fixed variance components does not account for it. The method also depends on having a suitable conditional model and enough information or an appropriate prior to define its draws. It is not a substitute for checking the model or the imputation assumptions.

Key takeaway: In a multilevel imputation, a cluster effect is uncertain even after observing data from that cluster. Draw one effect per cluster per imputation, use it for all missing observations in that cluster, and then draw individual residuals. This preserves a source of predictive uncertainty and the dependence shared by cluster members.

Check Your Understanding

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

  1. In the normal random-intercept model, why is the conditional variance of \(u_j\) positive when a cluster has observed outcomes?
  2. A cluster has two missing outcomes. Should one effect be drawn for each outcome or one effect shared by both? Why?
  3. With conditional effect variance \(V_j=2\) and residual variance \(\sigma^2=5\), what is the predictive variance of one missing outcome and the covariance of two missing outcomes in the same cluster?
  4. Does drawing a random effect, while holding all model parameters fixed, account for all parameter uncertainty in a fully proper imputation procedure?

Solutions. (1) The posterior precision is \(1/\tau^2+n_j^{\mathrm{obs}}/\sigma^2\), which is positive and finite under positive finite variances and finite cluster size. Its reciprocal, \(V_j\), is therefore positive: observed data reduce uncertainty but do not generally eliminate it. (2) Draw one shared effect for the cluster, then draw a separate individual error for each outcome. The shared effect creates the dependence implied by the model. (3) The variance is \(V_j+\sigma^2=2+5=7\) squared outcome units; the covariance is \(V_j=2\) squared outcome units. (4) No. This draw represents random-effect uncertainty conditional on the parameter values used. Other relevant parameter uncertainty, including uncertainty in variance components, must be handled separately for a fully proper procedure.

Clinical Biostats