Why is my variance negative?

121 Views Asked by At

Let $Y_1 \sim Gamma(2,1)$, and $Y_2|Y_1 \sim f_{Y_2}(Y_2)$, where $y_1\geq y_2\geq 0$.

Where $$f_{Y_2}(y_2) = \frac{1}{y_1}$$

$$f_{Y_1}(y_1) = y_1 \exp( -y_1)$$

Goal: Find standard deviation of $Y_2 - Y_1$

Start with

$$Var(Y_1) = 1, E(Y_1) = 1$$

$$E(Y_2|Y_1) = \int^{y_1}_0 \frac{y_2}{y_1}dy_2 = \frac{y_1}{2}$$

$$E(Y_2^2|Y_1)= \int^{y_1}_0 \frac{y_2^2}{y_1}dy_2 = \frac{y_1^2}{3} $$

$$Var(Y_2|Y_1) = E(Y^2_2|Y_1) - (E(Y_2|Y_1))^2 = \frac{y_1^2}{3} - \frac{y_1^2}{4} = \frac{y_1^2}{12}$$

\begin{align*} Var(Y_2) = & E(Var(Y_2|Y_1))+ Var(E(Y_2|Y_1))\\ = & E\left (\frac{y_1^2}{12} \right ) + Var\left (\frac{y_1}{2}\right )\\ = & E\left (\frac{y_1^2}{12}\right ) + Var\left (\frac{y_1}{2}\right )\\ = & \frac{2}{12} + \frac{1}{4}\\ = & \frac{5}{12} \end{align*}

The formula I am using is $Var(Y_1 - Y_2) = Var(Y_1) + Var(Y_2) - 2Cov(Y_1, Y_2)$

So now I need

\begin{align*} Cov(Y_1, Y_2) = & E(Y_1 Y_2) - E(Y_1)E(Y_2)\\ = & E(Y_1 Y_2) - E(Y_1)E(E(Y_2|Y_1))\\ = & E(Y_1 Y_2) - (1)\frac{1}{2} \end{align*}

Now find

\begin{align*} E(Y_1Y_2) = &\int^{\infty}_0 \int^{y_1}_0 y_1 y_2 \exp(-y_1) dy_2 dy_1\\ = & 3 \end{align*}

Thus $Cov(Y_1, Y_2) = 3 - \frac{1}{2} = \frac{5}{2}$

Hence

\begin{align*} Var(Y_1-Y_2) = & Var(Y_1) + Var(Y_2) - 2Cov(Y_1, Y_2) \\ = & 1 + \frac{5}{12} - 5 \end{align*}

Which clearly can't be true. I don't where I went wrong.

I tried another approach by transforming the random variables and finding the distribution of $Y_1 - Y_2$ which did produce a realistic answer. However, I would like to know what was wrong with this approach.

2

There are 2 best solutions below

0
On BEST ANSWER

I found my mistake.

$$E(Y_1) = 2$$

$$Var(Y_1) = 2$$

Therefore

\begin{align*} Var(Y_2) = & E\left (Var(Y_2|Y_1)\right) + Var\left ( E(Y_2|Y_1)\right ) \\ = & E \left ( \frac{y^2_1}{12}\right ) + Var \left( \frac{y_1}{2} \right ) \\ = & \frac{6}{12} + \frac{2}{4}\\ = &1 \end{align*}

In addition, the $Cov(Y_1, Y_2) = 3 - (2)\frac{2}{2} = 1$

\begin{align*} Var(Y_1 - Y_2) = &Var(Y_1) + Var(Y_2) - 2 Cov(Y_1, Y_2)\\ = & 2 + 1 - 2(1)\\ = & 1 \end{align*}

0
On

$$Y_1\sim\mathcal{Gamma}(2,1) \iff [~\mathsf E(Y_1)=2, \mathsf{Var}(Y_1)=2~]$$


$$Y_2\mid Y_1\sim\mathcal U(0,Y_1) \iff \left[\mathsf E(Y_2\mid Y_1)=\tfrac 12Y_1,\mathsf{Var}(Y_2\mid Y_1)=\tfrac 1{12}Y_1^2\right]$$


$$\begin{align}\mathsf{Var}(Y_2)&=\mathsf E(\mathsf{Var}(Y_2\mid Y_1))+\mathsf{Var}(\mathsf{E}(Y_2\mid Y_1))\\[1ex]&=\tfrac1{12}\mathsf E(Y_1^2)+\tfrac 14\mathsf{Var}(Y_1)\\[1ex]&=\tfrac 1{12}(\mathsf{Var}(Y_1)+\mathsf{E}(Y_1)^2)+\tfrac 14\mathsf{Var}(Y_1)\\[1ex]&=\tfrac 1{12}(2+2^2)+\tfrac 14\cdot 2\\[1ex]&=1\\[2ex]\mathsf{Cov}(Y_1,Y_2)&=\mathsf E(\mathsf{Cov}(Y_1,Y_2\mid Y_1))+\mathsf{Cov}(\mathsf E(Y_1\mid Y_1),\mathsf E(Y_2\mid Y_1))\\&=\mathsf E(0)+\mathsf{Cov}(Y_1,\tfrac 12Y_1)\\&=\tfrac 12\mathsf{Var}(Y_1)\\&=1\\[2ex]\mathsf {Var}(Y_2-Y_1) &= \mathsf{Var}(Y_2)+\mathsf{Var}(Y_1)-2\mathsf{Cov}(Y_1,Y_2)\\[1ex]&=1+2-2\\[1ex]&=1\end{align}$$