Tutorials › Generalized Linear Mixed Models (GLMM) › Intraclass Correlation in Nested Hierarchies

Crossed and Nested Random Effects · Tutorial 506 of 698

Intraclass Correlation in Nested Hierarchies

Learn to calculate and interpret the correlation between observations that share units at different depths of a nested hierarchy.

Advanced 12 min read

What You'll Learn

  • Derive covariance and correlation from the random effects shared by a pair of nested observations.
  • Calculate separate ICCs for pairs sharing a class, school, or other levels of a hierarchy.
  • Interpret an ICC as the fraction of total variance shared on the model’s scale.
  • Distinguish Gaussian response-scale ICCs from latent-scale ICCs in generalized linear mixed models.
  • Identify assumptions and diagnostics that can make a reported ICC misleading.

Why a Nested Hierarchy Has More Than One ICC

In a nested design, two observations may share some units but not others. Two students in the same class share both their class and school; students in different classes at the same school share the school but not the class. Their outcomes therefore share different amounts of modeled variation. A single “the ICC” can conceal this structure: the relevant intraclass correlation depends on which units the pair shares.

The derivation below uses a nested random-intercept model. Its central idea is direct: independent random effects contribute covariance to a pair of outcomes only when both outcomes contain the same random effect. Dividing that shared covariance by the marginal variance gives the correlation.

Definition: An intraclass correlation coefficient (ICC) is the correlation between two distinct outcomes from units in a specified relationship, such as two students in the same class. In a nested random-intercept model, this correlation is the sum of the variance components shared by the pair divided by the total marginal variance. Different relationships within a hierarchy can therefore have different ICCs.

Three Nested Levels: Schools, Classes, and Students

Let student \(i\) be in class \(j\) at school \(k\). Consider the Gaussian random-intercept model

$$ Y_{ijk}=\mathbf{x}_{ijk}^{\mathsf T}\boldsymbol{\beta}+a_k+b_{jk}+\varepsilon_{ijk}, $$

where \(a_k\) is a school random intercept, \(b_{jk}\) is a class-within-school random intercept, and \(\varepsilon_{ijk}\) is the student-level residual. Assume

$$ a_k\sim N(0,\tau_S^2),\qquad b_{jk}\sim N(0,\tau_C^2),\qquad \varepsilon_{ijk}\sim N(0,\sigma^2), $$

with all random effects and residuals mutually independent. The random effects are also assumed independent of the predictors in the fixed part of the model. These assumptions imply a common variance at each level and no additional dependence beyond that induced by shared random effects. The correlations below are marginal over the random effects, conditional on the fixed predictors; the fixed part changes the expected outcomes but does not add covariance under this model.

Deriving the Correlations From Shared Effects

For any one student, the random part of the outcome is \(a_k+b_{jk}+\varepsilon_{ijk}\). Independence makes its variance the sum of the component variances:

$$ \operatorname{Var}(Y_{ijk}\mid \mathbf{x}_{ijk}) =\tau_S^2+\tau_C^2+\sigma^2. $$

For two distinct students in the same class and school, the two outcomes contain the same \(a_k\) and \(b_{jk}\), but have different independent residuals. Their covariance is therefore \(\tau_S^2+\tau_C^2\). For two students in different classes at the same school, only \(a_k\) is shared, so their covariance is \(\tau_S^2\). Students in different schools share neither random intercept, so their covariance is zero.

The correlation is covariance divided by the product of the standard deviations. Since all outcomes have the same marginal variance \(V=\tau_S^2+\tau_C^2+\sigma^2\), each pair’s correlation is its covariance divided by \(V\):

$$ \begin{aligned} \rho_{\text{same class}} &=\frac{\tau_S^2+\tau_C^2}{\tau_S^2+\tau_C^2+\sigma^2},\\ \rho_{\text{same school, different classes}} &=\frac{\tau_S^2}{\tau_S^2+\tau_C^2+\sigma^2},\\ \rho_{\text{different schools}} &=0. \end{aligned} $$

The first ICC is at least as large as the second, because the same-class pair shares every effect shared by the same-school pair, plus the class effect. Both are nonnegative under the independent random-intercept assumptions. The zero correlation for different schools is a model implication, not a universal claim about people at different schools.

Interpretation: For Gaussian outcomes, each ICC is the proportion of total marginal variance associated with random effects shared by the specified pair. For example, an ICC of 0.30 for students in different classes at the same school means that 30% of the modeled marginal variance is attributable to the shared school effect. It does not mean that 30% of students’ outcomes are identical.

Worked Example: Students in Classes and Schools

Suppose a hypothetical fitted Gaussian model estimates school variance \(\tau_S^2=0.30\), class variance \(\tau_C^2=0.50\), and student-level residual variance \(\sigma^2=1.20\), in squared test-score points. Assume the model’s independent random-intercept assumptions are reasonable.

The total marginal variance is \(0.30+0.50+1.20=2.00\) squared points. The correlation for two students in the same class is

$$ \rho_{\text{same class}} =\frac{0.30+0.50}{2.00} =\frac{0.80}{2.00} =0.400. $$

For students in different classes at the same school,

$$ \rho_{\text{same school, different classes}} =\frac{0.30}{2.00} =0.150. $$

Students in different schools have model-implied correlation \(0\). In context, the fitted model assigns 40.0% of marginal test-score variation to effects shared by classmates, compared with 15.0% shared by students at the same school but in different classes. These are model-based associations, not evidence that belonging to a class or school causes a score difference.

Extending the Rule to a Deeper Hierarchy

The same reasoning applies when there are more than two nested grouping levels. Suppose level 1 is the highest level, level \(L\) is the lowest grouping level, and observations have a random intercept at each level as well as an observation-level residual:

$$ Y=\mathbf{x}^{\mathsf T}\boldsymbol{\beta} +\sum_{\ell=1}^{L} U^{(\ell)}+\varepsilon, \qquad \operatorname{Var}\!\left(U^{(\ell)}\right)=\tau_\ell^2, \qquad \operatorname{Var}(\varepsilon)=\sigma^2. $$

Assume the random effects at all levels and the residual are mutually independent, with a common variance within each level. For a pair of distinct observations that share the same unit at levels 1 through \(q\), but diverge below level \(q\), their shared random effects are exactly \(U^{(1)},\ldots,U^{(q)}\). Thus the covariance is \(\sum_{\ell=1}^{q}\tau_\ell^2\), while each observation’s marginal variance is \(\sum_{\ell=1}^{L}\tau_\ell^2+\sigma^2\). Their ICC is

$$ \rho_q= \frac{\displaystyle\sum_{\ell=1}^{q}\tau_\ell^2} {\displaystyle\sum_{\ell=1}^{L}\tau_\ell^2+\sigma^2}. $$

This is a cumulative quantity: moving down the hierarchy to a more closely shared unit adds variance components to the numerator. The formula is not a claim that variance components themselves are correlations. A component must be divided by total variance, and a pair sharing multiple levels must include all the components shared at those levels.

Worked Example: A Four-Level Hierarchy

Consider a hypothetical hierarchy of districts, schools within districts, classes within schools, and students within classes. Suppose the estimated variances for district, school, class, and student-level residual are respectively \(0.16\), \(0.24\), \(0.40\), and \(1.20\), all in squared outcome units. Assume independent random intercepts and a common residual variance. Total variance is \(0.16+0.24+0.40+1.20=2.00\).

Two observations from different schools in the same district share only the district effect. Their ICC is \(0.16/2.00=0.0800\). Two observations from different classes in the same school share both the district and school effects, giving \((0.16+0.24)/2.00=0.200\). Two students in the same class share the district, school, and class effects, giving \((0.16+0.24+0.40)/2.00=0.400\).

The successive values, 0.0800, 0.200, and 0.400, reflect the accumulated shared variance. They answer different questions about pairs of observations; none is a universal ICC for every pair in this hierarchy.

What Changes in a Generalized Linear Mixed Model?

For a generalized linear mixed model, a response-scale variance decomposition is not always available in the same form as for Gaussian outcomes. A common convention for binary GLMMs is to define an ICC on an underlying latent-variable scale. For a logistic random-intercept model, the level-one logistic distribution has variance \(\pi^2/3\). Replacing the Gaussian residual variance with this latent residual variance gives a useful, explicitly scale-dependent ICC. This is not generally the correlation of the observed zero-one outcomes.

Worked Example: A Binary Logistic Model on the Latent Scale

Suppose a hypothetical binary-outcome model has school variance \(0.45\) and class-within-school variance \(0.30\). It uses a logit link and independent random intercepts. Using the conventional latent residual variance \(\pi^2/3\approx3.290\), the latent total variance is \(0.45+0.30+3.290=4.040\).

For two observations in the same class, the latent-scale ICC is

$$ \rho_{\text{same class, latent}} =\frac{0.45+0.30}{4.040} =\frac{0.75}{4.040} \approx 0.186. $$

For observations in different classes at the same school, it is \(0.45/4.040\approx0.111\). These values describe shared variation on the conventional latent scale of the logistic model. They should not be reported as observed-scale correlations between the binary outcomes. Observed-scale dependence also depends on the outcome probabilities and the random-effect distribution; other links may use different latent-scale conventions, and some response distributions do not supply a single conventional level-one residual variance.

Assumptions, Diagnostics, and Alternatives

The formulas are exact for the stated random-intercept model. Before using them, check that the hierarchy reflects the sampling structure, that levels are genuinely nested, and that the model includes the intended random intercept at each level. Independence of random effects, constant variances within levels, and absence of additional shared effects are essential to the simple sums. In Gaussian models, the residual assumptions should also be plausible after accounting for fixed predictors.

Useful checks include examining whether residual spread changes across groups, whether fitted group-level patterns suggest a missing random slope, and whether estimated variance components are near zero or on a boundary. A near-zero estimate can make the corresponding ICC nearly zero; it does not prove that the population variance is exactly zero. ICC estimates also have sampling uncertainty, so avoid treating rounded point estimates as precise constants. For non-Gaussian outcomes, state clearly whether the reported ICC is latent-scale or response-scale.

A random-intercept model is appropriate when grouping shifts the outcome level similarly across predictor values. If group differences in a predictor’s effect are plausible, random slopes can change covariance with predictor values, so one constant ICC may no longer summarize all pairs. Crossed classifications can also make pairs share a unit that is not part of a single nested chain; the nested cumulative formula then does not apply unchanged. A marginal model or a robust covariance approach answers a different modeling question and does not automatically provide the same variance-partition interpretation.

A frequent mistake is to call the class variance \(0.50\) an ICC of 0.50, or to use it as the correlation for every pair in the same school. The correction is to identify the pair’s shared effects, add their variances, and divide by total marginal variance. Another mistake is to interpret a logistic latent-scale ICC as a directly observed binary correlation. Always identify the model scale and the pair relationship in the interpretation.

Key takeaway: In an independent nested random-intercept model, a pair’s covariance is the sum of the variance components for the units it shares. Divide that sum by total marginal variance to obtain its ICC; specify both the shared hierarchy level and the scale.

Check Your Understanding

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

  1. A Gaussian model has school variance \(0.20\), class variance \(0.30\), and residual variance \(1.50\). Find the ICC for two observations in the same class.
  2. Using the same variances, find the ICC for observations in different classes at the same school. Why is it smaller?
  3. In a four-level hierarchy, two observations share levels 1 and 2, with variances \(0.10\) and \(0.25\). The total variance is \(2.00\). Find their ICC.
  4. What scale does the conventional logistic ICC describe, and why should it not automatically be called the observed binary-outcome correlation?

Solutions. 1. Total variance is \(0.20+0.30+1.50=2.00\), and the same-class covariance is \(0.20+0.30=0.50\), so the ICC is \(0.50/2.00=0.250\). 2. The shared covariance is the school variance alone, so the ICC is \(0.20/2.00=0.100\). It is smaller because this pair does not share a class effect. 3. Shared variance is \(0.10+0.25=0.35\), so the ICC is \(0.35/2.00=0.175\). 4. It describes latent-scale correlation under the model’s convention, which uses logistic residual variance \(\pi^2/3\). The observed binary correlation also depends on outcome probabilities and random-effect integration, so the latent-scale ratio is not generally the observed response-scale correlation.

Clinical Biostats