# When is E(A*B) = E(A * E(B))?

I'm looking at the documentation for the econml python package. On this page it is stated that:

$$\begin{split}E[Y_{i, t}^{IPS} | X, W] =~& E\left[\frac{Y_i 1\{T_i=t\}}{p_t(X_i, W_i)} | X_i, W_i\right] = E\left[\frac{Y_i^{(t)} 1\{T_i=t\}}{p_t(X_i, W_i)} | X_i, W_i\right]\\ =~& E\left[\frac{Y_i^{(t)} E[1\{T_i=t\} | X_i, W_i]}{p_t(X_i, W_i)} | X_i, W_i\right] = E\left[Y_i^{(t)} | X_i, W_i\right]\end{split}$$ where $$Y_i$$ is some dependent variable, $$T_i$$ is a treatment variable, $$X_i, W_i$$ are covariates, and $$p_t(X_i, W_i)$$ is the probability that $$T = t$$.

I don't understand the third equality (from top line at the right to bottom line at the left). It looks like something of the form:

$$E[A*B | X] = E[A * E[B | X] | X]$$

where $$A = \frac{Y_i}{p_t(X_i, W_i)}$$ and $$B=1\{T_i=t\}$$. But unless I'm mistaken this equality does not hold in general.

Can someone explain to me why this equality holds in this case? Thanks!

• What does "$Y_i^{(t)}$" refer to??
– whuber
Commented Apr 23, 2021 at 13:23
• $Y_i^{(t)}$ refers to the potential outcome that $Y$ would have had, if the treatment for instance i had been t (regardless of whether the true treatment was really t). In case the true treatment T is not t, then it is a counterfactual outcome that can never be observed. Commented Apr 23, 2021 at 13:52

The issue here is not simply one of expectations, but of conditional expectation given a random variable.

I learnt this stuff a few years ago and don't remember it too well, but I'll give it a shot.

The basic intuition is when we say $$E[A | X]$$ we are saying what is the distribution of $$A$$ if we know $$X$$. It then is a function of $$X$$. For example if $$A = X + U$$, $$U \sim N(0,1)$$ then $$E[A | X] = X + E[U|X] = X + E[U] = X$$ as $$U$$ is independent of $$X$$ and has mean 0. So the expectation of $$A$$ given $$X$$ is just $$X$$.

We have a few basic properties we can use: \begin{align} (A) && E[A|X] = E\left[E\left[A|X\right]|X\right]\\ (B) && E\left[B * E\left[A|X\right]|X\right] = E[ B | X] E[A|X]\\ \text{for A and B independent, } \; (C) && E[A * B |X] = E[A|X] E[B|X] \end{align}

To understand these things more deeply you need to learn about sigma algebras, conditional expectation etc. See Capinski and Kopp, Measure, integral and probability, 2004 for a textbook on that. Unfortunately I can't remember it well enough to give a good intuitive explanation for why (A), (B) and (C) hold if they're not clear to you.

We can then apply these to get the result

$$\begin{split} E\left[\frac{Y_i^{\left(t\right)} 1\{T_i = t\}}{p_t\left(X_i , W_i \right)} | X_i , W_i \right] & = E\left[ E\left[\frac{ Y_i^{\left(t\right)} 1\{T_i = t\}}{p_t\left(X_i , W_i \right)} | X_i , W_i \right] | X_i , W_i \right] (1)\\ & = E\left[\frac{ E\left[Y_i^{\left(t\right)} 1\{T_i = t\} | X_i , W_i \right]}{p_t\left(X_i , W_i \right)} | X_i , W_i \right] (2) \\ & = E\left[\frac{ E\left[Y_i^{\left(t\right)}| X_i , W_i \right] E\left[ 1\{T_i = t\}| X_i , W_i \right] }{p_t\left(X_i , W_i \right)} | X_i , W_i \right] (3) \\ & = E\left[\frac{ E\left[Y_i^{\left(t\right)}| X_i , W_i \right] p_t\left(X_i , W_i \right) }{p_t\left(X_i , W_i \right)} | X_i , W_i \right] (4) \\ & = E\left[E\left[Y_i^{\left(t\right)}| X_i , W_i \right] | X_i , W_i \right] (5) \\ & = E\left[Y_i^{\left(t\right)}| X_i , W_i \right] (6) \end{split}$$

(1) holds by (A)

(2) holds because $$p_t\left(X_i , W_i \right) = E\left[ 1\{T_i = t\}| X_i , W_i \right]$$, so we can apply (B)

(3) holds by (C)

(4) holds by definition in the link you said

(5) is just cancelling numerator and denominator

(6) holds by (A)

• This answer is exactly what I was looking for, thanks! Commented Apr 24, 2021 at 17:30
• No worries at all, glad to help! Commented Apr 24, 2021 at 17:36