From a Nested Counterfactual to an Observed-Data Formula
A natural effect involves a nested counterfactual: the outcome under one treatment level, evaluated at the mediator value that would arise under another treatment level. The target considered here is \(E[Y(a,M(a'))]\). Its two treatment levels have different jobs: \(a\) sets the treatment in the outcome, while \(a'\) sets the treatment that generates the mediator value. The goal is to express this mean using an outcome regression and a mediator distribution, conditional on baseline covariates.
This separation is useful because the two ingredients are observable-data quantities under different treatment levels. The outcome regression describes the mean outcome at treatment \(a\) and mediator value \(m\); the mediator distribution describes how often each \(m\) would occur under treatment \(a'\). Averaging the former over the latter, and then over the baseline covariate distribution, yields the mediation formula.
The conditional expectation \(E[Y \mid A=a,M=m,C=c]\) is the outcome regression. The conditional probability \(P(M=m \mid A=a',C=c)\) is the mediator distribution. The final factor, \(P(C=c)\), weights each covariate stratum according to its frequency in the target population. Thus, the formula does not generally describe a single “average person”; it averages across the baseline covariate distribution.
Assumptions for the Identification Step
The nested counterfactual is not directly observed: for one person, the mediator under \(a'\) and outcome under \(a\) are not both observed when those treatment levels differ. The formula is therefore an identification result, not just an algebraic rewriting. The following conditions are a sufficient set for the derivation below. They concern the relevant treatment levels and mediator values.
- Consistency. If a person receives treatment \(a\), then their observed mediator equals \(M(a)\). If that person receives treatment \(a\) and mediator value \(m\), their observed outcome equals \(Y(a,m)\). The treatment and mediator interventions must be well-defined, and there must be no interference between individuals.
- Treatment exchangeability given baseline covariates. Conditional on \(C\), treatment assignment is independent of the relevant potential mediators and outcomes. In particular, \(M(a')\) and \(Y(a,m)\) are independent of \(A\) given \(C\).
- Mediator-outcome exchangeability. Within \(A=a,C=c\), the potential outcome \(Y(a,m)\) is independent of the observed mediator \(M\). This rules out unmeasured mediator-outcome confounding after conditioning on treatment and baseline covariates.
- Cross-world independence. For the relevant \(a,a',m\), \(Y(a,m)\) is independent of \(M(a')\) conditional on \(C\). This links an outcome under one intervention to a mediator value under another.
- Positivity. Each relevant covariate stratum has positive probability of receiving \(a\) and \(a'\). Also, any mediator value with positive probability under \(A=a',C=c\) must have positive probability under \(A=a,C=c\), so the outcome regression is defined where the mediator distribution places weight.
These assumptions are substantive. In particular, conditioning on measured baseline covariates does not by itself guarantee exchangeability, and cross-world independence is not verified merely by fitting a regression model. The formula identifies the target only when the assumptions are credible for the scientific setting.
Deriving the Mediation Formula
For clarity, first suppose that \(C\) and \(M\) are discrete. Define \(\mu(a,m,c)=E[Y \mid A=a,M=m,C=c]\). Within a covariate stratum, partition the nested counterfactual according to the value of \(M(a')\). The cross-world assumption allows the mean of \(Y(a,m)\) in each such subset to be replaced by its mean given \(C=c\):
The second line uses \(Y(a,m) \perp M(a') \mid C\). Next, treatment exchangeability and consistency identify the mediator distribution:
The first equality follows from treatment exchangeability, and the second from consistency among those who receive \(a'\). The outcome mean can also be expressed in observed-data terms. Treatment exchangeability first gives \(E[Y(a,m)\mid C=c]=E[Y(a,m)\mid A=a,C=c]\). Mediator-outcome exchangeability then allows conditioning on the observed mediator value \(m\); consistency completes the link to the observed outcome:
The positivity conditions ensure that these conditional quantities are defined in the strata and at the mediator values being used. Substituting both observed-data expressions into the conditional mean, then averaging over \(C\), gives the formula:
For continuous \(C\) and \(M\), the same averaging argument uses conditional densities and integration rather than summation. In that case, the mediator distribution under \(a'\) weights the conditional outcome regression over the mediator values, and the baseline covariate density supplies the outer weights.
Worked Examples
Worked Example: Averaging Over a Binary Mediator
Suppose a hypothetical population has no varying baseline covariates. The mediator \(M\) is binary. Under treatment \(a'=0\), \(P(M=1\mid A=0)=0.30\) and \(P(M=0\mid A=0)=0.70\). The hypothetical outcome regression under \(a=1\) has means \(E[Y\mid A=1,M=1]=18\) and \(E[Y\mid A=1,M=0]=10\), measured in outcome units. Calculate \(E[Y(1,M(0))]\) using the mediation formula.
Because there is only one covariate stratum, the baseline weight is 1. The mediator distribution comes from treatment \(0\), while the outcome regression comes from treatment \(1\):
The identified mean is 12.4 outcome units under the nested intervention represented by \(Y(1,M(0))\). This is not the outcome mean for treatment \(1\) with its own mediator distribution; the weights specifically describe the mediator distribution under treatment \(0\).
Worked Example: Standardizing Across Baseline Covariates
Consider a hypothetical population with a binary baseline covariate \(C\), where \(P(C=0)=0.60\) and \(P(C=1)=0.40\). The mediator is binary. Under \(a'=0\), the probability of \(M=1\) is 0.20 when \(C=0\), and 0.70 when \(C=1\). The outcome regression under \(a=1\) is given below, in outcome units.
| Baseline stratum | \(P(M=1\mid A=0,C)\) | \(E[Y\mid A=1,M=0,C]\) | \(E[Y\mid A=1,M=1,C]\) |
|---|---|---|---|
| \(C=0\) | 0.20 | 8 | 14 |
| \(C=1\) | 0.70 | 12 | 20 |
First calculate the mediator-weighted outcome mean within each stratum. For \(C=0\), the probability of \(M=0\) under \(a'=0\) is \(1-0.20=0.80\), so the stratum mean is
For \(C=1\), the probability of \(M=0\) is \(1-0.70=0.30\), giving
Now average these two means using the population proportions of the baseline strata:
The result is 12.56 outcome units. The calculation preserves the association between \(C\) and the mediator distribution by first using the mediator probabilities within each covariate stratum. It then averages over the stated target population, rather than giving the two strata equal weight.
Worked Example: Keeping the Two Treatment Roles Straight
Suppose a hypothetical population again has no varying baseline covariates and a binary mediator. Under \(a'=1\), \(P(M=1\mid A=1)=0.60\). Under \(a=0\), the outcome regression is 6 outcome units for \(M=0\) and 11 outcome units for \(M=1\). Calculate \(E[Y(0,M(1))]\).
The outcome regression must be evaluated at treatment \(0\), but the mediator weights must come from treatment \(1\). The complementary probability is \(P(M=0\mid A=1)=1-0.60=0.40\). Therefore,
The nested counterfactual mean is 9.0 outcome units. Replacing the mediator weights with those under treatment \(0\) would instead calculate \(E[Y(0,M(0))]\), a different target. This example makes the two roles explicit: the first treatment level selects the outcome regression and the second selects the mediator distribution.
Interpretation and a Common Pitfall
The mediation formula is a weighted average, but its weights have a causal interpretation only under the stated assumptions. For each covariate stratum, it combines outcome means at treatment \(a\) with the mediator distribution that would occur under \(a'\). The outer average then targets the population distribution of \(C\). Changing \(a\), \(a'\), or the population distribution of \(C\) can change the result.
A frequent error is to use \(P(M=m\mid A=a,C=c)\) when calculating \(E[Y(a,M(a'))]\), simply because the outcome regression is also evaluated at \(A=a\). That substitution uses the mediator distribution under \(a\), and therefore targets \(E[Y(a,M(a))]\) instead. The correction is to label the two components before calculating: use \(A=a\) for the outcome regression, \(A=a'\) for the mediator distribution, and \(P(C=c)\) for the target-population weights.
A second mistake is to average the outcome regression over the overall mediator distribution without conditioning on \(C\). If baseline covariates predict both mediator and outcome, the relevant weights are stratum-specific. The formula conditions on \(C\) in both components and only then averages over \(P(C)\). This order of operations is part of the standardization, not an optional adjustment.
Check Your Understanding
Use the formula and assumptions above to answer the following questions.
- In \(E[Y(a,M(a'))]\), which treatment level determines the outcome regression, and which determines the mediator distribution?
- Why is cross-world independence relevant to separating the nested counterfactual into an outcome mean and a mediator probability?
- If a mediator value occurs under \(a'\) in a covariate stratum but never occurs under \(a\) in that stratum, which identification condition is violated?
- In the second worked example, why are the stratum-specific means weighted by 0.60 and 0.40 rather than equally?
- What nested counterfactual mean is calculated if the mediator distribution under \(a\) replaces the distribution under \(a'\)?