---
title: "Chapter 2: Randomized Experiments"
format:
html: default
revealjs:
output-file: 02-randomized-experiments-slides.html
pdf:
output-file: 02-randomized-experiments-handout.pdf
docx:
output-file: 02-randomized-experiments.docx
preview-changed: true
---
{{< include ../latex-macros/macros.qmd >}}
If you look up at the sky on a busy street, do the people walking past look up as well?
Like every causal question, this one names something done (your glance upward),
something that may follow (passers-by glancing upward),
and a group of people it concerns (for instance, people living in Madrid in 2019).
This chapter explains why one kind of study, the randomized experiment, can answer such questions convincingly.
::: {#def-randomized-experiment}
## Experiment and randomized experiment
A study is an **experiment** if the investigator, not the subjects or anyone else, assigns the action of interest:
the investigator decides who gets it.
An experiment is **randomized** if a chance mechanism, such as a coin flip, makes those assignments,
and **nonrandomized** if no chance mechanism makes them, for example when a fixed rule based on each subject's characteristics does [@hernan2020causal, p. 13].
:::
::: {#exm-looking-up}
## Looking up at the sky
Stand on a sidewalk and flip a coin each time a pedestrian approaches:
on heads, look up;
on tails, look straight ahead.
After a few thousand repetitions,
compare, for each action, the share of pedestrians who look up within the next 10 seconds.
This is a randomized experiment (@def-randomized-experiment):
you carry out the action, and the coin decides whom you act on.
Suppose 55% looked up when you did and 1% when you did not.
:::
::: {#exm-looking-up-nonrandomized}
## A nonrandomized version
Now look up whenever a man approaches and straight ahead whenever a woman does.
This is still an experiment, but a nonrandomized one (@def-randomized-experiment):
sex, not a coin, decides the action.
A skeptic could point out that men and women might respond differently to a stranger's upward glance,
so any difference could reflect who was in each group rather than your action;
the groups are not comparable,
and the result persuades far less [@hernan2020causal, p. 13].
:::
::: {.notes}
This chapter is based on @hernan2020causal [Chapter 2, pp. 13-25].
:::
## 2.1 Randomization (pp. 13-16)
---
In a typical study we see only one of Zeus's two potential outcomes:
the one under the treatment he actually got.
Table 2.1 adds the counterfactual columns to the observed data of Table 1.2;
"?" marks the counterfactual outcome that is missing.
::: {.content-visible when-format="html"}
**Table 2.1**: Observed data with counterfactual outcomes, Zeus's family [@hernan2020causal, p. 14]
| Name | $A$ | $Y$ | $Y^{a=0}$ | $Y^{a=1}$ |
|------|-----|-----|-------|-------|
| Rheia | 0 | 0 | 0 | ? |
| Kronos | 0 | 1 | 1 | ? |
| Demeter | 0 | 0 | 0 | ? |
| Hades | 0 | 0 | 0 | ? |
| Hestia | 1 | 0 | ? | 0 |
| Poseidon | 1 | 0 | ? | 0 |
| Hera | 1 | 0 | ? | 0 |
| Zeus | 1 | 1 | ? | 1 |
| Artemis | 0 | 1 | 1 | ? |
| Apollo | 0 | 1 | 1 | ? |
| Leto | 0 | 0 | 0 | ? |
| Ares | 1 | 1 | ? | 1 |
| Athena | 1 | 1 | ? | 1 |
| Hephaestus | 1 | 1 | ? | 1 |
| Aphrodite | 1 | 1 | ? | 1 |
| Polyphemus | 1 | 1 | ? | 1 |
| Persephone | 1 | 1 | ? | 1 |
| Hermes | 1 | 0 | ? | 0 |
| Hebe | 1 | 0 | ? | 0 |
| Dionysus | 1 | 0 | ? | 0 |
:::
With half the counterfactual outcomes missing, Table 2.1 by itself only supports association measures.
Randomized experiments also have missing counterfactuals.
But randomization ensures the values are **missing by chance**,
so effect measures can be consistently estimated despite the missing data.
::: {.notes}
The use of counterfactuals to estimate effects in randomized experiments goes back to Neyman (1923) [@hernan2020causal, p. 13].
:::
### An Ideal Randomized Experiment
::: {#def-ideal-randomized-experiment}
## Ideal randomized experiment
An **ideal randomized experiment** is a randomized experiment (@def-randomized-experiment) that also satisfies the following:
- every participant is followed until the end of the study (no loss to follow-up);
- every participant takes the assigned treatment throughout (full adherence);
- there is a single version of treatment;
- assignment is double-blind: neither the participants nor the investigators know who received which treatment (Chapter 9) [@hernan2020causal, p. 14].
:::
::: {#exm-diamond-experiment}
## A coin for every individual
Take the near-infinite population drawn as a diamond in Figure 1.1,
and flip a coin for each individual, with probability of heads below 50%:
- tails: white group, given the treatment ($A = 1$);
- heads: grey group, given placebo ($A = 0$).
Suppose the experiment is otherwise ideal (@def-ideal-randomized-experiment).
Let $Y = 1$ if the individual has died by day 5 and $Y = 0$ otherwise.
At the end of the study, $\Pr[Y = 1 \mid A = 1] = 0.3$ and $\Pr[Y = 1 \mid A = 0] = 0.6$,
so the associational risk ratio is $0.3/0.6 = 0.5$
and the associational risk difference is $0.3 - 0.6 = -0.3$.
:::
::: {.notes}
Real experiments rarely meet all four requirements.
The ideal version is a teaching device, and later chapters relax it [@hernan2020causal, p. 14].
:::
### Exchangeability
When a coin decides who is treated, it should not matter *which* of the two groups the coin sends to treatment.
The property behind this intuition is exchangeability.
::: {#def-exchangeability}
## Exchangeability
Let $A$ be a dichotomous treatment, with $0 < \Pr[A = 1] < 1$,
and $Y$ a dichotomous outcome with counterfactual outcomes $Y^a$ for $a = 0, 1$ ([Chapter 1](01-introduction.qmd)).
The treated and the untreated are **exchangeable** if, for each treatment value $a$, the risk under $a$ is the same in both groups:
$$
\Pr[Y^a = 1 \mid A = 1] = \Pr[Y^a = 1 \mid A = 0] \quad \text{for } a = 0 \text{ and } a = 1.
$$ {#eq-exchangeability}
Equivalently, the counterfactual outcome is independent of the actual treatment: $Y^a \ind A$ for all $a$ [@hernan2020causal, p. 14].
:::
::: {#exm-swapped-groups}
## Swapping the groups
In @exm-diamond-experiment, suppose the assistants misread the instructions and treated the grey group instead of the white one.
Because the coin formed the groups,
neither group is expected to be at higher risk than the other under either treatment value.
We would still expect a risk of 0.3 among those treated, who are now the grey group,
and a risk of 0.6 among those not treated.
Which group was treated does not matter:
the white and grey groups are exchangeable (@def-exchangeability).
:::
---
::: {#prp-exchangeability-marginal}
## Under exchangeability, treatment does not predict the counterfactual outcome
Let $A$ and $Y$ be dichotomous, with $0 < \Pr[A = 1] < 1$.
If exchangeability (@def-exchangeability) holds, then, for $a = 0, 1$,
$$
\Pr[Y^a = 1 \mid A = 1] = \Pr[Y^a = 1 \mid A = 0] = \Pr[Y^a = 1].
$$
Knowing someone's treatment therefore tells us nothing about that person's $Y^a$ [@hernan2020causal, p. 14].
:::
::: {.proof}
By the law of total probability,
$\Pr[Y^a = 1] = \Pr[Y^a = 1 \mid A = 1] \Pr[A = 1] + \Pr[Y^a = 1 \mid A = 0] \Pr[A = 0]$.
Under exchangeability the two conditional risks have a common value $p$,
so $\Pr[Y^a = 1] = p \paren{\Pr[A = 1] + \Pr[A = 0]} = p$.
:::
That is why randomization matters: it is the study design we expect to deliver exchangeability.
::: {.notes}
Some authors call an exchangeable treatment **exogenous**,
using exogeneity as another name for exchangeability [@hernan2020causal, p. 14].
:::
### In Ideal Randomized Experiments, Association Is Causation
::: {#prp-association-is-causation}
## Association is causation under exchangeability
Let $A$ and $Y$ be dichotomous, with $0 < \Pr[A = 1] < 1$.
Suppose that [consistency](01-introduction.qmd#def-consistency-ch1) holds ($Y = Y^A$)
and that exchangeability (@def-exchangeability) holds.
Then, for $a = 0, 1$,
$$
\Pr[Y^a = 1] = \Pr[Y = 1 \mid A = a].
$$ {#eq-association-causation}
So the causal risk difference $\Pr[Y^{a=1} = 1] - \Pr[Y^{a=0} = 1]$ equals the associational risk difference $\Pr[Y = 1 \mid A = 1] - \Pr[Y = 1 \mid A = 0]$,
and, when $\Pr[Y = 1 \mid A = 0] > 0$, the causal risk ratio equals the associational risk ratio [@hernan2020causal, pp. 14-15].
:::
::: {.proof}
The first step below is @prp-exchangeability-marginal;
the second is consistency, since $Y = Y^a$ for everyone with $A = a$.
$$
\begin{aligned}
\Pr[Y^a = 1] &= \Pr[Y^a = 1 \mid A = a] \\
&= \Pr[Y = 1 \mid A = a].
\end{aligned}
$$
:::
::: {#exm-diamond-causal}
## Causal effects in the coin-flip experiment
In @exm-diamond-experiment the white group was actually treated,
so its risk under treatment is not counterfactual at all.
Assume consistency, and assume, as @exm-swapped-groups argues, that the coin made the groups exchangeable.
Then, by @prp-association-is-causation,
$\Pr[Y^{a=1} = 1] = \Pr[Y = 1 \mid A = 1] = 0.3$
and $\Pr[Y^{a=0} = 1] = \Pr[Y = 1 \mid A = 0] = 0.6$.
The causal risk ratio is $0.3/0.6 = 0.5$ and the causal risk difference is $0.3 - 0.6 = -0.3$,
the same as the associational measures.
:::
---
::: {#rem-counterfactual-baseline}
## Counterfactual outcomes as baseline traits
Here is a second way to see why randomization gives $Y^a \ind A$.
Think of $Y^a$ as a characteristic each person carries into the study, much like a blood type:
it is settled before the coin is flipped,
because it describes the outcome under $a$ regardless of the treatment later assigned.
A coin knows nothing about anyone's blood type, or about anyone's $Y^a$.
The analogy has a limit:
a blood type can be measured at any time,
whereas $Y^a$ is revealed only after treatment, and only in people who actually received $a$ [adapted from @hernan2020causal, p. 15, which uses genetic make-up as the analogy].
:::
### Full and Mean Exchangeability
::: {#def-full-exchangeability}
## Full exchangeability (Technical Point 2.1)
Let $\mathcal{A} = \set{a, a', a'', \ldots}$ be the set of treatment values present in the population
and $Y^{\mathcal{A}} = \set{Y^a, Y^{a'}, Y^{a''}, \ldots}$ the set of all counterfactual outcomes.
There is **full exchangeability** if $Y^{\mathcal{A}} \ind A$,
that is, if the counterfactual outcomes are jointly independent of the treatment.
For a dichotomous treatment, $\mathcal{A} = \set{0, 1}$ and full exchangeability is $\set{Y^{a=1}, Y^{a=0}} \ind A$ [@hernan2020causal, p. 15].
:::
::: {#exm-exchangeable-not-fully}
## Exchangeable but not fully exchangeable
Take a population with four equally common kinds of individuals, written as pairs $(Y^{a=0}, Y^{a=1})$:
the treated are of kinds $(0, 0)$ and $(1, 1)$,
and the untreated are of kinds $(0, 1)$ and $(1, 0)$.
In each treatment group, half have $Y^{a=0} = 1$ and half have $Y^{a=1} = 1$,
so the groups are exchangeable (@def-exchangeability).
But the treated are exactly the individuals whom treatment would not affect,
and the untreated exactly those whom it would,
so the pair $\set{Y^{a=1}, Y^{a=0}}$ depends on $A$,
and full exchangeability (@def-full-exchangeability) fails.
:::
::: {#prp-full-implies-exchangeability}
## Full exchangeability implies exchangeability (Technical Point 2.1)
For any treatment and outcome,
full exchangeability (@def-full-exchangeability) implies $Y^a \ind A$ for each $a$,
which for a dichotomous treatment and outcome is exchangeability (@def-exchangeability).
The converse is false [@hernan2020causal, p. 15].
:::
::: {.proof}
If the whole set $Y^{\mathcal{A}}$ is independent of $A$,
so is each of its members $Y^a$.
@exm-exchangeable-not-fully is a population in which the converse fails.
:::
A coin flip assigns $A$ independently of everything that exists before assignment, including the whole set $Y^{\mathcal{A}}$,
so randomization produces full exchangeability.
---
::: {#def-mean-exchangeability}
## Mean exchangeability (Technical Point 2.1)
For a treatment $A$ and an outcome $Y$ with finite counterfactual means $\E{Y^a}$,
there is **mean exchangeability** if $\E{Y^a \mid A = a'} = \E{Y^a}$
for all treatment values $a$ and $a'$ present in the population [@hernan2020causal, p. 15].
:::
::: {#exm-mean-not-exchangeable}
## Equal means, unequal spreads
For a dichotomous outcome and treatment, $\E{Y^a \mid A = a'} = \Pr[Y^a = 1 \mid A = a']$,
so mean exchangeability says that the risks in @eq-exchangeability are equal:
it is the same as exchangeability (@def-exchangeability).
For a continuous outcome, mean exchangeability can hold while exchangeability in the sense $Y^a \ind A$ fails.
Suppose that, under each treatment value $a$, systolic blood pressure $Y^a$ has mean 130 millimeters of mercury in both the treated and the untreated,
but a standard deviation of 10 in the treated and 20 in the untreated.
Mean exchangeability (@def-mean-exchangeability) holds,
yet $Y^a$ is not independent of $A$, because its spread depends on $A$.
:::
::: {#prp-mean-exchangeability-suffices}
## Mean exchangeability suffices (Technical Point 2.1)
Let $a$ be a treatment value with $\Pr[A = a] > 0$, and let $\E{Y^a}$ be finite.
If consistency ($Y = Y^A$) and mean exchangeability (@def-mean-exchangeability) hold, then
$$
\E{Y^a} = \E{Y \mid A = a}.
$$ {#eq-mean-exchangeability-suffices}
Full exchangeability implies $Y^a \ind A$ for each $a$ (@prp-full-implies-exchangeability),
which in turn implies mean exchangeability,
so any of the three can take its place here [@hernan2020causal, p. 15].
:::
::: {.proof}
$$
\begin{aligned}
\E{Y \mid A = a} &= \E{Y^a \mid A = a} && \text{(consistency)} \\
&= \E{Y^a} && \text{(mean exchangeability)}.
\end{aligned}
$$
If $Y^a \ind A$, then $\E{Y^a \mid A = a'} = \E{Y^a}$ for every $a'$ with $\Pr[A = a'] > 0$,
which is mean exchangeability.
:::
### Caution: $Y^a \ind A$ Is Not $Y \ind A$
::: {#prp-exchangeability-association}
## Under exchangeability, association signals an average effect
Under the conditions of @prp-association-is-causation
(dichotomous $A$ and $Y$, $0 < \Pr[A = 1] < 1$, consistency, and exchangeability),
treatment and outcome are [independent](01-introduction.qmd#def-independence), $Y \ind A$,
if and only if there is no [average causal effect](01-introduction.qmd#def-average-causal-effect),
that is, if and only if $\Pr[Y^{a=1} = 1] = \Pr[Y^{a=0} = 1]$.
:::
::: {.proof}
By @eq-association-causation,
$\Pr[Y = 1 \mid A = 1] - \Pr[Y = 1 \mid A = 0] = \Pr[Y^{a=1} = 1] - \Pr[Y^{a=0} = 1]$.
$Y \ind A$ means that the left side is 0, and no average causal effect means that the right side is 0.
:::
::: {.callout-warning title="Exchangeability Is Not Independence of Treatment and Outcome"}
- $Y^a \ind A$ (exchangeability) says that, given any one treatment level for everybody, both groups would share the same risk.
- $Y \ind A$ says that observed treatment and observed outcome are not associated.
In a marginally randomized experiment with consistency, exchangeability is expected to hold.
If treatment also has an average causal effect, $Y \ind A$ fails (@prp-exchangeability-association) [@hernan2020causal, p. 15].
The book's margin note puts this in terms of individual effects,
but an effect in some individuals is not enough to create an association.
By @prp-exchangeability-association, with consistency,
if exchangeability held in a population whose individual effects cancel out on average, as in Table 1.1,
then $Y \ind A$ would hold despite those individual effects.
:::
### Does Exchangeability Hold in Table 2.1?
Until Chapter 10, let each of the 20 individuals stand for 1 billion identical ones,
so that proportions in the tables are population probabilities and sampling variability plays no role.
::: {#exm-table-2-1-exchangeability}
## Exchangeability fails in the heart transplant study (Tables 1.1 and 2.1)
Check $Y^a \ind A$ for $a = 0$, pretending we can see the counterfactual outcomes of Table 1.1.
Among the 13 treated, $Y^{a=0} = 1$ for 7: Poseidon, Ares, Athena, Persephone, Hermes, Hebe, and Dionysus;
among the 7 untreated, for 3: Kronos, Artemis, and Apollo:
$$
\Pr[Y^{a=0} = 1 \mid A = 1] = \frac{7}{13} \approx 0.54 \;>\; \frac{3}{7} \approx 0.43 = \Pr[Y^{a=0} = 1 \mid A = 0].
$$
The treated are at higher baseline risk than the untreated,
so exchangeability (@def-exchangeability) does not hold.
It fails for $a = 1$ too:
$\Pr[Y^{a=1} = 1 \mid A = 1] = 7/13$,
whereas $\Pr[Y^{a=1} = 1 \mid A = 0] = 3/7$ (Rheia, Artemis, and Leto) [@hernan2020causal, p. 16].
:::
::: {.callout-warning title="Exchangeability Usually Cannot Be Checked"}
In practice we have only the observed data of Table 2.1, not the counterfactual outcomes of Table 1.1,
so we usually cannot tell whether exchangeability holds.
Even if we knew that it failed, that would not prove the study was not randomized:
1. Twenty people are too few;
sampling variability could explain almost anything (Chapter 10),
which is why we let each individual stand for 1 billion identical ones.
2. A study can be randomized and still lack exchangeability in an infinite population,
if the investigators used more than one coin (Section 2.2) [@hernan2020causal, p. 16].
:::
::: {.callout-note title="Population Effects Only"}
This chapter targets population (average) causal effects,
because effects in single individuals generally cannot be computed from the observed data
(they are not [identified](01-introduction.qmd), in the sense made precise in Section 2.3).
Crossover experiments, next, are a possible exception under strong conditions [@hernan2020causal, p. 16].
:::
### Crossover Experiments
::: {#def-crossover-experiment}
## Crossover experiment (Fine Point 2.1)
A **crossover experiment** follows each individual $i$ over two or more time points $t = 0, 1, \ldots$,
with a treatment $A_{it}$ assigned anew at each,
so that one person's outcome can be seen under more than one treatment value.
For two periods, write $Y_{i0}^{a_0}$ for $i$'s counterfactual outcome at $t = 0$ under treatment $a_0$ at $t = 0$,
and $Y_{i1}^{a_0, a_1}$ for the counterfactual outcome at $t = 1$ under $a_0$ at $t = 0$ and $a_1$ at $t = 1$ [@hernan2020causal, p. 16].
:::
::: {#exm-zeus-lightning}
## Zeus's lightning bolt
Zeus lets us decide when he throws his thunderbolt.
On day 1 he throws it at our request ($a = 1$), and his blood pressure goes up;
on day 2 we ask him to hold off ($a = 0$), and his blood pressure stays flat.
This is a crossover experiment (@def-crossover-experiment) with one individual and two periods.
It is tempting to say that we have seen both of Zeus's counterfactual outcomes,
$Y^{a=1} = 1$ and $Y^{a=0} = 0$,
and therefore an individual causal effect.
That conclusion holds only under the strong conditions stated next.
:::
---
::: {#prp-crossover-identification}
## When a crossover experiment reveals an individual effect (Fine Point 2.1)
Consider a two-period crossover experiment (@def-crossover-experiment) with dichotomous treatments $A_{it} \in \set{0, 1}$, deterministic counterfactual outcomes, and consistency.
Write $Y_{it}^{a_t}$ for individual $i$'s outcome at $t$ under treatment $a_t$ at $t$,
and suppose that
- (i) there is no carryover effect of treatment: $Y_{i1}^{a_0, a_1} = Y_{i1}^{a_1}$ for all $a_0, a_1$;
- (ii) the individual causal effect does not change over time: $Y_{it}^{a_t = 1} - Y_{it}^{a_t = 0} = \alpha_i$ for $t = 0, 1$;
- (iii) the outcome under no treatment does not change over time: $Y_{it}^{a_t = 0} = \beta_i$ for $t = 0, 1$.
If $A_{i0} = 0$ and $A_{i1} = 1$, then $Y_{i1} - Y_{i0} = \alpha_i$;
if $A_{i0} = 1$ and $A_{i1} = 0$, then $Y_{i0} - Y_{i1} = \alpha_i$.
So the observed change equals the individual causal effect $\alpha_i$ [@hernan2020causal, p. 16].
:::
::: {.proof}
Suppose $A_{i0} = 0$ and $A_{i1} = 1$.
By consistency, $Y_{i0} = Y_{i0}^{a_0 = 0}$ and $Y_{i1} = Y_{i1}^{a_0 = 0, a_1 = 1}$,
which equals $Y_{i1}^{a_1 = 1}$ by (i).
Adding and subtracting $Y_{i1}^{a_1 = 0}$, and then using (ii) and (iii),
$$
\begin{aligned}
Y_{i1} - Y_{i0} &= \paren{Y_{i1}^{a_1 = 1} - Y_{i1}^{a_1 = 0}} + \paren{Y_{i1}^{a_1 = 0} - Y_{i0}^{a_0 = 0}} \\
&= \alpha_i + (\beta_i - \beta_i) \\
&= \alpha_i .
\end{aligned}
$$
If instead $A_{i0} = 1$ and $A_{i1} = 0$, the same steps with the periods swapped give
$Y_{i0} - Y_{i1} = \paren{Y_{i0}^{a_0 = 1} - Y_{i0}^{a_0 = 0}} + \paren{Y_{i0}^{a_0 = 0} - Y_{i1}^{a_1 = 0}} = \alpha_i + (\beta_i - \beta_i) = \alpha_i$.
:::
::: {.callout-warning title="Crossover Designs Need Effects That Wear Off"}
Condition (i) of @prp-crossover-identification requires an outcome that appears abruptly and resolves completely before the next period.
So a crossover design cannot study the effect of an irreversible action, such as a heart transplant,
on an irreversible outcome, such as death [@hernan2020causal, p. 16].
:::
## 2.2 Conditional Randomization (pp. 17-19)
---
Table 2.2 adds a prognostic factor $L$ (1 if in critical condition, 0 otherwise), measured before treatment was assigned.
::: {.content-visible when-format="html"}
**Table 2.2**: Heart transplant study with prognostic factor $L$ [@hernan2020causal, p. 17]
| Name | $L$ | $A$ | $Y$ |
|------|-----|-----|-----|
| Rheia | 0 | 0 | 0 |
| Kronos | 0 | 0 | 1 |
| Demeter | 0 | 0 | 0 |
| Hades | 0 | 0 | 0 |
| Hestia | 0 | 1 | 0 |
| Poseidon | 0 | 1 | 0 |
| Hera | 0 | 1 | 0 |
| Zeus | 0 | 1 | 1 |
| Artemis | 1 | 0 | 1 |
| Apollo | 1 | 0 | 1 |
| Leto | 1 | 0 | 0 |
| Ares | 1 | 1 | 1 |
| Athena | 1 | 1 | 1 |
| Hephaestus | 1 | 1 | 1 |
| Aphrodite | 1 | 1 | 1 |
| Polyphemus | 1 | 1 | 1 |
| Persephone | 1 | 1 | 1 |
| Hermes | 1 | 1 | 0 |
| Hebe | 1 | 1 | 0 |
| Dionysus | 1 | 1 | 0 |
:::
::: {#def-marginal-conditional-randomization}
## Marginally and conditionally randomized experiments
Consider a randomized experiment (@def-randomized-experiment) with a dichotomous treatment $A$
and a variable $L$ measured before treatment is assigned.
The experiment is **marginally randomized** if it uses a single randomization probability $\Pr[A = 1]$, the same for everyone.
It is **conditionally randomized** if the randomization probability $\Pr[A = 1 \mid L = l]$ depends on the value $l$ of $L$,
for example with a different coin for each level of $L$ [@hernan2020causal, p. 17].
:::
::: {#exm-two-designs}
## Two designs for Table 2.2
Two mutually exclusive designs could each explain the treatment counts in Table 2.2:
- **Design 1** (marginally randomized): one loaded coin, with probability 0.65 of treatment, for all 20 individuals;
it would explain why 13 of the 20 were treated.
- **Design 2** (conditionally randomized): a coin with probability 0.75 of treatment for those in critical condition ($L = 1$)
and one with probability 0.5 for those in noncritical condition ($L = 0$);
it would explain why 9 of the 12 with $L = 1$ and 4 of the 8 with $L = 0$ were treated [@hernan2020causal, p. 17].
:::
### Which Design Produced Table 2.2?
As in Section 2.1, a marginally randomized experiment is expected to give exchangeability, $Y^a \ind A$.
A conditionally randomized one generally does not:
if the coin favors treatment in the sicker stratum,
the treated start out sicker on average than the untreated.
::: {#exm-which-design}
## Table 2.2 came from design 2
With each individual standing for 1 billion identical ones,
9 of the 13 treated ($\approx 69\%$) but only 3 of the 7 untreated ($\approx 43\%$) in Table 2.2 were in critical condition.
Since critical condition signals a bad prognosis,
the treated would have had a higher risk than the untreated had they remained untreated:
$A$ predicts $Y^{a=0}$, and exchangeability (@def-exchangeability) fails.
The study was randomized,
so it must have been randomized conditional on $L$:
design 2 of @exm-two-designs [@hernan2020causal, p. 17].
:::
### Conditional Exchangeability
A conditionally randomized experiment is one marginally randomized experiment per level of $L$:
here two, one among those with $L = 1$ and one among those with $L = 0$.
Within each stratum, the treated and the untreated should therefore be exchangeable.
::: {#def-conditional-exchangeability}
## Conditional exchangeability
Let $A$ be a treatment with finitely many values,
$Y$ an outcome with counterfactual outcomes $Y^a$,
and $L$ a variable measured before treatment.
The treated and the untreated are **exchangeable within level $l$ of $L$**, written $Y^a \ind A \mid L = l$,
if $Y^a$ and $A$ are independent given $L = l$.
For a dichotomous treatment and outcome, and when both treatment values occur in level $l$, this means
$$
\Pr[Y^a = 1 \mid A = 1, L = l] = \Pr[Y^a = 1 \mid A = 0, L = l].
$$ {#eq-conditional-exchangeability}
**Conditional exchangeability**, $Y^a \ind A \mid L$, holds if this is true for every treatment value $a$ and every level $l$ of $L$ [@hernan2020causal, p. 18].
:::
::: {#exm-conditional-exchangeability-design-2}
## Conditional exchangeability in design 2
In design 2 of @exm-two-designs, everyone in critical condition ($L = 1$) gets the same coin, with probability 0.75 of treatment,
so within $L = 1$ the experiment is marginally randomized,
and, as in Section 2.1, it is expected to give $Y^a \ind A \mid L = 1$.
Likewise the coin with probability 0.5 gives $Y^a \ind A \mid L = 0$.
So conditional exchangeability (@def-conditional-exchangeability) holds
(the next proposition makes this precise),
even though @exm-which-design indicated that exchangeability fails in the population as a whole.
:::
::: {#def-positivity-ch2}
## Positivity
Let $A$ be a treatment with finitely many values and $L$ a variable measured before treatment.
**Positivity** holds if every treatment value has a nonzero probability in every level of $L$ that occurs:
$$
\Pr[A = a \mid L = l] > 0 \quad \text{for every } a \text{ and every } l \text{ with } \Pr[L = l] > 0
$$ {#eq-positivity-ch2}
[@hernan2020causal, p. 25].
:::
::: {#exm-positivity-design-2}
## Positivity in design 2
In design 2 of @exm-two-designs, $\Pr[A = 1 \mid L = 1] = 0.75$, $\Pr[A = 0 \mid L = 1] = 0.25$,
and $\Pr[A = 1 \mid L = 0] = \Pr[A = 0 \mid L = 0] = 0.5$.
All four are positive, so positivity (@def-positivity-ch2) holds.
Had the investigators transplanted everyone in critical condition, $\Pr[A = 0 \mid L = 1]$ would be 0, and positivity would fail.
:::
---
::: {#prp-randomization-exchangeability}
## What each design guarantees
Let $A$ be a dichotomous treatment,
$Y$ an outcome with counterfactual outcomes $Y^{a=0}$ and $Y^{a=1}$ (dichotomous wherever @def-exchangeability is invoked),
and $L$ a variable measured before treatment.
Suppose treatment is assigned by a random device so that, in a near-infinite population,
$0 < \Pr[A = 1 \mid L = l] < 1$ for every level $l$ of $L$, and
$$
\Pr[A = 1 \mid L, Y^{a=0}, Y^{a=1}] = \Pr[A = 1 \mid L].
$$ {#eq-conditional-randomization}
1. Conditional exchangeability holds: $Y^a \ind A \mid L$ for $a = 0, 1$ (@def-conditional-exchangeability).
2. If, in addition, $\Pr[A = 1 \mid L]$ is the same for every level of $L$ (marginal randomization),
then exchangeability also holds: $Y^a \ind A$ for $a = 0, 1$ (@def-exchangeability) [@hernan2020causal, p. 18].
:::
::: {.proof}
For a dichotomous $A$, @eq-conditional-randomization says that $A$ is independent of the pair $(Y^{a=0}, Y^{a=1})$ given $L$,
so it is independent of each member of the pair given $L$: $Y^a \ind A \mid L$.
If moreover $\Pr[A = 1 \mid L, Y^{a=0}, Y^{a=1}]$ equals one constant $p$,
then $A$ is independent of $(L, Y^{a=0}, Y^{a=1})$ jointly, and in particular of $Y^a$.
:::
- Marginal randomization (design 1) produces both exchangeability and conditional exchangeability.
- Conditional randomization (design 2) produces conditional exchangeability, but not, in general, exchangeability (@exm-which-design).
### A Missing-Data View
::: {#def-mcar-mar}
## Missing completely at random and missing at random
Let $A$ be a dichotomous treatment, $Y$ an outcome with counterfactual outcomes $Y^{a=0}$ and $Y^{a=1}$, and $L$ a variable measured before treatment.
One counterfactual outcome is missing for everyone:
$Y^{a=0}$ if $A = 1$, and $Y^{a=1}$ if $A = 0$.
Take the full data to be $(L, Y^{a=0}, Y^{a=1})$, of which $(L, Y^a)$ is observed when $A = a$.
The counterfactual outcomes are
- **missing completely at random** (MCAR) if $\Pr[A = a \mid L, Y^{a=1}, Y^{a=0}] = \Pr[A = a]$ for $a = 0, 1$;
- **missing at random** (MAR) if, for $a = 0, 1$, $\Pr[A = a \mid L, Y^{a=1}, Y^{a=0}]$ depends only on $(L, Y^a)$, the data that would be observed if $A = a$;
- **missing not at random** (MNAR) if they are not MAR [@hernan2020causal, p. 18].
:::
::: {#exm-mcar-mar-designs}
## The two designs as missing-data mechanisms
In design 1 of @exm-two-designs, $\Pr[A = 1 \mid L, Y^{a=1}, Y^{a=0}] = 0.65$ whatever the full data,
so the counterfactual outcomes are MCAR (@def-mcar-mar).
In design 2, $\Pr[A = 1 \mid L, Y^{a=1}, Y^{a=0}]$ is 0.75 if $L = 1$ and 0.5 if $L = 0$,
so it depends on $L$ alone, and the counterfactual outcomes are MAR but not MCAR.
:::
::: {#prp-mar-conditional-randomization}
## MAR is conditional randomization
Let $A$ and $Y$ be dichotomous, and suppose that for every level $l$ of $L$,
each of the four combinations of $(Y^{a=0}, Y^{a=1})$ has positive probability given $L = l$.
Then the counterfactual outcomes are MAR (@def-mcar-mar) if and only if @eq-conditional-randomization holds,
that is, $\Pr[A = a \mid L, Y^{a=1}, Y^{a=0}] = \Pr[A = a \mid L]$ for $a = 0, 1$.
The book's margin note states the implication from MAR without the condition on $(Y^{a=0}, Y^{a=1})$, which is added here (the next example shows why) [after @hernan2020causal, p. 18].
:::
::: {.proof}
If @eq-conditional-randomization holds, $\Pr[A = a \mid L, Y^{a=1}, Y^{a=0}]$ depends on $L$ alone, so MAR holds.
Conversely, let $g(l, y_0, y_1) = \Pr[A = 1 \mid L = l, Y^{a=0} = y_0, Y^{a=1} = y_1]$.
Under MAR with $a = 1$, $g$ does not depend on $y_0$.
Under MAR with $a = 0$, $1 - g$, and hence $g$, does not depend on $y_1$.
With all four combinations of $(y_0, y_1)$ possible given $L = l$,
$g(l, y_0, y_1) = g(l, y_0', y_1) = g(l, y_0', y_1')$ for all of them,
so $g$ depends on $l$ alone and therefore equals $\Pr[A = 1 \mid L = l]$.
:::
::: {#exm-mar-without-support}
## MAR without conditional randomization
The condition on $(Y^{a=0}, Y^{a=1})$ in @prp-mar-conditional-randomization cannot simply be dropped.
Suppose the sharp causal null holds, so that $Y^{a=0} = Y^{a=1}$ for everyone,
and suppose the probability of treatment is 0.8 for those with $Y^{a=0} = Y^{a=1} = 1$ and 0.2 for the others,
whatever their $L$,
and that in some level $l$ of $L$ both $Y^a = 0$ and $Y^a = 1$ occur.
This probability is a function of $Y^{a=1}$ alone and also of $Y^{a=0}$ alone,
so the counterfactual outcomes are MAR (@def-mcar-mar),
yet $A$ depends on $Y^a$ given $L$, so conditional exchangeability fails.
Here only two of the four combinations of $(Y^{a=0}, Y^{a=1})$ occur.
:::
::: {.notes}
Rubin (1976) and Marini, Olsen, and Rubin (1980) coined the labels MCAR, MAR, and MNAR [@hernan2020causal, p. 18].
:::
### Two Targets
::: {#exm-design-1-analysis}
## If Table 2.2 had come from design 1
Had the data of Table 2.2 come from a marginally randomized experiment,
exchangeability would hold,
and, assuming consistency, by @prp-association-is-causation the causal risk ratio would be the associational one:
$$
\frac{\Pr[Y = 1 \mid A = 1]}{\Pr[Y = 1 \mid A = 0]} = \frac{7/13}{3/7} = \frac{49}{39} \approx 1.26 .
$$
Table 2.2 came from design 2 (@exm-which-design), so this calculation does not apply [@hernan2020causal, p. 18].
:::
Under conditional randomization there are two targets.
::: {#def-stratification-ch2}
## Stratification
Let $A$ be a dichotomous treatment, $Y$ a dichotomous outcome, and $L$ a variable measured before treatment.
**Stratification** computes causal effects separately within each level (stratum) $l$ of $L$ with $\Pr[L = l] > 0$,
for example the stratum-specific causal risk ratio
$$
\frac{\Pr[Y^{a=1} = 1 \mid L = l]}{\Pr[Y^{a=0} = 1 \mid L = l]},
$$
defined when $\Pr[Y^{a=0} = 1 \mid L = l] > 0$ [@hernan2020causal, p. 18].
:::
::: {#prp-stratum-association-causation}
## Within a stratum, association is causation
Let $A$ and $Y$ be dichotomous, $L$ a variable measured before treatment, and $l$ a level with $\Pr[L = l] > 0$.
Suppose that consistency holds,
that $Y^a \ind A \mid L = l$ for $a = 0, 1$ (@def-conditional-exchangeability),
and that both treatment values occur in level $l$ (positivity within level $l$, as in @def-positivity-ch2).
Then, for $a = 0, 1$,
$$
\Pr[Y^a = 1 \mid L = l] = \Pr[Y = 1 \mid L = l, A = a],
$$ {#eq-stratum-association-causation}
so the stratum-specific causal risk ratio equals the stratum-specific associational risk ratio
$\Pr[Y = 1 \mid L = l, A = 1] / \Pr[Y = 1 \mid L = l, A = 0]$
whenever the denominators are positive [@hernan2020causal, p. 18].
:::
::: {.proof}
Restrict attention to the stratum $L = l$, viewed as a population in its own right.
In it, treatment is dichotomous with both values occurring,
consistency holds,
and the treated and the untreated are exchangeable.
@prp-association-is-causation applied to that stratum gives @eq-stratum-association-causation.
:::
::: {#exm-stratification-table-2-2}
## Stratum-specific effects in Table 2.2
- $L = 0$: 1 of the 4 treated died (Zeus) and 1 of the 4 untreated died (Kronos),
so $\Pr[Y = 1 \mid L = 0, A = 1] = \Pr[Y = 1 \mid L = 0, A = 0] = 1/4$.
- $L = 1$: 6 of the 9 treated died and 2 of the 3 untreated died (Artemis and Apollo),
so $\Pr[Y = 1 \mid L = 1, A = 1] = 6/9 = 2/3$ and $\Pr[Y = 1 \mid L = 1, A = 0] = 2/3$.
Design 2 gives conditional exchangeability (@exm-conditional-exchangeability-design-2, @prp-randomization-exchangeability) and positivity (@exm-positivity-design-2).
Assuming consistency as well, @prp-stratum-association-causation turns these into stratum-specific causal risk ratios (@def-stratification-ch2):
$(1/4)/(1/4) = 1$ when $L = 0$
and $(2/3)/(2/3) = 1$ when $L = 1$.
:::
The two targets are then:
1. **The stratum-specific causal effects**, by stratification.
If they differ across levels of $L$, there is [effect modification](04-effect-modification.qmd#def-effect-modification) by $L$ (treatment effect heterogeneity), the topic of Chapter 4.
2. **The average causal effect in the whole population**, $\Pr[Y^{a=1} = 1] / \Pr[Y^{a=0} = 1]$,
for example when $L$ will not be available for future patients, so treatment decisions cannot depend on it.
Until Chapter 4, this is our target;
Sections 2.3 and 2.4 show two ways to compute it.
### Risk Periods
::: {#def-risk-period}
## Risk and risk period (Fine Point 2.2)
The **risk period** is the stretch of follow-up over which outcomes are counted,
and a **risk** is the fraction of individuals in whom the outcome occurs within it.
Read as a 5-day mortality risk, for instance, $\Pr[Y = 1 \mid A = 1]$ is the share of treated individuals dead by day 5.
Once a risk period has been named, the book usually leaves it implicit [@hernan2020causal, p. 19].
:::
::: {#exm-plague-antibiotics}
## One trial, two risk ratios
Two analysts study the same randomized trial of antibiotics in elderly plague patients.
One reports a causal risk ratio for death of 0.05;
the other reports 1.
They do not contradict each other:
the first used a 1-year risk period (@def-risk-period),
and the second a 100-year one, over which everyone dies whatever the treatment.
So a treatment that "affects mortality" postpones deaths rather than abolishing them [@hernan2020causal, p. 19].
:::
::: {.callout-tip title="Name the Risk Period"}
When you report a risk or a risk ratio, say over what period it was measured,
as @exm-plague-antibiotics shows the same data can give very different numbers.
:::
## 2.3 Standardization (pp. 19-20)
---
In our conditionally randomized study, hearts were assigned with probability 50% to the 8 individuals with $L = 0$ and 75% to the 12 with $L = 1$.
### Stratum-Specific Risks
From @exm-stratification-table-2-2:
| | $A = 1$ | $A = 0$ |
|---|---|---|
| $L = 0$ (8 individuals) | $\Pr[Y = 1 \mid L = 0, A = 1] = 1/4$ | $\Pr[Y = 1 \mid L = 0, A = 0] = 1/4$ |
| $L = 1$ (12 individuals) | $\Pr[Y = 1 \mid L = 1, A = 1] = 6/9 = 2/3$ | $\Pr[Y = 1 \mid L = 1, A = 0] = 2/3$ |
Under design 2 (conditional exchangeability by @prp-randomization-exchangeability, and positivity by @exm-positivity-design-2) and consistency,
@prp-stratum-association-causation says that each observed stratum risk equals the corresponding counterfactual risk,
e.g. $\Pr[Y = 1 \mid L = 0, A = 1] = \Pr[Y^{a=1} = 1 \mid L = 0]$.
The risk if all 20 had been treated should then be an average of $1/4$ (in $L = 0$) and $2/3$ (in $L = 1$),
weighted by the size of each stratum.
### Standardized Means
::: {#def-standardization}
## Standardization
Let $A$ be a treatment, $Y$ an outcome with finite mean, and $L$ a discrete variable,
with $\Pr[A = a \mid L = l] > 0$ for every $l$ with $\Pr[L = l] > 0$.
The **standardized mean** of $Y$ for treatment level $a$, with the whole population as the standard, is
$$
\sum_l \E{Y \mid L = l, A = a} \Pr[L = l],
$$ {#eq-standardized-mean}
the average of the stratum-specific means among those with $A = a$, weighted by the distribution of $L$ in the population.
For a dichotomous outcome it is the **standardized risk** $\sum_l \Pr[Y = 1 \mid L = l, A = a] \Pr[L = l]$.
Computing causal effects this way is called **standardization** [@hernan2020causal, p. 20].
:::
::: {#exm-standardization-table-2-2}
## Standardized risks in Table 2.2
The stratum weights are $\Pr[L = 0] = 8/20 = 0.4$ and $\Pr[L = 1] = 12/20 = 0.6$.
With the stratum risks of @exm-stratification-table-2-2, the standardized risks (@def-standardization) are
$$
\begin{aligned}
\textstyle\sum_l \Pr[Y = 1 \mid L = l, A = 1] \Pr[L = l] &= \tfrac{1}{4} \times 0.4 + \tfrac{2}{3} \times 0.6 = 0.1 + 0.4 = 0.5, \\
\textstyle\sum_l \Pr[Y = 1 \mid L = l, A = 0] \Pr[L = l] &= \tfrac{1}{4} \times 0.4 + \tfrac{2}{3} \times 0.6 = 0.1 + 0.4 = 0.5 ,
\end{aligned}
$$
and their ratio is $0.5/0.5 = 1$ [@hernan2020causal, p. 19].
:::
### Identification
::: {#def-identification}
## Identification
Fix a set of assumptions about how the data arose.
Under those assumptions, a counterfactual quantity, such as $\Pr[Y^a = 1]$, is **identified** (identifiable) if it can be written as a function of the distribution of the observed data, such as the joint distribution of $(L, A, Y)$;
otherwise it is **unidentified** [@hernan2020causal, p. 20].
:::
::: {#exm-identified-coin-flip}
## Identification in the coin-flip experiment
In @exm-diamond-experiment, assume consistency and exchangeability.
By @prp-association-is-causation, $\Pr[Y^{a=1} = 1] = \Pr[Y = 1 \mid A = 1]$,
a function of the joint distribution of the observed $(A, Y)$.
So under those assumptions $\Pr[Y^{a=1} = 1]$ is identified (@def-identification), and its value is 0.3.
:::
---
::: {#prp-standardization-identifies}
## Standardization identifies the counterfactual mean
Let $A$ and $L$ be discrete, with $L$ measured before treatment,
and let $Y$ be an outcome with finite counterfactual means $\E{Y^a}$.
Suppose that
- consistency holds ($Y = Y^A$);
- conditional exchangeability holds, $Y^a \ind A \mid L$ (@def-conditional-exchangeability);
- positivity holds, $\Pr[A = a \mid L = l] > 0$ for every $l$ with $\Pr[L = l] > 0$ (@def-positivity-ch2).
Then $\E{Y^a}$ is identified (@def-identification) and equals the standardized mean (@def-standardization):
$$
\E{Y^a} = \sum_l \E{Y \mid L = l, A = a} \Pr[L = l].
$$ {#eq-standardization-identifies}
For a dichotomous outcome, $\Pr[Y^a = 1]$ is the standardized risk,
so, when $\Pr[Y^{a=0} = 1] > 0$, the causal risk ratio is the ratio of the standardized risks:
$$
\frac{\Pr[Y^{a=1} = 1]}{\Pr[Y^{a=0} = 1]} = \frac{\sum_l \Pr[Y = 1 \mid L = l, A = 1] \Pr[L = l]}{\sum_l \Pr[Y = 1 \mid L = l, A = 0] \Pr[L = l]}
$$ {#eq-standardized-risk-ratio}
[@hernan2020causal, pp. 19-20, 25].
:::
::: {.proof}
The sums are over the values $l$ with $\Pr[L = l] > 0$.
$$
\begin{aligned}
\E{Y^a} &= \sum_l \E{Y^a \mid L = l} \Pr[L = l] && \text{(law of total expectation)} \\
&= \sum_l \E{Y^a \mid A = a, L = l} \Pr[L = l] && \text{(conditional exchangeability, positivity)} \\
&= \sum_l \E{Y \mid A = a, L = l} \Pr[L = l] && \text{(consistency)}.
\end{aligned}
$$
The right side involves only the observed $L$, $A$, and $Y$.
For a dichotomous outcome, each mean is a risk.
:::
::: {#exm-identified-table-2-2}
## The counterfactual risks in Table 2.2
In the conditionally randomized experiment of Table 2.2,
the conditions of @prp-standardization-identifies hold:
conditional exchangeability by design (@exm-conditional-exchangeability-design-2, @prp-randomization-exchangeability),
positivity by @exm-positivity-design-2,
and consistency by assumption.
So the standardized risks of @exm-standardization-table-2-2 are the counterfactual risks:
$\Pr[Y^{a=1} = 1] = \Pr[Y^{a=0} = 1] = 0.5$.
The causal risk ratio is $0.5/0.5 = 1$,
not the 1.26 of @exm-design-1-analysis [@hernan2020causal, p. 19].
:::
## 2.4 Inverse Probability Weighting (pp. 20-25)
---
The same causal risk ratio can be computed a second way, by reweighting the individuals.
### The Tree (Figure 2.1)
Display Table 2.2 as a tree, from left to right:
- first branching on $L$: 8 with $L = 0$ ($\Pr[L = 0] = 0.4$), 12 with $L = 1$ ($\Pr[L = 1] = 0.6$);
- then on $A$: in $L = 0$, 4 untreated and 4 treated ($\Pr[A = 0 \mid L = 0] = \Pr[A = 1 \mid L = 0] = 0.5$);
in $L = 1$, 3 untreated and 9 treated ($\Pr[A = 0 \mid L = 1] = 0.25$, $\Pr[A = 1 \mid L = 1] = 0.75$);
- then on $Y$: e.g. in $(L = 0, A = 0)$, 3 survived and 1 died, so $\Pr[Y = 1 \mid L = 0, A = 0] = 1/4$.
::: {.notes}
In the terminology of Robins (1986, 1987), Figure 2.1 represents a conditionally randomized experiment as an FRCISTG: a fully randomized causally interpreted structured tree graph.
The book asks whether this wins "the prize for the worst acronym ever" [@hernan2020causal, p. 20].
:::
### Simulating Everybody Untreated and Everybody Treated
::: {#exm-everybody-untreated}
## Everybody untreated (Figure 2.2)
- $L = 0$: 1 of the 4 untreated died.
Had all 8 been untreated (twice as many), 2 would have died.
- $L = 1$: 2 of the 3 untreated died.
Had all 12 been untreated ($12 = 3 \times 4$), $2 \times 4 = 8$ would have died.
So $\Pr[Y^{a=0} = 1] = (2 + 8)/(8 + 12) = 10/20 = 0.5$.
This relies on exchangeability within each stratum (@def-conditional-exchangeability):
the treated, had they been untreated, would have had the same risk as the untreated in their stratum [@hernan2020causal, pp. 21-22].
:::
::: {#exm-everybody-treated}
## Everybody treated (Figure 2.2)
- $L = 0$: 1 of the 4 treated died;
scaled up to all 8: 2 deaths.
- $L = 1$: 6 of the 9 treated died;
scaled up to all 12 (a factor $12/9 = 4/3$): $6 \times 4/3 = 8$ deaths.
So $\Pr[Y^{a=1} = 1] = (2 + 8)/20 = 0.5$,
and with @exm-everybody-untreated the causal risk ratio is $0.5/0.5 = 1$,
as with standardization (@exm-standardization-table-2-2) [@hernan2020causal, p. 22].
:::
### IP Weights and the Pseudo-Population
Both simulations scaled each group up by the inverse of the probability that its members received the treatment they did.
::: {#def-ip-weights}
## IP weights
Let $A$ and $L$ be discrete, and let $f[a \mid l] = \Pr[A = a \mid L = l]$ be the conditional probability of treatment value $a$ given $L = l$,
assumed positive for every value $a$ of $A$ and every $l$ with $\Pr[L = l] > 0$.
The **inverse probability (IP) weight** of an individual is
$$
W^A = \frac{1}{f[A \mid L]},
$$ {#eq-ip-weights}
the inverse of the probability of receiving the treatment value the individual actually received, given the individual's own $L$.
For a dichotomous $A$, a treated individual with $L = l$ gets $1/\Pr[A = 1 \mid L = l]$,
and an untreated one with $L = l'$ gets $1/\Pr[A = 0 \mid L = l']$ [@hernan2020causal, pp. 22-23].
:::
::: {#exm-ip-weights-table-2-2}
## IP weights in Table 2.2
From the tree of Figure 2.1, the IP weights (@def-ip-weights) and the size of each group after weighting are
- $L = 0$, $A = 0$: weight $1/0.5 = 2$, so the 4 individuals count as 8;
- $L = 0$, $A = 1$: weight $1/0.5 = 2$, so the 4 individuals count as 8;
- $L = 1$, $A = 0$: weight $1/0.25 = 4$, so the 3 individuals count as 12;
- $L = 1$, $A = 1$: weight $1/0.75 \approx 1.33$, so the 9 individuals count as 12.
:::
::: {#def-pseudo-population-ch2}
## Pseudo-population
The **pseudo-population** created by the IP weights $W^A$ (@def-ip-weights) is the hypothetical population in which each individual of the original population is counted $W^A$ times.
Its expectations are IP weighted averages:
for any function $g$, $\Expfc{ps}{g(L, A, Y)} = \E{W^A g(L, A, Y)} / \E{W^A}$.
The book uses this rule for the particular functions in Technical Point 2.2;
the general form is ours [adapted from @hernan2020causal, pp. 22-23].
:::
::: {#exm-pseudo-population-table-2-2}
## The pseudo-population of Table 2.2 (Figure 2.3)
Weighting as in @exm-ip-weights-table-2-2 gives a pseudo-population (@def-pseudo-population-ch2) of 40,
twice the original 20:
8 treated and 8 untreated with $L = 0$, and 12 treated and 12 untreated with $L = 1$.
It pools the two simulated trees of @exm-everybody-untreated and @exm-everybody-treated,
so every stratum of the original population appears once in full as treated and once in full as untreated.
Half of each stratum is treated, so $L$ and $A$ are independent in the pseudo-population [@hernan2020causal, p. 22].
:::
---
::: {#def-ip-weighted-mean}
## IP weighted mean
Under the conditions of @def-ip-weights, and for an outcome $Y$ with finite mean, the **IP weighted mean** of $Y$ for treatment level $a$ is
$$
\E{\frac{\indicp{A = a} Y}{f[A \mid L]}},
$$ {#eq-ip-weighted-mean}
where the indicator $\indicp{A = a}$ is 1 if $A = a$ and 0 otherwise [@hernan2020causal, p. 25].
:::
::: {#exm-ip-weighted-mean-table-2-2}
## IP weighted risks in Table 2.2
For a dichotomous outcome the IP weighted mean (@def-ip-weighted-mean) is a risk.
In Table 2.2, with the weights of @exm-ip-weights-table-2-2,
only the deaths among those with $A = a$ contribute to the average over the 20 individuals:
- $a = 0$: 1 death with weight 2 and 2 deaths with weight 4, so the IP weighted risk is $(1 \times 2 + 2 \times 4)/20 = 0.5$;
- $a = 1$: 1 death with weight 2 and 6 deaths with weight $4/3$, so the IP weighted risk is $(1 \times 2 + 6 \times 4/3)/20 = 0.5$.
These are the risks found in @exm-everybody-untreated and @exm-everybody-treated.
:::
::: {#prp-pseudo-population-ch2}
## Properties of the pseudo-population
Let $A$ take $k$ values, assume the conditions of @def-ip-weights, and let $Y$ have finite mean.
In the pseudo-population (@def-pseudo-population-ch2):
1. $L$ and $A$ are independent, $L$ has the same distribution as in the original population, and each treatment value has probability $1/k$;
2. the mean outcome among those with $A = a$ is the IP weighted mean (@def-ip-weighted-mean):
$$
\Expfc{ps}{Y \mid A = a} = \E{\frac{\indicp{A = a} Y}{f[A \mid L]}}
$$ {#eq-pseudo-population-mean}
Part 2 is Technical Point 2.2;
the book states only the independence in part 1, and the margins are added here [adapted from @hernan2020causal, pp. 22-23].
:::
::: {.proof}
For 1, the weighted size of the group with $A = a$ and $L = l$ is
$\E{W^A \indicp{A = a, L = l}} = \Pr[A = a, L = l] / \Pr[A = a \mid L = l] = \Pr[L = l]$.
Summing over the $k$ values of $a$ and the values of $l$ gives a total size $\E{W^A} = k$.
So $\Pr_{ps}[A = a, L = l] = \Pr[L = l] \times (1/k)$, a product of a function of $l$ and a function of $a$,
which gives independence with the stated margins.
For 2,
$$
\begin{aligned}
\Expfc{ps}{Y \mid A = a} &= \frac{\Expfc{ps}{Y \indicp{A = a}}}{\Expfc{ps}{\indicp{A = a}}} && \text{(laws of probability)} \\
&= \frac{\E{W^A Y \indicp{A = a}}}{\E{W^A \indicp{A = a}}} && \text{(definition of } \Expfc{ps}{\cdot}\text{)} \\
&= \frac{\E{Y \indicp{A = a} / f[a \mid L]}}{\E{\indicp{A = a} / f[a \mid L]}} && \text{(} f[A \mid L] = f[a \mid L] \text{ when } A = a\text{)} \\
&= \E{\frac{Y \indicp{A = a}}{f[a \mid L]}} && \text{(denominator is 1)},
\end{aligned}
$$
because $\E{\indicp{A = a} / f[a \mid L] \mid L} = f[a \mid L] / f[a \mid L] = 1$.
The last expression equals @eq-ip-weighted-mean, again because $f[A \mid L] = f[a \mid L]$ whenever $\indicp{A = a} \neq 0$.
:::
::: {#rem-ip-weight-notation}
## Why IP weights use random arguments (Technical Point 2.2)
Each person's weight plugs that person's own treatment and covariate values into $f[a \mid l]$.
Substituting the random variables themselves for $a$ and $l$ gives $f[A \mid L]$,
a single formula that covers everyone.
The tempting alternative $\Pr[A = A \mid L = L]$ is useless, since it equals 1 for everyone.
For a continuous $A$, $f$ would be a conditional probability density function [@hernan2020causal, p. 23].
:::
::: {.callout-tip title="Read an IP Weight as a Head Count"}
An individual with weight $W^A = 4$ counts as 4 members of the pseudo-population:
the individual,
plus 3 stand-ins for members of the same stratum of $L$ who actually received the other treatment.
Conditional exchangeability is what lets the stand-ins borrow this individual's risk under the treatment the individual received.
:::
::: {.notes}
IP weighted estimators date back to Horvitz and Thompson (1952), who designed them for surveys that sample units with unequal probabilities (Technical Point 12.1) [@hernan2020causal, p. 22].
:::
### Standardization and IP Weighting Are Equivalent
::: {#prp-ipw-equals-standardization}
## IP weighting equals standardization (Technical Point 2.3)
Let $A$ be discrete with finitely many values and $L$ discrete,
let $Y$ have finite mean,
and assume positivity (@def-positivity-ch2): $f[a \mid l] > 0$ for every $l$ with $\Pr[L = l] > 0$,
which holds in a conditionally randomized experiment whose randomization probabilities are all strictly between 0 and 1.
Then the IP weighted mean (@def-ip-weighted-mean) equals the standardized mean (@def-standardization):
$$
\E{\frac{\indicp{A = a} Y}{f[A \mid L]}} = \sum_l \E{Y \mid A = a, L = l} \Pr[L = l].
$$ {#eq-ipw-equals-standardization}
No counterfactuals are involved [@hernan2020causal, p. 25].
:::
::: {.proof}
Only individuals with $A = a$ contribute to the left side, and for them $f[A \mid L] = f[a \mid L]$.
Conditioning on $L$,
$$
\begin{aligned}
\E{\frac{\indicp{A = a} Y}{f[A \mid L]}}
&= \sum_l \frac{1}{f[a \mid l]} \E{Y \mid A = a, L = l} f[a \mid l] \Pr[L = l] \\
&= \sum_l \E{Y \mid A = a, L = l} \Pr[L = l],
\end{aligned}
$$
after $f[a \mid l]$ cancels.
For a continuous $L$, replace the sum by an integral.
:::
::: {#prp-ipw-identifies}
## IP weighting identifies the counterfactual mean (Technical Point 2.3)
Under the conditions of @prp-ipw-equals-standardization,
suppose also that $\E{Y^a}$ is finite, and that consistency ($Y = Y^A$) and conditional exchangeability ($Y^a \ind A \mid L$, @def-conditional-exchangeability) hold.
Then the IP weighted mean equals the counterfactual mean:
$$
\E{\frac{\indicp{A = a} Y}{f[A \mid L]}} = \E{Y^a}.
$$ {#eq-ipw-identifies}
So, by @prp-pseudo-population-ch2, for a dichotomous treatment and outcome with $\Pr[Y^{a=0} = 1] > 0$,
comparing the risks of treated and untreated members of the pseudo-population gives the causal risk ratio of the original population [@hernan2020causal, pp. 22, 25].
:::
::: {.proof}
This follows from @prp-ipw-equals-standardization and @prp-standardization-identifies.
A direct proof:
$$
\begin{aligned}
\E{\frac{\indicp{A = a}}{f[A \mid L]} Y}
&= \E{\frac{\indicp{A = a}}{f[a \mid L]} Y^a} && \text{(consistency)} \\
&= \E{\E{\frac{\indicp{A = a}}{f[a \mid L]} Y^a \;\middle|\; L}} && \text{(law of total expectation)} \\
&= \E{\E{\frac{\indicp{A = a}}{f[a \mid L]} \;\middle|\; L} \E{Y^a \mid L}} && \text{(conditional exchangeability)} \\
&= \E{\E{Y^a \mid L}} && \text{(the inner mean is 1)} \\
&= \E{Y^a} .
\end{aligned}
$$
Positivity makes $f[a \mid L]$ nonzero, so every ratio is defined.
:::
::: {#exm-two-methods-table-2-2}
## Two methods, one answer in Table 2.2
Standardization (@exm-standardization-table-2-2) and IP weighting (@exm-ip-weighted-mean-table-2-2) both give $\Pr[Y^{a=1} = 1] = \Pr[Y^{a=0} = 1] = 0.5$ in Table 2.2,
and so a causal risk ratio of 1.
By @prp-ipw-equals-standardization this is no coincidence [@hernan2020causal, p. 23].
:::
::: {#rem-two-ingredients}
## Two recipes for the same counterfactual tree
Both methods build a counterfactual tree in which everyone receives $a$, from different pieces:
- **IP weighting** uses the treatment probabilities $\Pr[A = a \mid L = l]$;
- **standardization** uses $\Pr[L = l]$ and the outcome risks $\Pr[Y = 1 \mid A = a, L = l]$ [@hernan2020causal, p. 23].
:::
::: {.callout-warning title="Analytic Control Is Not Physical Control"}
Both methods mimic a world in which $L$ played no part in how treatment was assigned,
so we say that they **adjust for** $L$.
Saying that they "control for" $L$ is a slight abuse of language:
adjusting for $L$ in the analysis is very different from the control that a randomized experiment exerts by design [@hernan2020causal, p. 23].
:::
::: {.callout-warning title="Continuous Treatments Break the Equivalence"}
With a continuous treatment, the IP weighted mean no longer equals the standardized mean,
and it is biased for $\E{Y^a}$ even under exchangeability.
If $f$ is a density, $\E{\indicp{A = a} / f(a \mid l) \mid L = l}$ is 0, not 1;
if $f$ is a probability, $f(a \mid L = l) = 0$ with probability 1, so positivity fails.
Section 12.4 generalizes IP weighting to continuous treatments,
and Technical Point 3.1 shows that the results above fail without positivity even for a discrete $A$ [@hernan2020causal, p. 25].
:::
### Why Not Finish the Book Here?
::: {#rem-limits-of-experiments}
## Why not always run a randomized experiment?
An ideal randomized experiment plus standardization or IP weighting gives average causal effects.
But such experiments are frequently unethical, infeasible, or too slow.
For the heart transplant study:
- **ethics**: donor hearts are in short supply, and allocating them by coin flip rather than by expected benefit would be hard to defend;
- **feasibility**: nobody can be blinded to a transplant, patients randomized to medical therapy may seek one anyway, and a matching heart may not turn up for those randomized to receive one;
- **timeliness**: results would arrive only after years, while patients need decisions now.
Often the least bad choice left is an observational study (Chapter 3) [@hernan2020causal, pp. 23-24].
:::
## Summary
---
1. **Randomization** makes missing counterfactuals missing by chance and is expected to produce exchangeability, $Y^a \ind A$ (@def-exchangeability);
in an ideal randomized experiment, association is causation (@prp-association-is-causation).
2. $Y^a \ind A$ (exchangeability) is different from $Y \ind A$ (no association), as @prp-exchangeability-association shows.
3. **Conditional randomization** (randomization probabilities depending on $L$) in general produces only conditional exchangeability, $Y^a \ind A \mid L$ (@def-conditional-exchangeability, @prp-randomization-exchangeability).
4. Under consistency, conditional exchangeability, and positivity, the population causal effect is identified by **standardization**, $\sum_l \E{Y \mid L = l, A = a} \Pr[L = l]$ (@prp-standardization-identifies),
or equivalently by **IP weighting** with $W^A = 1/f[A \mid L]$ (@prp-ipw-identifies),
which creates a pseudo-population in which $L$ and $A$ are independent (@prp-pseudo-population-ch2).
5. In Table 2.2 both methods give a causal risk ratio of 1 (@exm-two-methods-table-2-2), whereas the crude associational risk ratio is 1.26.
## References
---
::: {#refs}
:::