I am trying to solve an exercise for my homework and am stuck. The question is the following:
Assume you have two dependent random variables $X,Y$. The expectation and the variance are given by $E(Y|X=x)=5x$ and $var(Y|X=x)=2x+x^2$ and assume that $E(X)=12$ and $Var(X)=4$. Compute the expectation and variance of $Y$
I succeeded in computing the expectation, but unfortunately I am stuck for the variance. Here is what I tried:
$$Var(Y)= \int_{\mathbb{R}^2}(y-\mu_Y)^2 f_{X,Y}(x,y)dxdy$$ $$=\int_\mathbb{R}\big( \int_\mathbb{R} (y-\mu_Y)^2 f_{Y|X}(y|x)dy\big)f_X(x)dx.$$
Question: Can the integral in the parentheses be expressed in terms of $E(Y|X=x)=5x$ and $var(Y|X=x)=2x+x^2$? If yes, then I know how to conclude the computation. However I am not able to show this. First I thought that the integral in the parentheses is just $Var(Y|X=x)$, but it isn't. In fact, the following holds:
$$Var(Y|X=x)=\int_\mathbb{R} (y-E(Y|X=x))^2 f_{Y|X}(y|x)dy,$$ where $\mu_Y$ is known (see below).
Note: For completeness, I write down the computation for the expectation, as I guess that the one of the variance must be similar.
$$E(Y)=\int_{\mathbb{R}^2}y f_{X,Y}(x,y)dxdy=\int_\mathbb{R}\big( \int_\mathbb{R} y f_{Y|X}(y|x)dy\big)f_X(x)dx=\int_\mathbb{R}E(Y|X=x) f^X(x) dx=\int_\mathbb{R}5xf^X(x)dx=5E(X).$$
In the third equation, I used the definition of conditional expectation, and in the last one the definition of expectation of $X$.
As it is an homework I cannot show you the entire solution.
First request:
$$\mathbb{E}[Y]=\mathbb{E}[\mathbb{E}[Y|X=x]]=\mathbb{E}[5x]=5\mathbb{E}[X]=60$$
This is the right way to the solution: now considering that
$$\mathbb{V}[Y]=\mathbb{E}[Y^2]-\mathbb{E}^2[Y]$$
...I think you can conclude your homework without "shedding too much blood".