betaFeedback

WorksMathematics

Embedding-Bias in Conditional Independence Testing

Abstract

To test conditional independence of XX and YY given a text or an image ZZ, one conditions on an embedding ψ(Z)ψ(Z) in place of ZZ. The embedded test is valid if ZZ is independent of XX or of YY given ψ(Z)ψ(Z), which cannot be confirmed from data, and when this fails, the rejection probability under the null hypothesis can tend to one. We study this failure, and show that focusing on a specific form of dependence relaxes what the embedding must retain. For a residual correlation test inspired by the Generalised Covariance Measure, validity only requires that the parts of E[X∣Z]\mathbb{E}[X \mid Z] and E[Y∣Z]\mathbb{E}[Y \mid Z] missed by E[X∣ψ(Z)]\mathbb{E}[X \mid ψ(Z)] and E[Y∣ψ(Z)]\mathbb{E}[Y \mid ψ(Z)] are uncorrelated. Otherwise, we treat the discarded information as an omitted variable. Under the null hypothesis, the bias equals the absolute correlation of the missed parts times the geometric mean of two partial R2R^2 values. This identity yields a robust test valid under a declared tolerance for the geometric mean, which, like a sensitivity parameter, is not identified from the data. On synthetic data and text embeddings, the robust test holds its level approximately. On text generated by a language model, under an exact null hypothesis, every embedding, even the generator's own states, biases the embedded test.

Introduction

Tests of conditional independence (CI) are a basic tool of statistics [30]. They underpin tests of variable significance [20], the evaluation of predictors for fairness [13] and robustness [24], and constraint-based causal discovery [33]. In many current applications, the tested variables are text, images, or other unstructured objects, and the test is run on embeddings of those objects instead [39, 18, 31 a], testing H0:X⊥ ⁣ ⁣⊥Y∣ZH_0 : X \perp\!\!\perp Y \mid Z by testing the surrogate hypothesis H0ψ:ψX(X)⊥ ⁣ ⁣⊥ψY(Y)∣ψZ(Z)H_0^{\psi} : \psi_X(X) \perp\!\!\perp\psi_Y(Y) \mid\psi_Z(Z) for embeddings ψX,ψY\psi_X,\psi_Y and ψZ\psi_Z.

Even a perfect test of H0ψH_0^{\psi} may not result in a valid test of H0H_0. The problem lies not with embedding XX or YY; testing H0H_0 via a test of ψX(X)⊥ ⁣ ⁣⊥ψY(Y)∣Z\psi_X(X) \perp\!\!\perp\psi_Y(Y) \mid Z is valid, though possibly less powerful than a direct test of H0H_0. Embedding the conditioning variable ZZ, however, does not generally preserve conditional independence. In this paper, we formalize and quantify this potential loss of validity. Only the embedding of ZZ matters for validity, so we absorb ψX\psi_X and ψY\psi_Y into XX and YY and write H0ψH_0^{\psi} for X⊥ ⁣ ⁣⊥Y∣ψ(Z)X \perp\!\!\perp Y \mid\psi(Z), with ψ:=ψZ\psi:= \psi_Z.

Example 1.1. Consider an observational study of online discussions. Let ZZ be an original post, XX be a reply, and YY the votes the reply receives. Whether the style of a reply is unassociated with its reception other than through the content of the post is the hypothesis X⊥ ⁣ ⁣⊥Y∣ZX \perp\!\!\perp Y \mid Z. To test it, one reduces the reply to a summary such as its politeness f(X)f(X) and the votes to a score g(Y)g(Y), and replaces the post by an embedding ψ(Z)\psi(Z) from a pretrained encoder (Figure 1). Suppose that the encoder represents the topic of a post well but its opinion poorly, and that the opinion influences both the politeness of the replies and their votes. Then the parts of f(X)f(X) and g(Y)g(Y) that are not explained by ψ(Z)\psi(Z) are correlated even if X⊥ ⁣ ⁣⊥Y∣ZX \perp\!\!\perp Y \mid Z holds, and every consistent test on the embedded variables rejects with probability tending to one.

Conceptual example showing the topic and opinion of a post, its reply and votes, and the embedded test variables

Figure 1. The conceptual example: the topic and the opinion of a post ZZ both influence its reply XX and its reception YY, and the embedded test uses f(X)f(X), g(Y)g(Y), and ψ(Z)\psi(Z). Since ψ(Z)\psi(Z) represents the topic but not the opinion, the dashed path through the opinion stays open and XX and YY are dependent given ψ(Z)\psi(Z) although X⊥ ⁣ ⁣⊥Y∣ZX \perp\!\!\perp Y \mid Z.

Existing embedded tests apply a standard CI test to the embedded variables and rely on the embedding being sufficient. Simnacher et al. [31] show that this is valid if X⊥ ⁣ ⁣⊥Z∣ψ(Z)X \perp\!\!\perp Z \mid\psi(Z) or Y⊥ ⁣ ⁣⊥Z∣ψ(Z)Y \perp\!\!\perp Z \mid\psi(Z) (their Theorem 3) or, for tests of conditional mean independence of YY, if E[Y∣Z]=E[Y∣ψ(Z)]\mathbb{E}[Y \mid Z] = \mathbb{E}[Y \mid\psi(Z)] (their Theorem 14). A pretrained encoder, trained for a generic objective, has no reason to retain what ZZ says about XX or YY, and Simnacher et al. [31] themselves consider even the mean condition implausible for learned embeddings and assess it by simulation. Nor can sufficiency be checked from the data. It is itself a conditional (mean) independence hypothesis given ψ(Z)\psi(Z), for which no test is uniformly valid with nontrivial power [30, 21, 20]; a richer model of ZZ can only show that ψ(Z)\psi(Z) misses part of E[X∣Z]\mathbb{E}[X \mid Z].

We examine how embedded tests fail without strict sufficiency, and how far the failure can be contained, in two steps. First, we choose a target that requires less of the embedding. In particular, we consider a family of conditional association measures that includes the targets of commonly used CI tests. Each measure is the largest absolute correlation between residuals of transformations of XX and of YY after adjusting for the conditioning variable, and the classes of transformations determine which departures from H0H_0 it captures. For the absolute correlation ρψ\rho_{\psi} of the residuals of XX and YY after adjusting for ψ(Z)\psi(Z), it suffices that the parts of E[X∣Z]\mathbb{E}[X \mid Z] and E[Y∣Z]\mathbb{E}[Y \mid Z] that ψ(Z)\psi(Z) misses are uncorrelated, for instance because ψ(Z)\psi(Z) retains one of the two. However the test has no power against dependence that leaves the residuals given ZZ uncorrelated.

Second, as in sensitivity analysis for unmeasured confounding [28, 14, 9, 8], we treat the information that ψ\psi discards as an omitted variable and quantify its effect. Under H0H_0, ρψ=∣λ∣Rψ2(X)Rψ2(Y)\rho_\psi= |\lambda|\sqrt{R_\psi^2(X)R_\psi^2(Y)}, where Rψ2(X)R_\psi^2(X) is the share of the residual variance of XX given ψ(Z)\psi(Z) that ZZ would explain and λ\lambda is the correlation of the two missed parts. This yields a test that is valid, whatever the correlation of the discarded parts, under a declared bound on Rψ2(X)Rψ2(Y)\sqrt{R_\psi^2(X)R_\psi^2(Y)}. Because the discarded information is part of the observed ZZ, one can use data and any richer embedding to lower-bound Rψ2(X)R_\psi^2(X) and Rψ2(Y)R_\psi^2(Y).

Our contributions are as follows. In § 2, we define a family of measures of conditional dependence and bound how embedding ZZ changes them. In § 3, we treat the discarded information as an omitted variable and derive a test that remains valid under a declared bound on the resulting bias. In § 4, we evaluate the bias on synthetic and real data. On text generated by a language model under an exact null hypothesis, every embedding we tried biases the plain embedded test.

Related work

CI testing and embeddings. Besides covariance measures [30, 29, 20, 18], CI tests use kernel mean embeddings [40, 4], the conditional law of XX given ZZ [6, 5, 36], local permutations [17], or generative models [41, 27].

Simnacher et al. [31], discussed above, develop CI tests for embedded text. A number of works [16, 11, 10] treat sufficiency as an untestable assumption, to be argued from domain knowledge and examined by sensitivity analysis or simulation. In our work, we quantify how a lack of sufficiency invalidates the test.

Sensitivity analysis. Sensitivity analysis bounds the bias that an unobserved confounder can cause [28, 14]. Cinelli and Hazlett [9] parametrize it by partial R2R^2 values in linear regression, Chernozhukov et al. [8] extend the bounds to linear functionals of a nonparametric regression, and Veitch and Zaveri [38] apply them post hoc; Appendix § 7.§ 1 compares our identity with these bounds. Conditioning on ψ(Z)\psi(Z) is conditioning on a coarsening of the confounder, for which Ogburn and VanderWeele [22, 23] give bias-attenuation results.

Notation

Let (X,Y,Z)∼P(X,Y,Z) \sim P, where XX, YY, and ZZ take values in measurable spaces X\mathcal{X}, Y\mathcal{Y}, and Z\mathcal{Z}, for example spaces of texts. We observe nn independent copies (Xi,Yi,Zi)(X_i,Y_i,Z_i). We write E, Var, and Cov for moments under PP, E[U∣T]\mathbb{E}[U \mid T] for the conditional expectation of UU given TT, and U⊥ ⁣ ⁣ ⁣⊥T∣SU \perp\!\!\!\perp T \mid S for conditional independence of UU and TT given SS. Equalities between random variables hold almost surely.

The hypothesis of interest is H0H_0: X⊥ ⁣ ⁣ ⁣⊥Y∣ZX \perp\!\!\!\perp Y \mid Z. An embedding ψ:Z→V\psi:\mathcal{Z} \to\mathcal{V}, with V\mathcal{V} a measurable space such as Rd\mathbb{R}^d, is a fixed measurable map, pretrained on external data or fitted on a split of the sample that is not used for testing, and id⁡\operatorname{id} denotes the identity on ZZ. Every quantity below is indexed by the transformation of ZZ that is conditioned on. For a real-valued, square-integrable function ff of (X,Z)(X,Z) and a measurable ψ\psi, including ψ=id⁡\psi= \operatorname{id}, let

σψ2(f):=E[(f−E[f∣ψ(Z)])2]=E[Var⁡(f∣ψ(Z))]\sigma_{\psi}^{2}(f) := \mathbb{E}\left[(f-\mathbb{E}[f\mid\psi(Z)])^{2}\right] = \mathbb{E}[\operatorname{Var}(f\mid\psi(Z))]

be the residual variance of f=f(X,Z)f=f(X,Z) after adjusting for ψ(Z)\psi(Z). When XX is real-valued and f(x,z)=xf(x,z)=x, we write XX in place of ff, as in σψ2(X)\sigma_{\psi}^{2}(X). Throughout, when a definition or result is symmetric in (X,f)(X,f) and (Y,g)(Y,g), we state it for XX and ff only. All proofs are in Appendix § 6.

Measures of conditional dependence

Definition and examples

In general, neither H0H_0 nor H0ψH_0^{\psi} implies the other. Rather than comparing the two hypotheses, we compare measures of conditional dependence given ZZ and given ψ(Z)\psi(Z), which vanish under H0H_0 and under H0ψH_0^{\psi}, respectively. Write PX,ZP_{X,Z} and PY,ZP_{Y,Z} for the distributions of (X,Z)(X,Z) and of (Y,Z)(Y,Z), and let F⊆L2(PX,Z)\mathcal{F}\subseteq L^{2}(P_{X,Z}) and G⊆L2(PY,Z)\mathcal{G}\subseteq L^{2}(P_{Y,Z}) be classes of real-valued transformations of (X,Z)(X,Z) and of (Y,Z)(Y,Z); we write ff for f(X,Z)f(X,Z). A test that conditions on ψ(Z)\psi(Z) can only use transformations that depend on ZZ through ψ(Z)\psi(Z). We therefore let Fψ\mathcal{F}_{\psi} be the f∈Ff\in\mathcal{F} for which there exists an hh such that f(x,z)=h(x,ψ(z))f(x,z)=h(x,\psi(z)), and Gψ\mathcal{G}_{\psi} likewise. We remark that Fid⁡=F\mathcal{F}_{\operatorname{id}}=\mathcal{F}. If F\mathcal{F} is a class of functions of xx alone, such as {(x,z)↦x}\{(x,z)\mapsto x\}, then Fψ=F\mathcal{F}_{\psi}=\mathcal{F}.

Definition 2.1 (Measure of conditional dependence). For f∈Fψf\in\mathcal{F}_{\psi} and g∈Gψg\in\mathcal{G}_{\psi}, let

ρψ(f,g):=∣E[Cov⁡(f,g∣ψ(Z))]∣σψ(f) σψ(g)\rho_{\psi}(f,g):=\frac{\left|\mathbb{E}[\operatorname{Cov}(f,g\mid\psi(Z))]\right|}{\sigma_{\psi}(f)\,\sigma_{\psi}(g)}

with ρψ(f,g):=0\rho_{\psi}(f,g):=0 if σψ(f)=0\sigma_{\psi}(f)=0 or σψ(g)=0\sigma_{\psi}(g)=0, and let ρψ(F,G):=sup⁡f∈Fψ,g∈Gψρψ(f,g)\rho_{\psi}(\mathcal{F},\mathcal{G}):=\sup_{f\in\mathcal{F}_{\psi},g\in\mathcal{G}_{\psi}}\rho_{\psi}(f,g), with ρψ(F,G):=0\rho_{\psi}(\mathcal{F},\mathcal{G}):=0 if Fψ\mathcal{F}_{\psi} or Gψ\mathcal{G}_{\psi} is empty.

References

  1. [1]Anthropic. Claude Haiku 4.5 system card. https://www.anthropic.com/system-cards, 2025. Model claude-haiku-4-5 through the Anthropic API.
  2. [2]Timothy B. Armstrong and Michal Kolesár. Optimal inference in a class of regression models. Econometrica, 86(2):655–683, 2018.
  3. [3]Timothy B. Armstrong and Michal Kolesár. Sensitivity analysis using approximate moment condition models. Quantitative Economics, 12(1):77–108, 2021.
  4. [4]Luca Bergen, Dino Sejdinovic, and Vanessa Didelez. The generalised kernel covariance measure. arXiv preprint arXiv:2604.03721, 2026.arxiv.org/abs/2604.03721
  5. [5]Thomas B. Berrett, Yi Wang, Rina Foygel Barber, and Richard J. Samworth. The conditional permutation test for independence while controlling for confounders. Journal of the Royal Statistical Society: Series B, 82(1):175–197, 2020.arxiv.org/abs/1807.05405
  6. [6]Emmanuel Candès, Yingying Fan, Lucas Janson, and Jinchi Lv. Panning for gold: ‘model-X’ knockoffs for high dimensional controlled variable selection. Journal of the Royal Statistical Society: Series B, 80(3):551–577, 2018.
  7. [7]Jonathan P. Chang, Caleb Chiam, Liye Fu, Andrew Z. Wang, Justine Zhang, and Cristian Danescu-Niculescu-Mizil. ConvoKit: A toolkit for the analysis of conversations. In Proceedings of the 21st Annual Meeting of the Special Interest Group on Discourse and Dialogue, pages 57–60, 2020.arxiv.org/abs/2005.04246
  8. [8]Victor Chernozhukov, Carlos Cinelli, Whitney Newey, Amit Sharma, and Vasilis Syrgkanis. Long story short: omitted variable bias in causal machine learning. arXiv preprint arXiv:2112.13398, 2022.DOI
  9. [9]Carlos Cinelli and Chad Hazlett. Making sense of sensitivity: extending omitted variable bias. Journal of the Royal Statistical Society: Series B, 82(1):39–67, 2020.
  10. [10]Naoki Egami, Christian J. Fong, Justin Grimmer, Margaret E. Roberts, and Brandon M. Stewart. How to make causal inferences using texts. Science Advances, 8(42):eabg2652, 2022.DOI
  11. [11]Amir Feder, Katherine A. Keith, Emaad Manzoor, Reid Pryzant, Dhanya Sridhar, Zach Wood-Doughty, Jacob Eisenstein, Justin Grimmer, Roi Reichart, Margaret E. Roberts, Brandon M. Stewart, Victor Veitch, and Diyiy Yang. Causal inference in natural language processing: estimation, prediction, interpretation and beyond. Transactions of the Association for Computational Linguistics, 10:1138–1158, 2022.
  12. [12]Ben B. Hansen. The prognostic analogue of the propensity score. Biometrika, 95(2):481–488, 2008.DOI
  13. [13]Moritz Hardt, Eric Price, and Nati Srebro. Equality of opportunity in supervised learning. In Advances in Neural Information Processing Systems, volume 29, pages 3315–3323. Curran Associates, Inc., 2016. URL https://proceedings.neurips.cc/paper/2016/file/6a96a9feb1216f114f7384ba499518b38-Paper.pdf.arxiv.org/abs/1610.02413
  14. [14]Guido W. Imbens. Sensitivity to exogeneity assumptions in program evaluation. American Economic Review, 93(2):126–132, 2003.
  15. [15]Guido W. Imbens and Charles F. Manski. Confidence intervals for partially identified parameters. Econometrica, 72(6):1845–1857, 2004.
  16. [16]Katherine A. Keith, David Jensen, and Brendan O’Connor. Text and causal inference: a review of using text to remove confounding from causal estimates. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pages 5332–5344, 2020.arxiv.org/abs/2005.00649
  17. [17]Ilmun Kim, Matey Neykov, Sivaramn Balakrishnan, and Larry Wasserman. Local permutation tests for conditional independence. The Annals of Statistics, 50(6):3388–3414, 2022.arxiv.org/abs/2112.11666
  18. [18]Lucas Kook and Anton Rask Lundborg. Algorithm-agnostic significance testing in supervised learning with multimodal data. Briefings in Bioinformatics, 25(6):bbae475, 2024.DOI
  19. [19]Ken Lang. NewsWeeder: learning to filter netnews. In Proceedings of the 12th International Conference on Machine Learning, pages 331–339, 1995.DOI
  20. [20]Anton Rask Lundborg, Ilmun Kim, Rajen D. Shah, and Richard J. Samworth. The projected covariance measure for assumption-lean variable significance testing. The Annals of Statistics, 52(6):2851–2878, 2024.arxiv.org/abs/2211.02039
  21. [21]Matey Neykov, Sivaramn Balakrishnan, and Larry Wasserman. Minimax optimal conditional independence testing. The Annals of Statistics, 49(4):2151–2177, 2021.arxiv.org/abs/2001.03039
  22. [22]Elizabeth L. Ogburn and Tyler J. VanderWeele. On the nondifferential misclassification of a binary confounder. Epidemiology, 23(3):433–439, 2012.DOI
  23. [23]Elizabeth L. Ogburn and Tyler J. VanderWeele. Bias attenuation results for nondifferentially mismeasured ordinal and coarsened confounders. Biometrika, 100(1):241–248, 2013.pubmed.ncbi.nlm.nih.gov/24014285
  24. [24]Jonas Peters, Peter Bühlmann, and Nicolai Meinshausen. Causal inference by using invariant prediction: identification and confidence intervals. Journal of the Royal Statistical Society Series B: Statistical Methodology, 78(5):947–1012, 2016. doi: 10.1111/rssb.12167.
  25. [25]Qwen Team. Qwen3 technical report. arXiv preprint arXiv:2505.09388, 2025.
  26. [26]Nils Reimers and Iryna Gurevych. Sentence-BERT: sentence embeddings using Siamese BERT-networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing, pages 3982–3992, 2019.arxiv.org/abs/1908.10084
  27. [27]Yixin Ren, Chenghou Jin, Yewei Xia, Li Ke, Longtao Huang, Hui Xue, Hao Zhang, Jihong Guan, and Shuigeng Zhou. Score-based generative modeling for conditional independence testing. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining, 2025.arxiv.org/abs/2505.23309
  28. [28]Paul R. Rosenbaum. Observational Studies. Springer, New York, 2nd edition, 2002.
  29. [29]Cyrill Scheidegger, Julia Hörmann, and Peter Bühlmann. The weighted generalised covariance measure. Journal of Machine Learning Research, 23:1–68, 2022.arxiv.org/abs/2111.04361
  30. [30]Rajen D. Shah and Jonas Peters. The hardness of conditional independence testing and the generalised covariance measure. The Annals of Statistics, 48(3):1514–1538, 2020.
  31. [31]Marco Simnacher, Georg Keilbar, Benjamin König, Christoph Lippert, and Sonja Greven. Embedded conditional independence tests for large language model generated text with an application to German parliament speeches. arXiv preprint arXiv:2609.00946, 2026a.arxiv.org/abs/2609.00946
  32. [33]Peter Spirtes, Clark Glymour, and Richard Scheines. Causation, Prediction, and Search. Adaptive Computation and Machine Learning. MIT Press, Cambridge, MA, 2nd edition, 2000. ISBN 0-262-19440-6. doi: 10.7551/mitpress/1754.001.0001.DOI
  33. [34]Jörg Stoye. More on confidence intervals for partially identified parameters. Econometrica, 77(4):1299–1315, 2009.DOI
  34. [35]Chenhao Tan, Vlad Niculae, Cristian Danescu-Niculescu-Mizil, and Lillian Lee. Winning arguments: Interaction dynamics and persuasion strategies in good-faith online discussions. In Proceedings of the 25th International Conference on World Wide Web, pages 613–624, 2016.
  35. [36]Wesley Tansey, Victor Veitch, Haoran Zhang, Raul Rabadan, and David M. Blei. The hold-out randomization test for feature selection in black box models. Journal of Computational and Graphical Statistics, 31(1):151–162, 2022.arxiv.org/abs/1811.00645
  36. [37]TypeSafe AI. Jev: a System One decision model. https://typesafe.ai, 2026. Model jev-latest through the TypeSafe API, accessed 30 September 2026.
  37. [38]Victor Veitch and Anisha Zaveri. Sense and sensitivity analysis: simple post-hoc analysis of bias due to unobserved confounding. In Advances in Neural Information Processing Systems, volume 33, 2020.arxiv.org/abs/2003.01747
  38. [39]Victor Veitch, Dhanya Sridhar, and David M. Blei. Adapting text embeddings for causal inference. In Proceedings of the 36th Conference on Uncertainty in Artificial Intelligence, pages 919–928, 2020.arxiv.org/abs/1905.12741
  39. [40]Kun Zhang, Jonas Peters, Dominik Janzing, and Bernhard Schölkopf. Kernel-based conditional independence test and application in causal discovery. In Proceedings of the 27th Conference on Uncertainty in Artificial Intelligence, pages 804–813, 2011.arxiv.org/abs/1202.3775
  40. [41]Yi Zhang, Linjun Huang, Yun Yang, and Xiaofeng Shao. Doubly robust conditional independence testing with generative neural networks. arXiv preprint arXiv:2407.17694, 2024.arxiv.org/abs/2407.17694

Paper details

vlnc:W_54tw3v5h
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

Generative AI tools

View statement
Looking for related papers…
Contents