# Prove E[Y|X] = f(X)

I have a model $$Y = f(X) + \epsilon$$

where $$\epsilon$$ is independent of $$X$$ and $$\mathbb{E}[\epsilon]=0, \mathbb{E}\left[\epsilon^2\right]=\sigma^2$$.

Show that $$f(X)=\mathbb{E}[Y \mid X]$$

This is my attempt at the proof:

\begin{aligned} & E[Y \mid X] \\ &= E[f(X)+\varepsilon \mid X] \\ &= E[f(X) \mid X]+E[\varepsilon \mid X] \\ &= E[f(X) \mid X]+E[\varepsilon] \\ &= E[f(X) \mid X]+0 \\ &= E_{Y \mid X}[f(X) \mid X] \quad\quad\quad \quad \quad\ \ (5) \\ &= \sum_{y \mid x} f(X) P(Y|X=y| x) \quad\quad(6) \\ &= f(X) \sum_{y \mid x} P(Y|X=y| x) \quad\quad(7)\\ &= f(X) \end{aligned}

• You were done before you reached step (5). In fact, at that point $Y$ no longer appears anywhere. You can't just stick $Y$ back in, either, because it involves $\epsilon,$ which also has vanished. A basic property of conditional expectations -- usually proven as soon as conditional expectation is defined -- is that $E[f(X)\mid X] = f(X).$ This is called "taking out what is known."
$$\mathbb{E}[Y|X] = \mathbb{E}[f(X)+\epsilon|X] = \mathbb{E}[f(X)|X]+\mathbb{E}[\epsilon|X] = \mathbb{E}[f(X)|X]+\mathbb{E}[\epsilon] = f(X)+0$$
• @PeterLeopold The OP asssumes that X and $\epsilon$ are independent. Oct 1, 2022 at 13:03