Causal inference is framed here as two levels of generalization — sample to population, and
control to treatment — computed by simulation rather than by formula. The worked example makes the
distinction vivid: with a treatment effect that varies in x and a sample whose x-distribution
differs from the population’s, the SATE is −0.96±0.10 and the PATE is −0.60±0.11 from
the very same fit. The cautionary half of the example: adding a quadratic interaction that the data
cannot pin down leaves the estimates unchanged but inflates their uncertainty, because β6
is strongly correlated with both SATE and PATE.
Overview
Two levels of generalization (Ch. 7.2, p. 125)
“In the simplest randomized experiments, an average causal effect can be estimated by the mean
difference between treatment and control groups. But in general, calculating a causal effect involves
two levels of generalization: from sample to population and from control to treatment group.
That latter step involves specifying one or more hypothetical interventions that are reflected in
treatment variables. This is different than just computing predictions, because the causal structure of
the generative model may be needed as well.”
The general simulation procedure
Computing an average causal effect by simulation (Ch. 7.2, p. 126)
With treatment z∈{0,1}, pre-treatment predictors x (N×K), outcome y, and a target
population characterized by x~ (n~×K, which must also be specified):
Draw θs, s=1,…,S from the joint posterior of all model parameters.
Fix or simulate pre-treatment predictors x~ for the new data.
For each draw θs:
(a) Compute E(y∣x~,z~=0,θs) and E(y∣x~,z~=1,θs).
(b) The treatment effects for the n~ new units are the difference between those
vectors. For an average effect, average over the n~ units or poststratify over some
assumed distribution of x~.
The set of these S values is the posterior distribution of the treatment effects.
When the causal model has more structure
“If the causal model contains more structure, like post-treatment variables, then the simulation
will also contain more structure. One must simulate all of the downstream (post-treatment) variables
as well. And sometimes treatments are applied to more than one variable, or hold some variables
constant. The details of the correct simulations differ, but they all follow the logic of a clearly
specified model of potential outcomes, whatever its structure.”
Two failure modes flagged:
Effects unfolding over time. Kaminsky et al. (2019) “give examples of simulations used in
epidemiology that do not correctly account for causal structure and as a result can yield incorrect
uncertainty intervals that include negative effects, even when the actual treatment effect is always
positive.”
Spillover. “Similar issues can arise whenever there are spillover effects from the treatment
group to the ‘controls.’ Simple analyses assume this does not happen, but a more complete workflow
involves modeling spillovers, multilevel structure, and other structure that goes beyond the default
stable unit treatment value assumption.”
Main Content
Worked example: SATE vs. PATE by regression and poststratification
The setup (Ch. 7.2, pp. 126-127, Figure 7.7)
The model.yi∼normal(b1+b2xi+b3zi+b4xizi,σ).
The analytic effects (available here, but “in general, it is not always possible to estimate average
treatment effects using a simple formula, but we can always do it using simulation”):
Simulating the data — N=200, with x uniform on (0,10):
N <- 200x <- runif(N, 0, 10)
Unbalanced assignment — “to make things interesting, we set up an imbalance in which people with
higher values of x are more likely to get the treatment”:
“We have set up the example so that the interaction and imbalance are large.”
The population, deliberately different from the sample:
N_pop <- 5000x_pop <- rnorm(N_pop, 6, 2) # purposely choosing a population different from the datan_pop <- rep(1, N_pop)
“By setting npop=1 for all cells, we are assuming they are of equal size in the
population or, equivalently, that each of the Npop rows of the poststratification table
corresponds to one person.”
“This is a simple linear regression with flat priors on the parameters. The main focus here is the
generated quantities block, in which
the expected outcome under treatment or control is computed for each data point,
these are averaged to get the SATE,
the same is done for each poststratification cell,
and these are averaged, weighting by cell population, to get the PATE.”
Note that defining Ey() as a functions-block function is what lets the same expression be
evaluated at z=0, z=1, on the sample, and on the population without duplication — a small but
important coding pattern for causal quantities.
“The values of xin the sample are uniformly distributed between 0 and 10, the treatment effect
varies widely in this range — the interaction between x and z is large — and the average
difference between the regression lines is about −1.
In contrast, the values of xin the population are normally distributed with mean 6 and standard
deviation 2; here, the average treatment effect happens to be closer to zero.”
The mechanism is arithmetic: SATE=b3+b4xˉ with xˉ=5, versus
PATE=b3+b4⋅6. The difference exists only because the effect is heterogeneous;
with b4=0 the two would coincide.
The cost of an unnecessary term
Adding a quadratic interaction (Figure 7.8, Ch. 7.2, pp. 128-129)
“Given how the data have been constructed, these extra terms are unnecessary — but in general we
will not know the true data-generating process, so often we include extra terms in a model, just to see
what happens.”
“The estimated effects are not so different from before, but the posterior standard deviations are
much bigger. What happened is that the quadratic interaction term has a big influence on the
average treatment effects, and it is difficult to estimate precisely from the data.” Figure 7.8 shows
the posterior correlation of β6 with both SATE and PATE across the 4000 draws — near-linear,
steep, and in the same direction for both.
The recommendation: “In a real-life setting it might make sense, if such a quadratic term were
included in the model, to accompany it with a strong prior so that posterior uncertainties would not be
unduly increased due to the possibility of extreme values of these new coefficients. It is a good idea
to add additional terms to a model, but often some regularization is needed to supply stability of
inferences.”
This is the piranha principle arriving in
a causal setting: model expansion without regularization buys flexibility at the cost of identifiability.
The nonlinear case
The same machinery with logistic regression (Ch. 7.2, pp. 129-130)
Note that the coefficients are wildly uncertain (b3=−20.4±7.1) while the SATE and PATE
are precisely estimated (±0.02 and ±0.03). This is exactly the point of
Average predictive comparisons — the predictive comparison, not the coefficient,
is the interpretable quantity in a nonlinear model.
“Again, the big difference between the estimated sample and population average effects comes from the
combination of a treatment interaction and systematic differences between sample and population, that
is, differences between the distributions of x and xpop.”
Direct and indirect effects
Computing a direct effect through a mediator (Ch. 7.2, p. 130)
Suppose treatment z influences yboth directly and through a mediator u, and the goal is the
direct causal effect. “Since u itself can be influenced by z, it must be simulated conditional
on z.”
Draw θs, s=1,…,S from p(θ∣u,x,z,y).
Fix or simulate x~.
For each θs, simulate under control:u~s∣x~,z~=0,θs,
then y~s∣u~s,x~,z~=0,θs.
Set the treatment to z′.
Simulate under treatment but holding the mediator at its control value:(y~′)s∣u~s,x~,z~=1,θs.
The direct effect is (y~′)s−y~s. Average over the n~ units within
each s, then work with the S averages.
Step 5 is the whole trick: the mediator is carried over from the control simulation, so the
difference isolates the path that does not run through u.
More complex generative models require more choices
“For example, in a time series the intervention may happen once to some fraction of the population or
otherwise happen repeatedly to different fractions of the population. This complicates the simulations,
but the logic of running a separate simulation for each sample s from the posterior remains the
same.”
Examples
Exercise 7.1 — the superpopulation as a middle ground
“If the distribution of the predictors in the population is unknown, we can estimate the SATE. An
intermediate approach is to estimate the average effect in a hypothetical superpopulation from which
the observed data are considered to be a random sample. The point estimate should be the same as for
the SATE, but it should have higher uncertainty to account for the modeled sampling variation. One
way to approximate this superpopulation is by bootstrapping the values of the predictors in the
sample.”
Exercise 7.2 — simulating selection bias, type S and type M errors
A model of selection bias in science: (i) effects θj sampled from a population with mean μ
and sd σ; (ii) each estimated by an experiment giving unbiased θ^j with standard
error 1; (iii) each summarized by a z-score and p-value.
(a) Display the distributions of z-scores and p-values for several interesting (μ,σ).
(b) Now suppose only “statistically significant” results are published. Compute the type S
error (probability the estimate has a different sign than the true effect) and type M error
(average exaggeration factor) for published results, as a function of μ and σ.
The generated quantities pattern here generalizes the LD50 post-processing in
Bioassay - A First Probabilistic Program — causal quantities are derived quantities.