From an Interventional Estimand to an Estimate
Interventional mediation effects are defined by comparing expected outcomes under treatment settings while drawing the mediator from specified distributions. In data analysis, those distributions and expected outcomes are unknown. Parametric g-computation estimates them with statistical models, then combines the fitted models to approximate the target population averages.
Let \(A\) be a binary treatment, \(M\) a mediator, \(Y\) an outcome, and \(C\) a set of baseline covariates. The interventional mean \(\psi(a,a^*)\) is the expected outcome if treatment were set to \(a\), while the mediator were drawn from its distribution under treatment \(a^*\), conditional on baseline covariates. The covariates are then averaged over their target population distribution.
For binary treatment, one common additive decomposition is the interventional direct effect \(\psi(1,0)-\psi(0,0)\), the interventional indirect effect \(\psi(1,1)-\psi(1,0)\), and the total effect \(\psi(1,1)-\psi(0,0)\). The first contrast changes treatment while holding the mediator reference distribution at that under \(A=0\). The second changes the mediator reference distribution while holding treatment at \(A=1\). Their sum equals the total contrast because \(\{\psi(1,0)-\psi(0,0)\}+\{\psi(1,1)-\psi(1,0)\}=\psi(1,1)-\psi(0,0)\).
The Parametric G-Computation Algorithm
The procedure uses two fitted models. First, fit a model for the conditional mediator distribution \(F_{M\mid A,C}\). Its role is to generate mediator values for each participant’s baseline covariates under a chosen treatment value. Second, fit a model for the conditional outcome mean \(E(Y\mid A,M,C)\). Its role is to predict the mean outcome at a specified treatment, mediator value, and covariate profile.
For each target contrast, use the observed baseline covariates \(C_i\) as the standardization population. For each individual \(i\), generate \(L\) mediator draws from the fitted mediator distribution under \(a^*\), predict the outcome under \(a\) for each draw, and average. Finally, average those individual-specific means across the sample:
The model for the outcome must return a predicted conditional mean on the outcome’s response scale. For a continuous outcome with an identity-link model, this is the predicted mean itself. For a binary outcome modeled with logistic regression, it is the predicted probability, obtained by applying the inverse-logit function to the fitted linear predictor. Averaging linear predictors and then transforming them is generally not the same as averaging predicted probabilities.
Use observed treatment and baseline covariates to estimate how the mediator is distributed across treatment and covariate values.
Estimate the conditional mean of the outcome as a function of treatment, mediator, and baseline covariates, allowing a suitably flexible form for their relationships.
For each \(a,a^*\) contrast and each observed covariate profile, draw mediators under \(a^*\), then predict outcomes under \(a\).
Average predictions over mediator draws and the target covariate distribution to estimate \(\psi(a,a^*)\); subtract the relevant means to obtain effects.
Worked Example: A Continuous Outcome With No Baseline Covariates
Suppose hypothetical fitted models are \(M\mid A=a\sim N(4+1.2a,1.5^2)\) and \(E(Y\mid A=a,M=m)=20+2a+3m\). The outcome is measured in points. To make the Monte Carlo calculation transparent, suppose three illustrative mediator draws under \(a^*=0\) are \(3,4,5\), and three under \(a^*=1\) are \(4.2,5.2,6.2\). Their averages are 4 and 5.2, respectively.
For \(\widehat{\psi}(0,0)\), use \(A=0\) in the outcome model and the first draw set. The three predicted outcomes are \(20+3(3)=29\), \(20+3(4)=32\), and \(20+3(5)=35\). Thus \(\widehat{\psi}(0,0)=(29+32+35)/3=32\) points.
For \(\widehat{\psi}(1,0)\), keep the mediator draws from the \(A=0\) distribution but set treatment to 1 in the outcome model. Predictions are 31, 34, and 37 points, so \(\widehat{\psi}(1,0)=34\). For \(\widehat{\psi}(1,1)\), use the draws \(4.2,5.2,6.2\) and set treatment to 1. Predictions are \(20+2+3(4.2)=34.6\), \(37.6\), and \(40.6\); their average is \(37.6\) points.
The estimated direct effect is \(34-32=2\) points, the indirect effect is \(37.6-34=3.6\) points, and the total effect is \(37.6-32=5.6\) points. These are illustrative calculations using a small set of draws; an applied analysis would generally use many more draws.
Worked Example: A Binary Outcome and Response-Scale Averaging
Consider a hypothetical fitted outcome model \(\operatorname{logit}\{P(Y=1\mid A,M)\}=-2+0.5A+0.8M\). Suppose mediator draws supplied by the fitted mediator model are \(0,1,2\) under \(a^*=0\) and \(1,2,3\) under \(a^*=1\). There are no baseline covariates in this illustration. Because \(Y\) is binary, each predicted outcome is a probability.
For \(\widehat{\psi}(0,0)\), the linear predictors are \(-2,-1.2,-0.4\). Applying the inverse-logit gives probabilities \(0.1192,0.2315,0.4013\), whose average is \((0.1192+0.2315+0.4013)/3=0.2507\).
For \(\widehat{\psi}(1,0)\), use the same mediator draws but set \(A=1\). The linear predictors become \(-1.5,-0.7,0.1\), giving probabilities \(0.1824,0.3318,0.5250\). Their mean is \(0.3464\). For \(\widehat{\psi}(1,1)\), use mediator draws \(1,2,3\) with \(A=1\). The predictors are \(-0.7,0.1,0.9\), giving probabilities \(0.3318,0.5250,0.7109\), with mean \(0.5226\).
The estimated direct contrast is \(0.3464-0.2507=0.0957\), or about 9.57 percentage points. The indirect contrast is \(0.5226-0.3464=0.1762\), or about 17.62 percentage points. The total contrast is \(0.5226-0.2507=0.2719\), or about 27.19 percentage points. These are marginal risk differences in this hypothetical example. The calculations average predicted probabilities, not logistic linear predictors.
Standardizing Over Baseline Covariates
When baseline covariates are present, the algorithm repeats the mediator simulation and outcome prediction at each observed covariate profile. Averaging over those profiles targets the empirical covariate distribution of the study sample. This standardization matters: the fitted models provide conditional quantities, whereas \(\psi(a,a^*)\) is a marginal mean for a specified population.
Worked Example: Averaging Over Observed Covariate Profiles
Suppose four hypothetical participants have baseline covariate values \(C=(0,0,0,1)\). Assume fitted models \(M\mid A,C\sim N(10+2A+C,2^2)\) and \(E(Y\mid A,M,C)=5+1.5A+0.8M+2C\), with \(Y\) measured in outcome units. To display the averaging, use mediator draws \(8,10,12\) under \(a^*=0\) for each participant with \(C=0\), and \(9,11,13\) for the participant with \(C=1\). Under \(a^*=1\), the corresponding illustrative draw sets are \(10,12,14\) and \(11,13,15\).
For \(\widehat{\psi}(0,0)\), each \(C=0\) participant has predicted outcomes \(11.4,13,14.6\), averaging to \(13\). The \(C=1\) participant has predictions \(14.2,15.8,17.4\), averaging to \(15.8\). Averaging the four participant-specific means gives \(\widehat{\psi}(0,0)=\{3(13)+15.8\}/4=13.7\).
For \(\widehat{\psi}(1,0)\), the participant-specific means are \(14.5\) for each of the three \(C=0\) participants and \(17.3\) for the \(C=1\) participant. Therefore \(\widehat{\psi}(1,0)=\{3(14.5)+17.3\}/4=15.2\). For \(\widehat{\psi}(1,1)\), the corresponding means are \(16.1\) and \(18.9\), so \(\widehat{\psi}(1,1)=\{3(16.1)+18.9\}/4=16.8\).
The direct, indirect, and total contrasts are \(15.2-13.7=1.5\), \(16.8-15.2=1.6\), and \(16.8-13.7=3.1\) outcome units. The empirical covariate distribution gives weight \(3/4\) to \(C=0\) and \(1/4\) to \(C=1\); the results therefore reflect that distribution, not an equally weighted average of the two covariate strata.
Why the Simulation-and-Averaging Formula Works
The integral in the estimand averages the conditional outcome mean over the mediator distribution for each covariate profile. A draw from that distribution allows the integral to be approximated by an average. In the limit, this average converges to the integral when draws are generated from the specified distribution and the relevant expectations exist. A second average over observed covariate profiles approximates the expectation over the target population’s covariate distribution.
More explicitly, for fixed \(C_i\), define \(g(a,m,C_i)=E(Y\mid A=a,M=m,C_i)\). If \(M_{i\ell}^{a^*}\) are independent draws from \(F_{M\mid A=a^*,C_i}\), then the conditional Monte Carlo average has expectation
Replacing \(g\) and \(F\) with fitted models gives the plug-in estimator. Increasing \(L\) reduces the numerical error from using a finite number of mediator draws, but it does not correct bias from an incorrectly specified model or remove uncertainty from estimating model parameters.
Identification and Model Requirements
G-computation is an estimation procedure; its output has a causal interpretation only when the estimand is identified and the fitted models adequately represent the required conditional quantities. The identification conditions for interventional mediation include consistency, appropriate treatment exchangeability given baseline covariates, and mediator-outcome exchangeability given treatment and baseline covariates. Positivity must also hold: the treatment and mediator values needed for the estimand must be supported at relevant covariate profiles. In particular, mediator positivity and support are important when generating draws under a reference treatment.
Parametric estimation adds modeling requirements. The mediator model must describe its conditional distribution well enough to generate appropriate draws, and the outcome model must estimate the conditional mean well over the combinations of treatment, mediator, and covariates used in the calculation. Model misspecification, extrapolation beyond observed support, and sparse data can undermine the result even when the estimation algorithm is implemented correctly. Including treatment-by-mediator or nonlinear terms may be necessary when the scientific setting and data support them.
The number of mediator draws controls Monte Carlo precision, not causal identification. Likewise, a large number of draws does not make an unsupported mediator value credible. Statistical uncertainty in the fitted effects requires additional uncertainty quantification; the point-estimation calculations here do not by themselves provide a confidence interval.
Common Mistakes
- Using the same treatment value for both roles. The first argument \(a\) sets treatment in the outcome prediction; the second, \(a^*\), sets the mediator distribution. Changing one while holding the other fixed is how the interventional contrasts are formed.
- Plugging in a single predicted mediator. A conditional mean mediator is not generally a substitute for its full distribution, especially when the outcome model is nonlinear. Draw from the fitted distribution and average predicted outcomes.
- Averaging on the wrong scale. For a binary outcome, average predicted probabilities. Averaging logistic linear predictors and transforming once generally yields a different quantity.
- Confusing numerical accuracy with causal validity. More simulation draws can reduce Monte Carlo error, but cannot repair failed identification conditions, poor support, or misspecified models.
- Interpreting a conditional prediction as a population effect. Average over the covariate distribution of the target population before taking contrasts, unless the target estimand is explicitly conditional.
Check Your Understanding
Answer each question by tracing the treatment setting, mediator distribution, and averaging step.
- In \(\psi(1,0)\), which treatment value is used in the outcome model, and which treatment value determines the mediator draws?
- Why should a logistic outcome model’s predictions be averaged as probabilities rather than as linear predictors?
- If the mediator draws are generated correctly but the outcome model is misspecified, does increasing the number of draws eliminate the resulting bias? Explain.
- What population distribution is represented when standardization averages over the observed baseline covariate profiles?
- In the continuous-outcome example, verify that the direct and indirect contrasts add to the total contrast.