# How to understand random assignment eliminates selection bias in the potential outcomes framework

In Angrist & Pischke's book mostly harmless econometrics, they explain that if the treatment in an RCT $$D_i$$ is randomly assigned, then $$D_i$$ is independent of potential outcomes and the following holds:

\begin{align} E[Y_i|D_i = 1] - E[Y_i|D_i = 0] &= E[Y_{1i}|D_i = 1] \color{red}{- E[Y_{0i}|D_i = 0]} \\\\ &= E[Y_{1i}|D_i = 1] \color{red}{- E[Y_{0i}|D_i = 1]} \end{align}.

The main thing here, as I understand it, is that we can switch the terms in red $$E[Y_{0i}|D_i = 0]$$ $$E[Y_{0i}|D_i = 1]$$. But How do I interpret this? I get why we want to randomly assign treatment (because we want the treatment group and control group to be identical), but I don't understand what the above equation says. For me it looks like the expected outcome for the control group is the same even if they get treatment, i.e, $$D_i = 1$$. I think I am misinterpreting something here.

For completeness. After this, they go on to say that we can simplify further. Starting from the last line above:

\begin{align} E[Y_{1i}|D_i = 1] - E[Y_{0i}|D_i = 1] &= E[Y_{1i} - Y_{0i} | D_i = 1] \\\\ &= E[Y_{1i} - Y_{0i}] \end{align}, noting that "The main thing, however, is that random assignment of $$D_i$$ eliminates selection bias".

Let me know if I need to add some context!

an intutive explanation is that given independence of treatment from potential outcomes the average of $$Y_0$$ in the control group (roughly E[Y_{i0}|D=0]) is as good an estimate of E[$$Y_0$$] as the average of $$Y_0$$ in the experimental group. Thus, given the aforementioned independence you can 'exchange' participants in the experimental and the control group; they are just two random samples from the larger population.