The law of total covariance can be proved using the
law of total expectation: First, :\operatorname{cov}(X,Y) = \operatorname{E}[XY] - \operatorname{E}[X]\operatorname{E}[Y] from a simple standard identity on covariances. Then we apply the law of total expectation by conditioning on the random variable
Z: ::= \operatorname{E}\big[\operatorname{E}[XY\mid Z]\big] - \operatorname{E}\big[\operatorname{E}[X\mid Z]\big]\operatorname{E}\big[\operatorname{E}[Y\mid Z]\big] Now we rewrite the term inside the first expectation using the definition of covariance: ::= \operatorname{E}\!\big[\operatorname{cov}(X,Y\mid Z) + \operatorname{E}[X\mid Z]\operatorname{E}[Y\mid Z]\big] - \operatorname{E}\big[\operatorname{E}[X\mid Z]\big]\operatorname{E}\big[\operatorname{E}[Y\mid Z]\big] Since expectation of a sum is the sum of expectations, we can regroup the terms: ::= \operatorname{E}\!\big[\operatorname{cov}(X,Y\mid Z)\big] + \operatorname{E}\big[\operatorname{E}[X\mid Z] \operatorname{E}[Y\mid Z]\big] - \operatorname{E}\big[\operatorname{E}[X\mid Z]\big]\operatorname{E}\big[\operatorname{E}[Y\mid Z]\big] Finally, we recognize the final two terms as the covariance of the conditional expectations E[
X |
Z] and E[
Y |
Z]: ::= \operatorname{E}\big[\operatorname{cov}(X,Y \mid Z)\big]+\operatorname{cov}\big(\operatorname{E}[X\mid Z],\operatorname{E}[Y\mid Z]\big) ==See also==