Conditioning on a sum can create dependence (source code)

= Conditioning on a sum can create dependence
{title2=$X\perp Y\not\Rightarrow X\perp Y\mid X+Y$}

Let $X,Y$ be <independent random variables>, each with a <Bernoulli distribution> of parameter $1/2$, and put $S=X+Y$. Unconditionally, the four ordered pairs $(0,0),(0,1),(1,0),(1,1)$ each have <probability> $1/4$. On the <event> $S=1$, only $(0,1)$ and $(1,0)$ remain, each with <conditional probability> $1/2$. Thus
$$
\mathbb P(X=1,Y=1\mid S=1)=0
\ne\mathbb P(X=1\mid S=1)\mathbb P(Y=1\mid S=1)=\frac14.
$$
Knowing that exactly one trial succeeded makes observing one outcome informative about the other. This violates <conditional independence> given $S$, even though the original <random variables> are independent. Given $S=0$ or $S=2$, both variables are <constant random variables> and are <conditionally independent> there; that does not repair the failure at $S=1$, an <event> of positive <probability>.

\Image[/conditioning-sum-dependent-binary-outcomes.png]
{title=Selecting pairs with exactly one success makes independent trials dependent}
{description=Left: four equally probable outcomes of independent fair <Bernoulli trials>. The selection $S=X+Y=1$ retains exactly two pairs. Right: their conditional joint table has zero mass on the diagonal and $1/2$ off it. Within this selected model the <conditional covariance> is $-1/4$; the two conditional <marginal distributions> remain fair.}

The <conditional covariance> here is $\mathbb E[XY\mid S=1]-\mathbb E[X\mid S=1]\mathbb E[Y\mid S=1]=0-1/4=-1/4$. Both conditional <variances> are $1/4$, so the conditional <correlation coefficient> is $-1$: within the selected group, $Y=1-X$. These conclusions follow from restricting a finite <sample space>, without positing any physical interaction between the trials.

This example and the shared-environment example establish both logical directions: <independent random variables> need not be <conditionally independent>, and <conditionally independent> variables need not be independent. When $S$ is represented as the joint result of two inputs in a <causal directed acyclic graph>, conditioning on it has the <collider> structure associated with <collider bias>. A probability calculation by itself establishes a dependence relation, not a physical causal mechanism or an <intervention>.