Manuscript Offprint

arXiv:2610.11584

Embedding-Bias in Conditional Independence Testing

Nikolaj Thams, Anton Rask Lundborg

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

To test conditional independence of X and Y given a text or an image Z, one conditions on an embedding ψ(Z)\psi(Z) in place of Z. The embedded test is valid if Z is independent of X or of Y given ψ(Z)\psi(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 \psi(Z)] and E[Y∣ψ(Z)]\mathbb{E}[Y \mid \psi(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.

Keywords: conditional independence testing, sensitivity analysis, embeddings, text data, generalised covariance measure

1 Introduction

Tests of conditional independence (CI) are a basic tool of statistics (Shah and Peters, 2020). They underpin tests of variable significance (Lundborg et al., 2024), the evaluation of predictors for fairness (Hardt et al., 2016) and robustness (Peters et al., 2016), and constraint-based causal discovery (Spirtes et al., 2000). 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 (Veitch et al., 2020; Kook and Lundborg, 2024; Simnacher et al., 2026b,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 \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 Y \mid \psi(Z), with ψ:=ψZ\psi := \psi_Z.

Figure

Figure 1: The conceptual example: the topic and the opinion of a post Z both influence its reply X and its reception Y, 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 X and Y are dependent given ψ(Z)\psi(Z) although X⊥Y∣ZX \perp Y \mid Z.

Example 1.1. Consider an observational study of online discussions. Let Z be an original post, X be a reply, and Y 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 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 Y \mid Z holds, and every consistent test on the embedded variables rejects with probability tending to one.

Existing embedded tests apply a standard CI test to the embedded variables and rely on the embedding being sufficient. Simnacher et al. (2026a) show that this is valid if X⊥Z∣ψ(Z)X \perp Z \mid \psi(Z) or Y⊥Z∣ψ(Z)Y \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. (2026a, Section 3.2) 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 (Shah and Peters, 2020; Neykov et al., 2021; Lundborg et al., 2024); 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 X and of Y 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 X and Y 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 Z uncorrelated.

Second, as in sensitivity analysis for unmeasured confounding (Rosenbaum, 2002; Imbens, 2003; Cinelli and Hazlett, 2020; Chernozhukov et al., 2022), 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 Section 2, we define a family of measures of conditional dependence and bound how embedding Z changes them. In Section 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 Section 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.

References (34)