Finding the expected squared error loss of the mean under a normal conjugate posterior? Suppose that we have that $\hat{\theta} = B(A+B)^{-1}Y + A(A+B)^{-1}\theta_0$ and that $Y \sim N(\theta_0, A+B)$, so that $\operatorname{E}(Y) = \theta_0$ and $\operatorname{Var} (Y) = A+B$. 
I would like to show that:
$$
\operatorname{E}\left(\|\hat{\theta}-\theta\|^2\right) = \operatorname{trace} \left(B(A+B)^{-1}A(A+B)^{-1}B\right) + \left\| A(A+B)^{-1}(\theta_0-\theta)\right\|^2.
$$
I recognize that this can be done using the bias variance decomposition. However, I am unable to get the $A(A+B)^{-1}$ term inside the squared norm. Would anyone have any idea what I am doing wrong? Thanks.
 A: It appears that you have in mind that $\theta \sim N(\theta_0, B)$ and $Y\mid\theta\sim N(\theta,A)$.
The only way I know how to make sense of an expression like $\operatorname{E} \left( \|\hat{\theta}-\theta\|^2 \right)$ in this context is that it means the marginal expected value and not the conditional expected value given $\theta$ or anything like that.  So this expected value should not be a function of $\theta$, and yet that is what you've got in the equality you say you want to prove.
Can you show that if $U$ is a random variable taking values in $\mathbb R^{n\times1}$ and $\operatorname{E}(U)=0$ then $\operatorname{E}(\|U\|^2) = \operatorname{trace}(\operatorname{var}(U))$?
Note that


*

*$\|U\|^2 = U^\top U$ and for matrices $A\in\mathbb R^{n\times m}$, and $B\in\mathbb R^{m\times n}$, you have $$\operatorname{trace}(AB) = \operatorname{trace}(BA),$$ so

*$\|U\| = U^\top U = \operatorname{trace}(U^\top U) = \operatorname{trace}(UU^\top),$ and

*since the trace functional is linear, it commutes with the expectation operator.

