Tutorials › Multiple Imputation by Chained Equations (MICE) › Imputing Three-Level Hierarchies

Nested and Multilevel Data · Tutorial 367 of 497

Imputing Three-Level Hierarchies

Learn to specify three-level chained-equation imputations that respect the distinct roles of individuals, classrooms, and schools.

Advanced 10 min read

What You'll Learn

  • Distinguish individual-, classroom-, and school-level variables in a three-level hierarchy.
  • Specify nested random-intercept conditional models for individual-level incomplete variables.
  • Choose the appropriate analysis unit and random-effects structure for classroom- and school-level variables.
  • Calculate how nested random effects induce different covariances within classrooms and across classrooms.
  • Diagnose hierarchy-related imputation problems and compare multilevel FCS with simpler alternatives.

Why a Third Level Changes the Imputation Model

In nested data, individuals belong to classrooms, and classrooms belong to schools. Two individuals in the same classroom may share conditions beyond those shared by individuals in different classrooms at the same school. All individuals in a school may also share school-wide conditions. An imputation model that accounts only for classroom membership, or treats every record as independent, can therefore misrepresent the dependence in the data.

The key design decision is to identify the level at which each variable is defined. A student's test score varies among students; a classroom teaching approach is shared by students in that classroom; and a school policy is shared across classrooms in that school. A value defined for a classroom or school is one value for that unit, not a collection of independent values repeated for all its students. The imputation procedure should reflect both this structure and the model that will be used for analysis.

Definition: A three-level hierarchy has level-1 units (individuals) nested within level-2 units (classrooms), which are in turn nested within level-3 units (schools). Write \(i\) for an individual, \(j\) for a classroom, and \(k\) for a school; \(Y_{ijk}\) denotes a person-level variable. A classroom-level variable has one value per classroom, and a school-level variable has one value per school.

A Nested Conditional Model for an Individual-Level Variable

For a continuous individual-level variable \(Y\), a basic three-level conditional model is

$$ Y_{ijk}=\beta_0+\boldsymbol{\beta}^{\mathsf T}\mathbf{x}_{ijk} +u_k+v_{jk}+\epsilon_{ijk}, \qquad u_k\sim N(0,\tau^2_{\mathrm{school}}),\quad v_{jk}\sim N(0,\tau^2_{\mathrm{class}}),\quad \epsilon_{ijk}\sim N(0,\sigma^2). $$

Here \(\mathbf{x}_{ijk}\) contains observed or currently imputed predictors, which may be measured at any of the three levels. The school effect \(u_k\) is shared by all individuals in school \(k\); the classroom effect \(v_{jk}\) is shared by individuals in classroom \(j\) of that school; and \(\epsilon_{ijk}\) is individual-level variation. In the basic model, the random effects and residuals are mutually independent, have mean zero, and have the stated variances. Conditional on the predictors and random effects, the residuals are independent and normally distributed.

These assumptions are a starting model, not a guarantee that the model fits. The conditional distribution should suit the variable being imputed: a binary, ordinal, nominal, or count variable requires an appropriate conditional model rather than a normal model for its recorded values. The conditional model should also include relevant predictors and preserve important relationships needed for the analysis. Earlier material on Multilevel Logistic Imputation For Binary Outcomes and Multilevel Count Imputation With Overdispersion covers those outcome-specific choices; the three-level task is to represent the nesting at both higher levels.

In chained equations, a conditional model is fitted for each incomplete variable in turn, using the other variables as predictors and their current observed or imputed values. For an incomplete individual-level variable, the model needs to distinguish variation among individuals within classrooms, classrooms within schools, and schools. Parameter uncertainty and uncertainty in the random effects must be reflected in the imputations; using only fitted conditional means would understate uncertainty and tend to make imputed values too similar.

Key takeaway: For an individual-level variable, a three-level imputation model needs to represent both classroom-within-school and school-level dependence. For a classroom- or school-level variable, impute at that variable's unit of definition, with the appropriate higher-level structure.

What the Hierarchy Implies for Covariance

The random-intercept model also shows why the two higher levels cannot be collapsed without consequences. Consider two different individuals, with no additional predictors in the expression. If they are in the same classroom and school, both share the same \(u_k\) and \(v_{jk}\). If they are in different classrooms of the same school, they share \(u_k\) but not \(v_{jk}\). If they are in different schools, they share neither effect.

$$ \begin{aligned} \operatorname{Cov}(Y_{ijk},Y_{i'jk})&=\tau^2_{\mathrm{school}}+\tau^2_{\mathrm{class}} &&\text{(same classroom, different individuals)},\\ \operatorname{Cov}(Y_{ijk},Y_{i'j'k})&=\tau^2_{\mathrm{school}} &&\text{(different classrooms, same school)},\\ \operatorname{Cov}(Y_{ijk},Y_{i'j'k'})&=0 &&\text{(different schools, under the model).} \end{aligned} $$

For the first line, the shared random effects contribute their variances to the covariance; the independent individual residuals contribute zero. For the second line, the classroom effects are independent, so only the shared school effect contributes. For the third line, all random effects are independent across schools. This is a model-based justification for including two nested random intercepts rather than one: the model can represent different dependence for classmates and for individuals in different classrooms at the same school.

Worked Example: Predicting a Missing Student Score

Suppose a hypothetical continuous score is being imputed from a current conditional model with mean \(50+4x+2z\), where \(x\) is a student's centered study-time measure and \(z\) is a classroom-level centered instructional measure. The school and classroom random-intercept contributions in this model are \(u_k=3\) and \(v_{jk}=-1\). For a student with \(x=1.5\) and \(z=0.5\), calculate the conditional mean before adding individual residual variation.

The relevant model is \(50+4x+2z+u_k+v_{jk}\). Substituting the stated values gives

$$ 50+4(1.5)+2(0.5)+3+(-1) =50+6+1+3-1=59. $$

Thus the conditional mean for this hypothetical student, given the current predictor values and random-effect contributions, is 59 score points. An imputed value is not automatically 59: a proper draw also reflects uncertainty in the model parameters, random effects, and individual-level residual. The calculation illustrates how each level contributes, not a deterministic replacement rule.

Impute Each Variable at Its Own Level

The analysis unit for an incomplete variable is determined by where that variable is defined. An individual-level value is updated for an individual. A classroom-level value is updated once per classroom, and a school-level value once per school. If a classroom-level variable is displayed on each student's row, those repeated entries represent the same classroom value. They do not turn one classroom value into many independent observations.

For a classroom-level incomplete variable, a natural conditional model treats classrooms as the observational units and accounts for their nesting within schools. A school-level predictor is constant among the classrooms in a school; classroom-level predictors and suitably summarized information about students may also be relevant, depending on the substantive model and missingness process. For a school-level incomplete variable, the observational units are schools. Its model may use school-level predictors and relevant summaries of lower-level information. Lower-level records can inform those summaries, but duplicating a school-level value across student rows and fitting an ordinary person-level model would give schools with more students extra weight and an incorrect unit of analysis.

The distinctions can be summarized as follows. The specific conditional distribution must still match the variable type and substantive analysis.

Incomplete variableUnit updatedHierarchy to represent
Individual-levelIndividualsIndividuals within classrooms within schools
Classroom-levelClassroomsClassrooms within schools
School-levelSchoolsSchools as the units; no school random intercept for schools themselves

A variable that is constant within a school cannot be identified as a school-level quantity merely by inspecting a few observed records if many values are missing. Its intended level and the data structure should be established from the study design. When an entire classroom or school has no observed values of a variable, imputation must rely more heavily on predictors and the model; the data contain no within-unit observed values to directly estimate that unit's value. The earlier material on Cluster-Level Covariates With Sparse Observed Clusters is relevant to this limitation.

Worked Example: Imputing a Classroom-Level Variable

Suppose a hypothetical teaching measure \(C_{jk}\), defined once per classroom, is missing for one classroom. A current classroom-level conditional model is \(C_{jk}=10+2S_k+v_k+\eta_{jk}\), where \(S_k\) is a centered school-level predictor, \(v_k\) is a school random effect, and \(\eta_{jk}\) is classroom-level residual variation. For this classroom, \(S_k=1\), the current school effect is \(v_k=-0.5\), and the conditional residual contribution in the current draw is \(0.8\). Find the drawn value under this specified model realization.

Substitution gives

$$ 10+2(1)-0.5+0.8=10+2-0.5+0.8=12.3. $$

The current draw is 12.3 units of the teaching measure. It is assigned once to that classroom and would be the same value for all its student records if the data are stored in student-level rows. The calculation presumes that this conditional model is suitable, including its school-level dependence and residual distribution; it does not justify copying the draw independently to each student.

Worked Example: Imputing a School-Level Variable Without Pseudoreplication

Suppose a hypothetical school policy score \(P_k\) is defined once per school, and the school-level conditional model has current conditional mean \(20+3A_k\), where the centered school-level predictor is \(A_k\). For a school with \(A_k=2\), the mean is \(20+3(2)=26\). If the current parameter-and-error draw adds \(-1.2\), the imputed score is

$$ 20+3(2)-1.2=26-1.2=24.8. $$

The value 24.8 is assigned once to the school, regardless of whether the school has 2 classrooms or 20. A model fitted to student rows that treats all repeated copies of \(P_k\) as independent would instead allow larger schools to contribute more nominal observations of the same policy value. That changes the implied analysis and understates the information limitation: the number of independently defined policy values is the number of schools, not the number of students.

Practical Workflow, Diagnostics, and Alternatives

A three-level chained-equation analysis should make its hierarchy explicit before the chains are run. The following sequence helps prevent a technically converged model from imputing at the wrong level.

1
Map variables to units.
Record whether each variable is defined for individuals, classrooms, or schools, and verify that identifiers uniquely encode each individual’s classroom and school membership.
2
Choose each conditional model.
Use a distribution suitable for the variable and include the relevant predictors. For individual-level variables, account for both nested levels; for higher-level variables, use their level as the observational unit.
3
Run and inspect the chains.
Check traces and summaries across chains, compare observed and imputed distributions, and examine whether within-classroom and between-classroom patterns are plausible at each school.
4
Check the analysis-relevant relationships.
Compare associations and variation at each level in observed data and completed data, while recognizing that checks cannot confirm unobserved values or prove the missingness assumptions.

Common warning signs include chains that drift or fail to mix, imputed values with implausible ranges, and imputed individual outcomes that show too little similarity among classmates or among individuals in the same school. For higher-level variables, inspect the number of distinct imputed values: a school-level variable should not vary among students in one school. Also check whether the imputation procedure inadvertently gives large schools disproportionate influence on a school-level conditional model.

The principal alternative is a single-level conditional model that ignores the hierarchy. It may be simpler to fit, but it assumes away the dependence represented by the random effects and can distort uncertainty and relationships across levels. A joint multilevel model offers a coherent joint distribution for the variables, whereas multilevel chained equations specify a series of conditional models. Either approach must represent the three-level structure well enough for the intended analysis. As with other chained-equation procedures, separate conditional models need not correspond to one compatible joint distribution; apparent chain stability does not establish compatibility or eliminate model misspecification.

The basic random-intercept model also has limits. It assumes a particular distribution for the effects and residuals, and it may be inadequate if effects vary across schools or classrooms in ways not represented by the model, if predictors have nonlinear relationships, or if missingness depends on unobserved values after conditioning on included information. More elaborate conditional models may be needed, but complexity is not a substitute for enough information at each level. With few schools, school-level quantities and variance components may be weakly informed; repeated student records cannot manufacture additional independent schools.

Common Mistakes

  • Using only one random intercept. Classmates and students in different classrooms of the same school share different portions of the dependence. The correction is to represent both classroom-within-school and school-level variation when appropriate.
  • Imputing a cluster-level value on every student row as though each copy were independent. This treats repeated representations of one value as independent information. Impute at the level where the variable is defined and map the resulting value back to the records.
  • Using a multilevel normal model for every variable. A hierarchy does not make a normal outcome model suitable for binary or count data. Choose a conditional distribution appropriate to the variable type.
  • Treating a good-looking trace plot as proof of validity. Stable chains do not show that the model preserves the hierarchy, that the conditional models are compatible, or that missingness assumptions hold. Check distributions and level-specific relationships as well.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. In the random-intercept model, what covariance is implied for two different students in the same school but different classrooms?
  2. A school-level policy is missing. Should it be imputed independently for every student record? Explain.
  3. Why can a single classroom random intercept fail to represent a three-level hierarchy?
  4. If the school random-effect variance is 4 and the classroom random-effect variance is 3, what covariance does the model imply for two classmates, and for students in different classrooms of the same school?

Solutions. (1) The covariance is \(\tau^2_{\mathrm{school}}\), because only the school effect is shared. (2) No. The policy is one value per school, so it should be imputed once per school using a school-level conditional model; independently imputing repeated copies would misrepresent the unit and create inconsistent values. (3) A classroom-only intercept does not distinguish the school-wide dependence shared by different classrooms in the same school from classroom-specific dependence. (4) Classmates have covariance \(4+3=7\); students in different classrooms of the same school have covariance \(4\), in the model’s squared outcome units.

Clinical Biostats