# Computing correlation of random variables $X$ and $Y$

Consider a random variable $Y$ with $\mathbb{E}(Y) = \mu_Y$ and $\text{Var}(Y) = \sigma_Y^2$. Let $X$ be another random variable with $\mathbb{E}(X|Y) = A+BY$ and $\text{Var}(X|Y) = \sigma_{X|Y}^2$, where $A, B, \sigma_{X|Y}^2$ constant.

Compute $\rho = \frac{\text{Cov(X,Y)}}{\sigma_X\sigma_Y} = \frac{\mathbb{E}(XY) - \mathbb{E}(X)\mathbb{E}(Y)}{\sigma_X\sigma_Y}$.

My thoughts

I first calculated $\mathbb{E}(X)$ using conditional expectation, and found that $\mathbb{E}(X) = A+B\mu_Y$, thus $E(X|Y) = \mu_X + B(Y-\mu_Y)$. I then computed $\text{Var}(X) = \sigma_X^2$ using the conditional variance formula and found that $\text{Var}(X) = B^2\sigma_Y^2+\sigma_{X|Y}^2 = \sigma_X^2$, thus we can write $\sigma^2_{X|Y} = \sigma_X^2-B^2\sigma_Y^2$.

Therefore, I have $\mathbb{E}(X)$ and $\mathbb{E}(Y)$, but now I need to find $\mathbb{E}(XY)$ to calculate $\rho$. Since this is a follow up exercise, I assume that I need to use the conditional variance $\sigma_{X|Y}^2$, however I don't know how to proceed. Any thoughts?

• $E(XY)=E(E(XY\mid Y))=E(Y\,E(X\mid Y))$. – StubbornAtom Jun 22 '18 at 9:58

By definition $\mathbb{E}X1_{B}\left(Y\right)=\mathbb{E}\left[\mathbb{E}\left[X\mid Y\right]1_{B}\left(Y\right)\right]$ for every Borel set $B$.
This can be extended to $\mathbb{E}Xf\left(Y\right)=\mathbb{E}\left[\mathbb{E}\left[X\mid Y\right]f\left(Y\right)\right]$ for suitable functions $f$.
Taking for $f$ the identity we find: $$\mathbb{E}XY=\mathbb{E}\left[\mathbb{E}\left[X\mid Y\right]Y\right]=\mathbb{E}\left[\left(A+BY\right)Y\right]=A\mu_{Y}+B\mathbb{E}Y^{2}$$
This leads to: $$\mathsf{Cov}\left(X,Y\right)=\sigma_{Y}^{2}$$