Tutorials › Multiple Imputation by Chained Equations (MICE) › Cross-Classified Data In MICE

Nested and Multilevel Data · Tutorial 368 of 497

Cross-Classified Data In MICE

Specify and check MICE models for observations classified simultaneously by two or more non-nested grouping factors.

Advanced 10 min read

What You'll Learn

  • Identify when group memberships are cross-classified rather than nested.
  • Write a crossed random-effects conditional model for an incomplete variable.
  • Calculate the covariance implied by shared school and neighborhood memberships.
  • Generate continuous and binary imputations while accounting for both classifications.
  • Diagnose sparse or weakly connected classifications and compare crossed models with simpler alternatives.

Why Cross-Classified Structure Matters

An observation can belong to more than one grouping system at once. For example, a student attends one school and lives in one neighborhood. Schools and neighborhoods are cross-classified when neither classification is contained within the other: a school can serve students from several neighborhoods, and a neighborhood can include students attending several schools. The same structure arises when patients are treated by one hospital but live in one of several areas.

If a variable is incomplete, an imputation model that ignores one of these classifications can fail to preserve the dependence associated with that grouping. Treating neighborhoods as if each belonged to a single school, for instance, imposes a nested structure that the data do not have. The model for each incomplete variable should represent the classifications that plausibly explain similarities among observations.

Definition: Data are cross-classified when each observational unit belongs to one category of each of two or more grouping factors, and the grouping factors are not nested within one another. In a school-and-neighborhood example, each student has a school label and a neighborhood label, but neighborhoods are not uniquely assigned to schools.

The group labels are part of the data structure, not ordinary numeric measurements. They must be available for the records being imputed and coded consistently across variables and chains. This tutorial assumes that each record’s group memberships are known. If membership itself is missing or uncertain, simply treating the missing label as an ordinary value does not resolve the problem.

A Crossed Conditional Model

Index observational units by \(i\). Let \(g(i)\) identify unit \(i\)’s school and \(h(i)\) identify its neighborhood. For a continuous incomplete variable \(Y_i\), a basic crossed random-intercepts model is

$$ Y_i = \boldsymbol{x}_i^\mathsf{T}\boldsymbol{\beta} + u_{g(i)} + v_{h(i)} + \varepsilon_i, \qquad u_j \sim N(0,\tau_S^2), \quad v_k \sim N(0,\tau_N^2), \quad \varepsilon_i \sim N(0,\sigma^2). $$

Here \(\boldsymbol{x}_i\) contains the predictors in the conditional imputation model, including any other variables needed to preserve relationships relevant to the analysis. The school effects \(u_j\), neighborhood effects \(v_k\), and unit-level errors \(\varepsilon_i\) are assumed mutually independent, and effects within each grouping factor are independent across groups. The normal model also assumes that the residual variance is suitable for the continuous outcome; if the outcome is strongly skewed or otherwise poorly represented, a different conditional model may be needed.

For a binary incomplete variable, a corresponding specification can use a logit link, with school and neighborhood random intercepts in the linear predictor. Other variable types require conditional models suited to their scales. The essential feature is not a particular link: both grouping factors must be represented in the conditional model when both induce relevant dependence.

In MICE, this is done for each incomplete variable in turn. At an update, the model conditions on the current values of the other variables and the known group memberships. A proper imputation draws model parameters and relevant group effects, then draws a missing value from the resulting predictive distribution. Using only fitted means or probabilities omits predictive variation and is not a proper multiple-imputation draw.

Assumptions and scope: The crossed model assumes that observations sharing a school or neighborhood may be correlated through that factor, while observations are independent conditional on the predictors and both sets of random effects. The random-effects distributions and link or residual model must be adequate for the variable. For valid multiple imputation, the conditional models must also be plausible for the missingness process and include information needed for the intended analysis. As with other chained-equation specifications, a set of conditionals need not correspond to one coherent joint distribution.

What Dependence Does the Model Imply?

The covariance structure follows directly from the model. For two distinct units \(i\) and \(\ell\), their errors are independent, but they share a random effect if they belong to the same school or the same neighborhood. Under the assumptions above,

$$ \operatorname{Cov}(Y_i,Y_\ell \mid \boldsymbol{x}) = \tau_S^2\,I\{g(i)=g(\ell)\} + \tau_N^2\,I\{h(i)=h(\ell)\}. $$

The indicator \(I\{\cdot\}\) equals 1 when its condition holds and 0 otherwise. The formula shows why a single grouping variable can be inadequate: two students can share a neighborhood but attend different schools, or share a school while living in different neighborhoods. A nested model cannot generally represent both patterns without imposing an incorrect grouping relation.

Worked Example: Reading the Crossed Covariance

Suppose a hypothetical continuous test score is measured in points, with school variance \(\tau_S^2=9\) points squared, neighborhood variance \(\tau_N^2=4\) points squared, and residual variance \(\sigma^2=16\) points squared. Consider two different students.

If they attend the same school but live in different neighborhoods, their covariance is \(\operatorname{Cov}(Y_i,Y_\ell)=9(1)+4(0)=9\) points squared. If they live in the same neighborhood but attend different schools, it is \(9(0)+4(1)=4\) points squared. If they share both school and neighborhood, it is \(9(1)+4(1)=13\) points squared.

For one student, both random intercepts and the residual contribute to the variance: \(\operatorname{Var}(Y_i)=9+4+16=29\) points squared. Thus, the model distinguishes shared school, shared neighborhood, and individual-level variation rather than treating all within-group resemblance as one effect.

This covariance calculation is also a useful model check. If the scientific setting suggests meaningful neighborhood resemblance, a school-only model is not justified merely because school is the more familiar grouping variable.

Using the Structure in MICE

Before fitting the chained equations, map each record to every relevant classification. Then specify a conditional model for each incomplete variable that preserves its scale and includes the grouping effects that matter. Include appropriate observed predictors, and retain interactions or nonlinear terms required by the analysis rather than assuming that random intercepts substitute for them.

1
Map the classifications.
For every record, verify the school and neighborhood labels, count the observed records in each group and in each school-by-neighborhood combination, and check that labels are consistent.
2
Choose each conditional model.
Match its outcome distribution to the incomplete variable, include relevant predictors, and represent both crossed group effects where warranted.
3
Draw imputations with uncertainty.
At each update, draw parameters and group effects under the fitted model, then draw the missing value from its predictive distribution. Repeat the chained updates and retain separated completed data sets.
4
Check the resulting imputations.
Review chain behavior and compare observed and imputed values and relationships across both classifications, paying particular attention to sparse combinations.

Group-level predictors need special attention. A covariate that has one value per school should not be treated as if it were independently observed for every student merely because it appears on many student rows. Its information is shared at the school level. Likewise, if a predictor varies only by neighborhood, its role and available information are at that level.

Worked Example: A Continuous MICE Update

Suppose a hypothetical student’s score is missing. In one iteration, a draw from the crossed conditional model has intercept \(50\) points, slope \(2\) points per study-hour, school effect \(3\) points, and neighborhood effect \(-1\) point. The student reports \(4\) study-hours. Suppose the residual variance draw is \(16\) points squared.

The conditional mean for this draw is \(\mu_i=50+(2)(4)+3+(-1)=60\) points. The residual standard deviation is \(\sqrt{16}=4\) points. If the residual draw for this update is \(-2\) points, then the imputed score is \(Y_i^{\mathrm{imp}}=60+(-2)=58\) points.

This is one illustrative draw, not a recommendation to insert the fitted mean for every missing score. In an actual proper imputation, the regression parameters, variance components, and relevant random effects are also drawn to reflect their uncertainty; the residual is then drawn conditional on those values. The example’s displayed coefficients and effects are already draws from their respective distributions.

Worked Example: A Binary Update With Both Group Effects

Consider a hypothetical binary outcome indicating whether a student meets a defined benchmark. In one MICE update, suppose the drawn logistic model has intercept \(-1\), slope \(0.5\) per study-hour, school effect \(0.4\), and neighborhood effect \(-0.3\). For a student with \(2\) study-hours, the linear predictor is \(\eta=-1+(0.5)(2)+0.4-0.3=0.1\).

The probability for this draw is \(p_i=1/(1+\exp(-0.1))\approx0.525\). If the uniform random draw used for the Bernoulli step is \(0.40\), then \(0.40<0.525\), so the imputed value is 1. If the draw were \(0.80\), the value would be 0. This preserves the binary scale and includes both group effects; substituting \(0.525\) itself as the imputed value would not.

Design Limitations, Diagnostics, and Alternatives

Crossed random effects require enough information to distinguish the grouping contributions. If nearly every school appears with only one neighborhood, or if a neighborhood occurs in only one small part of the data, school and neighborhood effects may be difficult to separate. Sparse school-by-neighborhood combinations are not automatically a problem—cross-classified data need not fill every possible combination—but very little overlap can weaken estimation and make extrapolations fragile.

Inspect the membership cross-tabulation and the number of observed records per group. During fitting, check chain traces for imputed-variable summaries and variance components, and look for persistent drift, poor mixing, or implausible estimates. Compare observed and imputed distributions, including within-school and within-neighborhood patterns. A good overall marginal distribution can conceal implausible subgroup behavior. Also check whether key associations required by the substantive analysis are retained.

A single-level conditional model is simpler, but assumes away residual dependence from the groups unless that dependence is captured by other predictors. A nested model is appropriate when one classification is genuinely contained within another; applying it to non-nested memberships misrepresents the structure. Crossed random-effects conditional models directly encode both classifications. A joint model can provide a coherent multivariate distribution, while chained equations allow variable-specific conditional models; neither approach removes the need to justify the group structure, assess fit, or account for parameter uncertainty.

ApproachWhat it representsMain concern for crossed data
Single-level conditional modelPredictor relationships without explicit group effectsCan underrepresent dependence and within-group variation
Nested multilevel modelGroups contained within higher-level groupsImposes containment that may not match the memberships
Crossed conditional model in MICESeparate effects for each non-nested classificationCan be difficult to estimate with sparse or weakly connected memberships
Joint modelA joint distribution with a specified group structureRequires a suitable joint model and distributional assumptions

A common mistake is to code school and neighborhood labels as numeric predictors and fit an ordinary regression, or to place neighborhoods under schools simply to make a nested model run. Numeric labels do not encode the desired random-effect structure, and artificial nesting changes which records are assumed to share an effect. Use crossed grouping terms when the classifications are genuinely crossed, and investigate weakly supported effects rather than treating model convergence alone as proof of adequacy.

Key takeaway: For cross-classified observations, each relevant MICE conditional model should preserve the distinct dependence associated with each non-nested grouping factor. Check the membership structure and the information supporting each effect, and make predictive draws that include parameter, group-effect, and residual uncertainty.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. Students share a school but not a neighborhood. Under the crossed model, which random-effect variance contributes to their covariance?
  2. Suppose two distinct records share both classifications, with \(\tau_S^2=5\) and \(\tau_N^2=2\). What is their covariance under the model?
  3. Why is imputing a missing binary value with its fitted probability not the same as making a proper binary imputation?
  4. Name one feature of the membership pattern that can make school and neighborhood variance components difficult to distinguish.

Solutions. (1) Only the school variance contributes, because the records share a school but not a neighborhood. (2) Their covariance is \(5+2=7\) in the squared units of the outcome, because they share both effects. (3) A fitted probability is a fractional expected value, not a draw on the binary scale; a proper update draws model quantities and then draws 0 or 1 from the implied Bernoulli distribution. (4) For example, if nearly every school is observed with only one neighborhood, there is little overlap to separate the two sources of variation.

Clinical Biostats