# Bias Variance Decomposition 2.7 in Elements of Statistical Inference

I try to derive 2.7 from the book. I expose my demonstration

$$E_\tau[(y_0-\hat{y}_0)^2]=E_\tau[y_0^2]-2E_{\tau}[y_{0}\hat{y_{0}}]+E_{\tau}[\hat{y_{0}}^{2}]$$ $$= y_{0}^{2}-2y_{0}E_{\tau}[\hat{y_{0}}]+E_{\tau}[\hat{y_{0}}^{2}]$$

I add and substract $$(x_{0}^{T}\beta)^{2}$$, I add and substract $$(E_{\tau}[y_{0}])^{2}$$ which gives

$$E_{\tau}[(y_{0}-\hat{y_{0}})^{2}]= y_{0}^{2}-(x_{0}^{T}\beta)^{2}+E_{\tau}[\hat{y_{0}}^{2}]-(E_{\tau}[y_{0}])^{2}+(E_{\tau}[y_{0}])^{2}-2y_{0}E_{\tau}[\hat{y_{0}}]+(x_{0}^{T}\beta)^{2}$$

Considering the first two terms and taking the conditional expectation: $$E_{y_{0}|x_{0}}[y_{0}^{2}-(x_{0}^{T}\beta)^{2}]=E_{y_{0}|x_{0}}[y_{0}^{2}]-(x_{0}^{T}\beta)^{2}=E_{y_{0}|x_{0}}[y_{0}^{2}]-E_{y_{0}|x_{0}}[y_{0}]^{2}=Var[y_{0}|x_{0}]$$

Considering the next two terms and taking the conditional expectation: $$E_{y_{0}|x_{0}}[E_{\tau}[\hat{y_{0}}^{2}]-(E_{\tau}[y_{0}])^{2}]=E_{\tau}[\hat{y_{0}}^{2}]-(E_{\tau}[y_{0}])^{2}=Var_{\tau}[y_{0}^{2}]$$

I consider the last three terms, take the conditional expectation and try to derive the bias: $$E_{y_{0}|x_{0}}[(E_{\tau}[y_{0}])^{2}-2y_{0}E_{\tau}[\hat{y_{0}}]+(x_{0}^{T}\beta)^{2}]=(E_{\tau}[y_{0}])^{2}-2E_{y_{0}|x_{0}}(y_{0})E_{\tau}(\hat{y_{0}})+E_{y_{0}|x_{0}}[(x_{0}^{T}\beta)^{2}]$$

But to me the squared bias is $$bias^{2}=(E_{\tau}(\hat{y_{0}})-\hat{y_{0}})^{2}=(E_{\tau}[y_{0}])^{2}-2\hat{y_{0}}E_{\tau}(\hat{y_{0}})+(x_{0}^{T}\beta)^{2}$$

I fail to identify the middle term. How should I have $$E_{y_{0}|x_{0}}(y_{0})=\hat{y_{0}}$$ ?

Any other nice demonstration will be helpful.