# Bias-variance decomposition of MSE

I'm trying to decompose the MSE into the bias and variance terms and have done the following: $$MSE = \frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y_i})^2$$

$$E(MSE) = E\left[\frac{1}{n}\sum_{i=1}^{n} (y_i - \hat{y_i})^2\right]$$

$$= \frac{1}{n}\sum_{i=1}^{n}E[(y_i - \hat{y_i})^2]$$ $$= \frac{1}{n}\sum_{i=1}^{n}E[y_i^2 - 2\hat{y_i}y_i + \hat{y_i}^2]$$ $$= \frac{1}{n}\sum_{i=1}^{n}\{Var[y_i] + Var[\hat{y_i}] + E[y_i]^2 + E[\hat{y_i}]^2 - 2E[\hat{y_i}y_i]\}$$ $$= \frac{1}{n}\sum_{i=1}^{n}\{\sigma^2 + Var[\hat{y_i}] + E[y_i]^2 + E[\hat{y_i}]^2 - 2E[\hat{y_i}y_i]\}$$

However, I am not sure how to factor the last three terms into the bias$$^2$$ term. Would it be correct to assume $$y_i$$ and $$\hat{y_i}$$ are independent and hence write $$E[y_i\hat{y_i}]=E[y_i]E[\hat{y_i}]$$?

The random part is $$\hat{y}_i$$, \begin{align} E[y_i]^2 + E[\hat{y}_i]^2-2E[\hat{y}_iy_i] &= y_i^2+E[\hat{y}_i]^2-2y_iE[\hat{y}_i] \\ &=(y_i-E[\hat{y}_i])^2 \end{align}