Suppose we have two random variables, $X$ and $Y$, defined over nonnegative reals. Obviously, the following formula holds:
$$\mathrm{Cov}(X,Y)=\mathbb{E}\left[XY\right]-\mathbb{E}\left[X\right]\mathbb{E}\left[Y\right].$$
However intuitional it may be, I am not so sure whether another formula that I stumbled upon holds:
$$\mathrm{Cov}(X,Y|X>0\,\wedge\,Y>0)=\mathbb{E}\left[XY|X>0\,\wedge\,Y>0\right]-\mathbb{E}\left[X|X>0\,\wedge\,Y>0\right]\cdot\mathbb{E}\left[Y|X>0\,\wedge\,Y>0\right].$$
I am not looking for a proof, but I would be thankful for a short note why or why not the above formula holds. Thank you in advance.
$\endgroup$ 42 Answers
$\begingroup$Assuming we define $\mathrm{Cov}[X,Y | A] = E[(X - E[X|A])(Y - E[Y|A])|A]$, we will have (for any nonzero event $A$ including "$X > 0 \wedge Y > 0$")
$$ \mathrm{Cov}[X,Y | A] = E[XY|A] - E[X|A] E[Y|A] - E[X|A] E[Y | A] + E[X|A]E[Y|A]$$ $$ = E[XY|A] - E[X|A]E[Y|A]$$
by linearity of conditional expectation. So your formula holds!
$\endgroup$ 1 $\begingroup$The formula which you wrote at the top holds for any two random variable $X,Y$. This means your formula holds under the condition of $X\gt0, Y\gt0$.
$\endgroup$ 1