General Frameworks for Conditional Two-Sample Testing

Seongchan Lee, Suman Cha, Ilmun KimarXiv 2024 · DOI

Introduction

In statistical analysis, standard two-sample testing is used to determine if two groups differ significantly. However, in many real-world applications—such as algorithmic fairness or domain adaptation—the more pertinent question is: "Are these groups different after we control for confounding factors?" This is the domain of Conditional Two-Sample Testing (C2ST).

Researchers at Yonsei University have recently established a rigorous foundation for C2ST, addressing the theoretical hurdles that have historically made this problem difficult to solve. Their work provides both a proof of the fundamental "hardness" of the task and two practical frameworks for implementing valid tests in complex, high-dimensional settings.

The Problem: Why C2ST is Challenging

In a standard two-sample test, we compare populations $P^{(1)}$ and $P^{(2)}$ based on an outcome $Y$. In C2ST, we account for a set of features $X$ (covariates). The goal is to test the null hypothesis that the conditional distributions are identical:

$$P_{Y|X}^{(1)} = P_{Y|X}^{(2)}$$

This is essential when the feature distributions ($X$) differ between the two groups—a phenomenon known as covariate shift. For example, in hiring, one might ask if a model discriminates based on gender ($Y$) after controlling for professional experience ($X$).

The authors identify two primary challenges in this field:

  1. Theoretical Hardness: The paper proves that for continuous variables, no valid C2ST can have power against any alternative without specific assumptions, such as smoothness or regularity in the underlying distributions.
  2. The CIT Gap: While C2ST is conceptually related to Conditional Independence Testing (CIT), a technical mismatch exists. CIT typically assumes data is i.i.d. (where group membership is a random variable), whereas two-sample testing often involves fixed group sizes. This deterministic nature breaks the theoretical validity of many existing CIT proofs.

Proposed Frameworks

To bridge these gaps, the researchers introduced two general frameworks that allow practitioners to leverage existing statistical tools for conditional testing.

1. The CIT-to-C2ST Framework

This "black-box" approach allows any existing CIT (such as the Generalized Covariance Measure) to be used for two-sample testing. To resolve the issue of fixed group sizes, the authors introduce a Binomial sampling strategy. By discarding a small, controlled number of samples to "randomize" the group sizes, they transform the fixed-size problem into an i.i.d. joint distribution problem. This ensures that the theoretical guarantees of CITs carry over to the two-sample context.

2. The Density Ratio Estimation (DRE) Framework

The DRE framework utilizes importance weighting to "re-weight" the second population so its feature distribution matches the first. By estimating the ratio $r_X(x) = f_X^{(1)}(x)/f_X^{(2)}(x)$, the conditional test is transformed into a simpler marginal comparison on the re-weighted data.

The authors demonstrate two primary implementations of this framework:

  • Classifier-based tests (CLF): A model is trained to distinguish between the two groups. If the model cannot perform better than a random guess after re-weighting, the null hypothesis is likely true.
  • Linear-time MMD: This utilizes Maximum Mean Discrepancy (a kernel-based method) adapted with importance weights to maintain computational efficiency in high dimensions.

Experimental Validation

The frameworks were evaluated across synthetic scenarios and real-world datasets, including diamond pricing and a high-dimensional superconductivity dataset (81 features).

Key Findings

  • DRE Performance: In settings where the feature distributions of the two groups overlap significantly (bounded ratios), DRE-based methods—particularly those using K-fold cross-fitting—outperformed CIT-based methods in terms of statistical power. Cross-fitting proved essential for using samples efficiently without overfitting the density estimate.
  • CIT Robustness: CIT methods (like RCIT and GCM) proved more robust across both bounded and unbounded scenarios, though their success was highly dependent on the choice of the underlying regression model (e.g., Random Forest vs. XGBoost).
  • The Importance of Flexibility: On the Superconductivity dataset, simple linear models for density estimation failed, resulting in high false-positive rates. In contrast, flexible estimators like Kernel Logistic Regression (KLR) successfully controlled the error, highlighting that C2ST is only as good as its underlying models.

Conclusion and Future Directions

The research confirms that C2ST is inherently as difficult as CIT; there is no "free lunch," and practitioners must assume some level of regularity in their data. While the DRE framework offers high power, it is sensitive to weight instability when feature distributions are vastly different. Conversely, the CIT-to-C2ST framework offers robustness at the cost of some sample efficiency.

Future work may extend these frameworks to K-sample testing (comparing more than two groups) and explore Sampling Importance Resampling (SIR) to generate approximate samples from target distributions, potentially offering a more stable alternative to simple re-weighting.

Summary updated

BibTeX
@misc{lee2024general,
  author = {Seongchan Lee and Suman Cha and Ilmun Kim},
  title = {{General Frameworks for Conditional Two-Sample Testing}},
  year = {2024},
  eprint = {2410.16636},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.16636},
}
Figure