I am reading the following:
I would like to write out explicitly what $E_X[\hat{Y} \mid Y = 0, A = a]$. I think the relevant definitions are in: https://en.wikipedia.org/wiki/Conditional_expectation#Conditional_expectation_with_respect_to_a_random_variable
I was told that $$E_X[Y^\text{?} \mid Y = 0, A = a] =\frac{1}{(p(X \mid Y = 0 \& A = a) } \int_{X \mid Y=0, A=a} \left (\int_{(Y,A)} p(X, A, Y) \, dA \, dY \right ) \hat{Y} \, dX$$
however I do not quite understand how this is derived. Can someone help explain this?
Here is what I think. Generally $E[X \mid Y] = \frac{1}{p(Y)} \cdot E[X \text{ and } Y]$. The $$\int_{(Y, A)} p(X, A, Y) \, dA \, dY = \int_Y \int_A p(X,A,Y) \, dA \, dY$$ is the marginal density on $X.$ Since we are conditioning on $Y=0$ and $A = A$ then $\hat{Y}$ depends only on the covariates $X$, i.e, a function of $X$. We want to find the expected value that function.
Is the above a correct explanation of what is happening? I will greatly appreciate input.

$$ \require{cancel} \begin{align} \text{right: } & \operatorname E X = \int\limits_{\mathbb R} xf(x)\,dx \\[10pt] \text{wrong: } & \xcancel{\operatorname E X = \int\limits_{\mathbb R} X f(X)\,dX} \end{align} $$ Note: capital $X$ appears in $\operatorname E X$ and lower-case $x$ in the integral.
Capital $X$ and lower-case $x$ are two different things, and without attention to the distinction one cannot make one's way through some logical arguments in probability theory, nor even understand such an expression as $\Pr(X\le x).$
There is such a thing as $\Pr(X\le x\mid A),$ where $A$ is an event.
So there is such a thing as $\Pr(X\le x\mid Y=y),$ since $\big[Y=y\big]$ is an event.
Hence there is also such a thing as the conditional distribution of the random variable $X$ given the event $\big[Y=y\big].$
So there is such a thing as the conditional expected value of the random variable $X$ given the event $\big[Y=y\big].$
That is denoted $\operatorname E(X\mid Y=y).$
That quantity depends on what number (lower-case) $y$ is. Let us therefore call it $g(y).$
Then $\operatorname E(X\mid Y)$ is defined as $g(Y),$ where this time we see the capital $Y,$ i.e. the random variable.
Thus $\operatorname E(X\mid Y)$ is a random variable whose value is determined by that of $Y.$