I have a derivation from my book, I have a problem with the very first line:
$$ \begin{align} E[E(Y|X)] &= \int_{-\infty}^\infty E(Y|x)f_1(x)dx <- \text{why dx}\\ &= \int_{-\infty}^\infty\int_{-\infty}^\infty yf(y|x)f_1(x)dydx\\ &=\int_{-\infty}^\infty y \int_{-\infty}^\infty f(x,y)dxdy\\ &=\int_{-\infty}^\infty yf_2(y)dy\\ &= E(Y) \end{align} $$
Now everything after the first integral I understand, thats just splitting the integral up and getting marginal/joint densities. But why do we choose $dx$ in the first integral? seems arbitrary, what is it based on?
$E[Y\mid X]$ is a function of $X$: its value when $X=x$ is $E[Y\mid X=x]$. We now weight each of these values by $f_1(x)$, intuitively the probability that $X=x$, and ‘average’ (i.e., integrate over $x$) to get the expected value of $E[Y\mid X]$, which turns out to be $E[Y]$.
It’s no different in principle from calculating $E[Z]$ when $Z$ is any other function of $X$, e.g., $Z=X^2$.