Scalable Out-of-distribution Robustness in the Presence of Unobserved Confounders

Parjanya Prashant, Seyedeh Baharan Khatami, Bruno Ribeiro, Babak Salimi

Abstract

We consider the task of out-of-distribution (OOD) generalization, where the distribution shift is due to an unobserved confounder ($Z$) affecting both the covariates ($X$) and the labels ($Y$). In this setting, traditional assumptions of covariate and label shift are unsuitable due to the confounding, which introduces heterogeneity in the predictor, i.e., $\hat{Y} = f_Z(X)$. OOD generalization differs from traditional domain adaptation by not assuming access to the covariate distribution ($X^\text{te}$) of the test samples during training. These conditions create a challenging scenario for OOD robustness: (a) $Z^\text{tr}$ is an unobserved confounder during training, (b) $P^\text{te}(Z) \neq P^\text{tr}(Z)$, (c) $X^\text{te}$ is unavailable during training, and (d) the posterior predictive distribution depends on $P^\text{te}(Z)$, i.e., $\hat{Y} = E_{P^\text{te}(Z)}[f_Z(X)]$. In general, accurate predictions are unattainable in this scenario, and existing literature has proposed complex predictors based on identifiability assumptions that require multiple additional variables. Our work investigates a set of identifiability assumptions that tremendously simplify the predictor, whose resulting elegant simplicity outperforms existing approaches.

Introduction

Most machine learning models operate under the assumption that the relationship between features ($X$) and labels ($Y$) remains stable across environments. However, real-world data is frequently influenced by unobserved "confounders" ($Z$) that affect both inputs and outputs. For instance, in healthcare, socioeconomic status might be an unobserved factor influencing both access to diagnostic tests ($X$) and health outcomes ($Y$).

When the distribution of such a hidden factor shifts between training and testing, standard models fail because the optimal predictor $P(Y|X)$ is no longer stationary. Existing solutions to this "latent shift" problem typically rely on multiple auxiliary variables (proxies) or computationally expensive generative models that do not scale to large datasets. This paper introduces a scalable framework that achieves OOD robustness using minimal auxiliary information.

Problem Formulation

The core challenge lies in the causal structure where an unobserved variable $Z$ acts as a parent to both $X$ and $Y$. To make this problem tractable, the authors leverage a single proxy variable $S$ that is also influenced by $Z$. This structure allows for the identification of the latent distribution even when $Z$ itself is never directly observed.

Causal graph showing the relationship between the unobserved confounder Z, features X, labels Y, and the proxy variable S.

Proposed Methodology

The authors propose a scalable, two-stage approach to address latent confounding shift:

  1. Latent Distribution Estimation (Training $\phi$): An encoder-decoder architecture is employed to infer the distribution of the hidden confounder $P(Z|X)$. The encoder $\phi$ maps features to a latent space, while a decoder $M$ attempts to reconstruct the proxy variable $S$. A novel variance regularizer ($L_{var}$) is introduced to ensure that the latent classes are clearly distinguishable within the feature space, satisfying a "weak overlap" assumption.
  2. Mixture-of-Experts (MoE) Predictor: Rather than training a single global model, the framework trains a set of experts ($E_1, ..., E_{n_z}$). each specializing in predicting $Y$ for a specific latent class of $Z$. The inferred $P(Z|X)$ serves as a gating function, weighting each expert's prediction based on the input features.
  3. Test-Time Adaptation (Estimating $w$): During inference, the distribution of $Z$ may shift. The authors utilize Black Box Shift Estimation (BBSE) to estimate the importance weights $w$ (the ratio of test-to-train latent distributions). These weights are used to adjust the MoE gating function, allowing the model to adapt to the test environment without requiring test-set labels.
The complete architectural framework, including latent distribution training, importance weight estimation (BBSE), and the Mixture-of-Experts prediction pipeline.

Experimental Evaluation

Datasets

The method was evaluated on synthetic benchmarks designed for Proxy OOD and Multi-source OOD tasks, as well as five high-stakes real-world datasets from the ACS/Folktables suite (U.S. Census Bureau data). These include tasks such as predicting employment status (confounded by disability), income (confounded by state), and health insurance coverage (confounded by age).

Key Results

  • Accuracy: On synthetic data, the proposed method achieved approximately 89% accuracy, significantly outperforming standard robust methods like Invariant Risk Minimization (IRM) and VREx, which hovered around 50%. On the ACS Income dataset, it reached 88.3% accuracy, a 3% improvement over the best baseline.
  • Scalability: Unlike kernel-based methods with $O(n^3)$ complexity, this neural-network-based approach scales linearly ($O(n)$). In scalability tests, the model maintained constant memory usage while competing methods saw exponential growth.
  • Ablation Studies: The $L_{var}$ regularizer proved critical; removing it led to a significant drop in the model's ability to recover the latent distribution and generalize to new environments.

Discussion and Conclusion

This work demonstrates that OOD robustness in the presence of unobserved confounders is achievable and scalable. A key insight is that a single proxy is sufficient for identifiability under the "weak overlap" assumption—a condition that becomes easier to satisfy as the dimensionality of the feature space $X$ increases.

While the current framework assumes discrete confounders and that the test distribution support is a subset of the training support, it provides a robust foundation for future work. Potential extensions include handling continuous latent variables and developing automated methods for determining the optimal number of latent classes ($n_z$).

Summary updated

Abstract

We consider the task of out-of-distribution (OOD) generalization, where the distribution shift is due to an unobserved confounder ($Z$) affecting both the covariates ($X$) and the labels ($Y$). In this setting, traditional assumptions of covariate and label shift are unsuitable due to the confounding, which introduces heterogeneity in the predictor, i.e., $\hat{Y} = f_Z(X)$. OOD generalization differs from traditional domain adaptation by not assuming access to the covariate distribution ($X^\text{te}$) of the test samples during training. These conditions create a challenging scenario for OOD robustness: (a) $Z^\text{tr}$ is an unobserved confounder during training, (b) $P^\text{te}{Z} \neq P^\text{tr}{Z}$, (c) $X^\text{te}$ is unavailable during training, and (d) the posterior predictive distribution depends on $P^\text{te}(Z)$, i.e., $\hat{Y} = E_{P^\text{te}(Z)}[f_Z(X)]$. In general, accurate predictions are unattainable in this scenario, and existing literature has proposed complex predictors based on identifiability assumptions that require multiple additional variables. Our work investigates a set of identifiability assumptions that tremendously simplify the predictor, whose resulting elegant simplicity outperforms existing approaches.
BibTeX
@inproceedings{prashant2025scalable,
  author = {Parjanya Prashant and Seyedeh Baharan Khatami and Bruno Ribeiro and Babak Salimi},
  title = {{Scalable Out-of-distribution Robustness in the Presence of Unobserved Confounders}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2025},
  url = {https://openreview.net/forum?id=eIyOtZ9tgl},
}
Figure