Distribution-free inference with hierarchical data

Yonghoon Lee, Rina Foygel Barber, Rebecca Willett · DOI

Abstract: This paper studies distribution-free inference in settings where the data set has a hierarchical structure—for example, groups of observations, or repeated measurements. In such settings, standard notions of exchangeability may not hold. To address this challenge, a hierarchical form of exchangeability is derived, facilitating extensions of distribution-free methods, including conformal prediction and jackknife+. While the standard theoretical guarantee obtained by the conformal prediction framework is a marginal predictive coverage guarantee, in the special case of independent repeated measurements, it is possible to achieve a stronger form of coverage—the "second-moment coverage" property—to provide better control of conditional miscoverage rates, and distribution-free prediction sets that achieve this property are constructed. Simulations illustrate that this guarantee indeed leads to uniformly small conditional miscoverage rates. Empirically, this stronger guarantee comes at the cost of a larger width of the prediction set in scenarios where the fitted model is poorly calibrated, but this cost is very mild in cases where the fitted model is accurate.

Introduction

Machine learning models are increasingly deployed in high-stakes environments, yet most provide only point estimates without a reliable measure of uncertainty. Conformal prediction has emerged as a popular framework for "distribution-free" uncertainty quantification, providing prediction intervals that are guaranteed to contain the true value with a user-specified probability (e.g., 90%). However, the validity of standard conformal prediction rests on the assumption of exchangeability, meaning the data points are essentially independent and identically distributed (i.i.d.).

In practice, data often exhibits a hierarchical structure. For instance, medical records are grouped by hospital, student performance by classroom, and climate simulations by initial condition ensembles. In these scenarios, observations within a group are more similar to each other than to those in other groups. Ignoring this structure can lead to invalid error rates or inconsistent performance across different groups. This paper introduces a framework to extend conformal prediction to these complex, hierarchical settings.

Hierarchical Conformal Prediction (HCP)

The authors first formalize Hierarchical Exchangeability, a condition where groups are exchangeable with one another, and observations within those groups are exchangeable among themselves. Based on this, they propose Hierarchical Conformal Prediction (HCP).

A key innovation in HCP is the "weighting fix." In standard split conformal prediction, all calibration points are treated equally. In a hierarchical setting, this can lead to bias if group sizes are imbalanced—a single large group could dominate the calibration, leading to poor coverage for smaller, unseen groups. HCP addresses this by weighting observations based on their group size, ensuring that the resulting uncertainty estimates remain valid for a new group regardless of the distribution of group sizes in the training data.

HCP² and Second-Moment Coverage

While HCP ensures marginal coverage, it does not guarantee "conditional coverage"—the idea that the interval should be valid for every specific input. While perfect conditional coverage is mathematically impossible for continuous data, the authors introduce a powerful proxy: second-moment coverage.

This is implemented via HCP², a method designed for settings with repeated measurements (e.g., the same patient tested multiple times). Instead of merely bounding the average error rate, HCP² bounds the squared error rate. By calculating thresholds based on the pairwise minimums of residuals within groups, HCP² effectively controls the variance of the error rate. This prevents "pockets" of high miscoverage, making the model significantly more reliable across the entire feature space.

Empirical Evaluation

The researchers evaluated HCP and HCP² using both synthetic simulations and the Lorenz 96 (L96) Dynamical System, a chaotic model used in weather forecasting.

Key Findings:

  1. Finite-Sample Guarantees: Unlike asymptotic methods that require a large number of groups to be valid, HCP provides exact guarantees even with small datasets.
  2. Stability in Heteroscedasticity: In simulations where noise levels varied across the feature space, standard HCP showed high variance in error rates. HCP² successfully stabilized these rates, keeping the actual miscoverage much closer to the target.
  3. The "Accuracy Discount": A significant empirical insight is that if the underlying machine learning model is well-calibrated, the stronger guarantees of HCP² come at almost no cost to the prediction set's width. The intervals only widen significantly when the model is struggling, providing necessary protection precisely when it is needed most.

Conclusion and Future Work

This work provides a robust foundation for applying distribution-free inference to grouped data. While the "split" versions of these methods are computationally efficient, the authors note that hierarchical versions of more complex methods like Jackknife+ or Full Conformal Prediction remain computationally intensive.

Future research may explore the optimal trade-off between the number of groups ($K$) and the number of observations per group ($N_k$). Additionally, as HCP² requires at least two observations per group for a portion of the calibration set, adapting these methods for datasets where repeated measurements are scarce remains an open challenge.

Summary updated

BibTeX
@misc{lee2023distribution,
  author = {Yonghoon Lee and Rina Foygel Barber and Rebecca Willett},
  title = {{Distribution-free inference with hierarchical data}},
  year = {2023},
  eprint = {2306.06342},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.06342},
}
Figure