expected squared prediction error derivation

957 Views Asked by At

I'm having a hard time deriving the formula on page 223 of Hastie et al. for the expected squared prediction error:

from the book

Here are my first steps:

$$ Err = E[(Y-\hat f(x))^2] = \\ E[(Y -f(x) +f(x) -\hat f(x))^2 ] = \\ E[(Y -f(x))^2 + 2(Y -f(x))(f(x) -\hat f(x))+(f(x) -\hat f(x))^2]=\\ E[(f(x)+\varepsilon -f(x))^2 + 2(Y -f(x))(f(x) -\hat f(x))+(f(x) -\hat f(x))^2]=\\ E[(f(x)+\varepsilon -f(x))^2] + 2E[(Y -f(x))(f(x) -\hat f(x))]+ E[(f(x) -\hat f(x))^2]=\\ E[\varepsilon^2 -0] + 2E[(Y -f(x))(f(x) -\hat f(x))]+ E[(f(x) -\hat f(x))^2]=\\ \sigma_\varepsilon^2 + 2E[(Y -f(x))(f(x) -\hat f(x))]+ E[(f(x) -\hat f(x))^2]=\\ $$

now I'm stuck, even if I expand the expressions I don't get to the result.

1

There are 1 best solutions below

4
On BEST ANSWER

Conditional on $X=x_0$, we have $Y = f(x_0) + \epsilon$ under the usual assumption that $\epsilon$ and $X$ are independent.

Therefore, \begin{align} \mathrm{Err}(x_0) & = E[(f(x_0) + \epsilon-\hat f(x_0))^2]\\ & = E[\epsilon^2] + E[2\epsilon(f(x_0)-\hat f(x_0))] + E[(f(x_0) - \hat f(x_0))^2]\\ & = \sigma_\epsilon^2 + E[(f(x_0) - \hat f(x_0))^2]\\ & = \sigma_\epsilon^2 + E[(f(x_0) - E\hat f(x_0))^2] + E[(E\hat f(x_0) - \hat f(x_0))^2] + 2\times 0\\ & = \sigma_\epsilon^2 + (f(x_0) - E\hat f(x_0))^2 + E[(E\hat f(x_0) - \hat f(x_0))^2] \end{align}