# Two random variables are dependent given a third random variable, and independent otherwise

Suppose that $$X$$ and $$Y$$ are dependent given $$Z$$, and independent when not given $$Z$$. Does this mean that:

$$p(x,y) = p(x) \cdot p(y) \\ p(x,y|z) \neq p(x|z) \cdot p(y|z)$$

Also, are there any real-world examples of this scenario?

• You might be interested in reading about examples of Berkson's paradox. Jan 28, 2021 at 15:57
• Well, the formulas are just restating the hypotheses about X, Y, and Z. Jan 28, 2021 at 22:11

There will be many examples of the form $$Z = f(X, Y)$$, where $$X$$ and $$Y$$ are two independent random variables and $$f$$ is some function.

For example, $$X$$ is the number I roll on a fair die, $$Y$$ is the number I roll on a second fair die, and $$Z$$ is $$X + Y$$.

• How does this address the case where $X$ and $Y$ are dependent given $Z$? Jan 28, 2021 at 11:10
• In my example $X$ and $Y$ are dependent given $Z$. For example, $P(X=1,Y=2|Z=3) = 0.5 \ne 0.25 = P(X=1|Z=3)P(Y=2|Z=3)$. Jan 28, 2021 at 12:04

Yes the translation in formula is correct, up to a loose formalism.

A generic "real-world" example can be obtained when $$X$$ and $$Y$$ can have either positive association or a negative association depending on $$Z$$. Then $$X$$ and $$Y$$ may eventually be independent.

For instance $$X$$ be the income and $$Y$$ be the experience and $$Z$$ be a type of professional activity. Then $$X$$ and $$Y$$ may be positively associated for some values of $$Z$$ but negatively associated for some others e.g. due to technical obsolescence. Examples can occur in environmetrics when the relation between $$X$$ and $$Y$$ is subject to an "inversion": $$Z$$ can be the time within day, day in year, rising/falling tide...

Note that this scenario can not happen when the joint distribution of $$X$$, $$Y$$ and $$Z$$ is normal because the covariance of $$X$$ and $$Y$$ conditional on $$Z = z$$ does not depend on the value $$z$$. On the contrary, easy examples are found with $$Z$$ being discrete or multimodal.