From a Stochastic Mediator Intervention to an Observed-Data Formula
Interventional mediation effects compare outcomes under specified treatment levels while assigning the mediator a distribution associated with a chosen treatment level. To calculate such an effect from observed data, two ingredients must be combined: the expected outcome at a given treatment, mediator, and covariate value, and the distribution from which the mediator is drawn. The resulting average is the mediational g-formula.
Let \(A\) denote treatment, \(M\) a mediator measured after treatment, \(Y\) the outcome, and \(C\) a set of baseline covariates. For simplicity, take \(A\in\{0,1\}\). Write \(Y(a,m)\) for the outcome that would occur if treatment were set to \(a\) and the mediator to \(m\), and \(M(a)\) for the mediator value that would occur under treatment \(a\).
We use the following contrasts: the interventional direct effect at the reference mediator distribution is \(\psi(1,0)-\psi(0,0)\); the interventional indirect effect under treatment level 1 is \(\psi(1,1)-\psi(1,0)\). Their sum is the total contrast \(\psi(1,1)-\psi(0,0)\). These are additive contrasts on the mean outcome scale.
Identification Conditions and the Observed-Data Ingredients
The formula below is an identification result: it expresses a causal estimand in terms of the observed-data distribution under stated assumptions. It is not, by itself, a prescription for fitting models or calculating uncertainty. Assume that \(C\) is measured before treatment and is sufficient to control the relevant confounding of treatment with the mediator and outcome, and of the mediator with the outcome.
The exchangeability conditions rule out unmeasured confounding for the relations needed in this calculation. In particular, the stated setup does not accommodate an unmeasured mediator-outcome confounder or an exposure-induced mediator-outcome confounder left outside the covariate history. Positivity is needed because the formula combines an outcome regression at \(A=a\) with mediator values drawn from the distribution under \(A=a^*\). That combination must be supported by observed data.
Define the observed conditional outcome mean as \(\mu(a,m,c)=E(Y\mid A=a,M=m,C=c)\). Define \(F(m\mid a^*,c)\) as the conditional distribution of \(M\) given \(A=a^*,C=c\), and \(F_C\) as the target population distribution of \(C\). In the discrete case, write \(p(m\mid a^*,c)\) for the corresponding conditional probability.
Deriving the Mediational G-Formula
The derivation first conditions on \(C\), then averages over the mediator draw. By the definition of the stochastic intervention, conditional on \(C=c\), the draw has distribution \(F_{M(a^*)\mid C=c}\). Treatment exchangeability and consistency identify that distribution with the observed mediator distribution \(F(m\mid a^*,c)\). For the outcome, treatment exchangeability, mediator exchangeability, and consistency identify the mean under fixed \(a,m,c\) with \(\mu(a,m,c)\). Thus the conditional intervention mean is the outcome regression averaged over the chosen mediator distribution:
Finally, average this conditional mean over the covariate distribution of the target population. This gives the observed-data g-formula:
For discrete \(C\) and \(M\), the same expression is a pair of sums:
The inner average uses the outcome regression from treatment arm \(a\) and the mediator distribution from arm \(a^*\), both conditional on the same covariate value. The outer average uses the covariate distribution in the target population. The formula therefore does not generally reduce to evaluating the outcome regression at an average mediator value. Nor can the conditional mediator distribution generally be replaced by a marginal distribution that ignores \(C\).
Worked Example: Binary Mediator and Covariate
Suppose a hypothetical study has a binary baseline covariate \(C\), with \(P(C=0)=0.6\) and \(P(C=1)=0.4\). The mediator \(M\) is binary. Its conditional probabilities of being 1 are \(P(M=1\mid A=0,C=0)=0.2\), \(P(M=1\mid A=0,C=1)=0.5\), \(P(M=1\mid A=1,C=0)=0.6\), and \(P(M=1\mid A=1,C=1)=0.8\). The following conditional outcome means are hypothetical symptom scores, in points:
| Treatment \(a\) | Covariate \(c\) | \(\mu(a,0,c)\) | \(\mu(a,1,c)\) |
|---|---|---|---|
| 0 | 0 | 10 | 14 |
| 0 | 1 | 12 | 18 |
| 1 | 0 | 12 | 20 |
| 1 | 1 | 15 | 23 |
For a binary mediator, the inner average is \(\mu(a,0,c)+P(M=1\mid A=a^*,C=c)\{\mu(a,1,c)-\mu(a,0,c)\}\). For \(\psi(0,0)\), the conditional means are \(10+0.2(14-10)=10.8\) points at \(C=0\), and \(12+0.5(18-12)=15\) points at \(C=1\). Therefore, \[ \psi(0,0)=0.6(10.8)+0.4(15)=6.48+6=12.48 \] points.
For \(\psi(1,0)\), use the treatment-1 outcome means but the treatment-0 mediator probabilities. The covariate-specific means are \(12+0.2(20-12)=13.6\) and \(15+0.5(23-15)=19\). Hence, \[ \psi(1,0)=0.6(13.6)+0.4(19)=8.16+7.6=15.76 \] points. For \(\psi(1,1)\), use the treatment-1 mediator probabilities: the means are \(12+0.6(8)=16.8\) and \(15+0.8(8)=21.4\), so \[ \psi(1,1)=0.6(16.8)+0.4(21.4)=10.08+8.56=18.64 \] points.
The direct contrast at the treatment-0 mediator distribution is \(15.76-12.48=3.28\) symptom-score points. The indirect contrast under treatment 1 is \(18.64-15.76=2.88\) points. Their sum, \(3.28+2.88=6.16\) points, equals the total contrast \(18.64-12.48=6.16\) points.
Worked Example: Integrating a Nonlinear Outcome Regression
Consider a hypothetical setting with no varying \(C\), a continuous mediator measured in units, and the conditional outcome regression \(\mu(a,m)=20+4a+2m+0.5m^2\), where the outcome is measured in points. Suppose the mediator distribution under \(A=0\) has mean 2 and variance 1, while under \(A=1\) it has mean 3 and variance 4. These distributions are assumed to have support adequate for the outcome regression.
For any mediator distribution, \(E(M^2)=\operatorname{Var}(M)+\{E(M)\}^2\). Under \(A=0\), this second moment is \(1+2^2=5\). Therefore, \[ \psi(1,0)=20+4(1)+2(2)+0.5(5)=24+4+2.5=30.5 \] points. Under \(A=1\), the second moment is \(4+3^2=13\), giving \[ \psi(1,1)=20+4(1)+2(3)+0.5(13)=24+6+6.5=36.5 \] points. For the reference treatment and reference mediator distribution, \[ \psi(0,0)=20+4(0)+2(2)+0.5(5)=26.5 \] points. Thus the direct contrast is \(30.5-26.5=4\) points, and the indirect contrast under treatment 1 is \(36.5-30.5=6\) points. The total contrast is \(36.5-26.5=10\) points, which is their sum.
This calculation illustrates why the entire mediator distribution can matter: the quadratic term requires its second moment, not merely its mean.
Worked Example: A Binary Outcome on the Risk-Difference Scale
Suppose a hypothetical study has \(P(C=0)=P(C=1)=0.5\), a binary mediator, and a binary outcome. The probabilities that \(M=1\) under treatment 0 are 0.1 for \(C=0\) and 0.7 for \(C=1\); under treatment 1 they are 0.4 and 0.9. In treatment arm 1, the outcome risks \(\mu(1,m,c)\) are 0.05 and 0.15 for \(C=0,M=0\) and \(C=0,M=1\), and 0.20 and 0.50 for \(C=1,M=0\) and \(C=1,M=1\), respectively.
To calculate \(\psi(1,0)\), average the treatment-1 risks over the treatment-0 mediator distribution within each covariate stratum. At \(C=0\), the risk is \(0.05+0.1(0.15-0.05)=0.06\). At \(C=1\), it is \(0.20+0.7(0.50-0.20)=0.41\). Consequently, \[ \psi(1,0)=0.5(0.06)+0.5(0.41)=0.235. \]
For \(\psi(1,1)\), the corresponding risks are \(0.05+0.4(0.10)=0.09\) and \(0.20+0.9(0.30)=0.47\). Thus \(\psi(1,1)=0.5(0.09)+0.5(0.47)=0.28\). The interventional indirect effect under treatment 1 is \(0.28-0.235=0.045\), or 4.5 percentage points of outcome risk. This is a risk difference, not a relative increase of 4.5 percent.
Why the Order of Averaging Matters
The g-formula makes the target population and the mediator intervention explicit. First, within each covariate stratum, it averages the outcome regression over the selected mediator distribution; then it averages those results over \(F_C\). This order respects the fact that both the mediator distribution and the conditional outcome mean can vary with baseline covariates.
A common mistake is to replace \(P(M=m\mid A=a^*,C=c)\) with \(P(M=m\mid A=a^*)\), then combine that marginal mediator distribution with outcome regressions conditional on \(C\). This generally changes the intervention: it no longer assigns mediator values according to the chosen treatment-specific distribution within covariate strata. Another mistake is to substitute \(E(M\mid A=a^*,C=c)\) into \(\mu(a,m,c)\). That is valid only in special cases, such as a regression linear in \(m\) with no features that make other aspects of the mediator distribution relevant. The formula requires integration over the distribution, not a plug-in at its mean.
The formula also clarifies the roles of its components. The outcome regression describes how the mean outcome varies with treatment, mediator, and covariates. The mediator distribution specifies which mediator values are assigned under the stochastic intervention. The covariate distribution determines how stratum-specific means are combined for the target population. Identification depends on the assumptions and support conditions, not merely on having written down these three ingredients.
Check Your Understanding
Use the definitions and formula above to answer the following questions.
- In the observed-data g-formula for \(\psi(1,0)\), which treatment level indexes the outcome regression, and which treatment level indexes the mediator distribution?
- Why does positivity need to cover mediator values drawn under \(a^*\) in the treatment arm \(a\) used for the outcome regression?
- If the outcome regression is quadratic in \(M\), which moments of the mediator distribution may be needed to evaluate the inner average?
- State the additive decomposition linking the direct contrast at the reference mediator distribution, the indirect contrast under treatment 1, and the total contrast.
- Why is it generally incorrect to replace the conditional mediator distribution given \(C\) with a marginal mediator distribution?