MSEP error derivation I have random variable $X$ and set of observations $\mathcal{D}$. Let $\widehat{X}$ be an estimator for $E[X|\mathcal{D}]$ and predictor for $X$. Mean square error of prediction MSEP is defined as
$$
msep_{X|\mathcal{D}} = E[(\widehat{X} - X)^2|\mathcal{D}]
$$ 
In the book it says also
$$
msep_{X|\mathcal{D}} (\widehat{X}) = Var(X|\mathcal{D}) + (\widehat{X} - E[X|\mathcal{D}])^2
$$
and I do not know how to get this.
I thought it would go through with variance formula, where I set
$$
msep_{X|\mathcal{D}} = E[(\widehat{X} - X)^2|\mathcal{D}] = Var(\widehat{X} - X|\mathcal{D}) + E[(\widehat{X} - X)|\mathcal{D}]^2
$$
but I could not proceed.
Any help would be great.
 A: I assume you mean that $E\left[ {\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}} \right]=E\left[ X|D \right]$.
So first, note that if $E\left[ XY|D \right]<\infty $ and $X,Y$ are both measurable with respect to $D$, then $E\left[ XY|D \right]=YE\left[ X|D \right]$.  Now, by definition:
     $MS{{E}_{{{P}_{X|D}}}}\left( {\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}} \right)=E\left[ {{\left( X-\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X} \right)}^{2}}|D \right]=E\left[ {{X}^{2}}|D \right]-2\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}E\left[ X|D \right]+E\left[ {{{\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}}}^{2}}|D \right]$.
Also by definition (of the conditional variance), we get
     $E\left[ {{X}^{2}}|D \right]=\operatorname{Var}\left( X|D \right)-{{E}^{2}}\left[ X|D \right]$.
Putting it together, using the fact that $E\left[ {\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}} \right]=E\left[ X|D \right]$ implies $E\left[ \overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}|D \right]=\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}$:
     $MS{{E}_{{{P}_{X|D}}}}\left( {\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}} \right)=\operatorname{Var}\left( X|D \right)+{{\left( \overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}-E\left[ X|D \right] \right)}^{2}}$.
(Since ${{\left( \overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}-E\left[ X|D \right] \right)}^{2}}={{E}^{2}}\left[ X|D \right]+{{\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}}^{2}}-2\overset{\lower0.5em\hbox{$\smash{\scriptscriptstyle\frown}$}}{X}E\left[ X|D \right]$).
