Why a Continuous Mediator Requires Integration
A mediator can be a measured quantity such as a biomarker concentration, symptom score, or duration of exposure. Unlike a binary mediator, it can take values across a continuum. To define a natural effect, we therefore ask what the outcome would be under a treatment level while the mediator takes the value it would naturally have under another treatment level. Identifying that quantity requires averaging the outcome regression over a distribution of mediator values, not summing over a few categories.
The integration matters even when the outcome regression is simple. If it is nonlinear in the mediator, its average depends on the shape and spread of the mediator distribution, not just its mean. The formula below makes both ingredients explicit: a conditional outcome regression and a conditional mediator density.
These definitions use an additive outcome scale. Their sum is the total effect on that scale: $$ \psi(a,a)-\psi(a',a')= \{\psi(a,a')-\psi(a',a')\}+ \{\psi(a,a)-\psi(a,a')\}. $$ The definitions involve nested counterfactuals: the outcome under one treatment is evaluated at the mediator value that would arise under a potentially different treatment. The assumptions needed to connect these quantities to observed data are therefore substantive, not merely technical.
The Continuous-Mediator Identification Formula
Write \(\mu(a,m,c)=E(Y\mid A=a,M=m,C=c)\) for the conditional outcome regression, and \(f(m\mid A=a,C=c)\) for the conditional density of the mediator. Under the identification assumptions stated below, the mediation functional is
Here \(F_C\) is the distribution of baseline covariates in the target population. For discrete \(C\), the outer integral is a sum. If there are no covariates to standardize over, the formula reduces to an integral over \(m\) alone. In either case, the mediator density is evaluated at treatment \(a'\), while the outcome regression is evaluated at treatment \(a\).
This distinction is central. To obtain \(\psi(a,a')\), draw mediator values from the distribution expected under \(a'\), predict the outcome for each value as if treatment were \(a\), and average those predictions over the target population. The mediator value is integrated out; it is not fixed at its mean unless the outcome regression makes that shortcut valid.
- Consistency and well-defined interventions: if a person receives \(A=a\), their observed mediator equals \(M(a)\); if they receive \(A=a\) and have mediator value \(m\), their observed outcome equals \(Y(a,m)\). The treatment and mediator interventions must be sufficiently well defined for these counterfactuals to have meaning.
- Treatment exchangeability given \(C\): conditional on \(C\), treatment is independent of the relevant potential mediators and outcomes. In particular, \(\{M(a),Y(a,m)\}\perp A\mid C\) for the treatment levels and mediator values of interest.
- Mediator-outcome exchangeability: \(Y(a,m)\perp M\mid A=a,C\). After conditioning on treatment and baseline covariates, there is no unmeasured common cause of the mediator and the potential outcome.
- Cross-world independence: \(Y(a,m)\perp M(a')\mid C\). This links the potential outcome under one mediator intervention to the mediator value under another treatment. It is not directly testable from observed data.
- Positivity: treatment levels occur with positive probability across the relevant covariate strata. Also, for almost every \(c\), mediator values with positive density under \(A=a',C=c\) must lie in the support where the outcome regression under \(A=a,C=c\) is identified. For a continuous mediator this is an overlap condition on densities, not a requirement that each exact mediator value have positive probability.
These assumptions are a sufficient identification set, not a guarantee that the resulting estimate is unbiased in a particular application. In practice, the outcome regression and mediator density must also be estimated adequately from the available data. A regression fit cannot remedy a failure of exchangeability or support overlap.
Why the Formula Holds
A short derivation shows how the assumptions connect the nested counterfactual to observed-data quantities. First condition on the covariates and the mediator value \(M(a')\). Cross-world independence allows the conditional mean of \(Y(a,m)\) to be averaged over the distribution of \(M(a')\):
Treatment exchangeability identifies the distribution of \(M(a')\mid C=c\) with the observed mediator distribution among people receiving \(A=a'\), conditional on \(C=c\). The treatment and mediator-outcome exchangeability assumptions identify the potential-outcome mean inside the integral with the observed outcome regression among people receiving \(A=a\), conditional on \(M=m,C=c\). Thus,
Substituting these two observed-data expressions into the conditional integral and averaging over \(C\) gives the stated mediation formula. The density and regression must be combined over the same covariate distribution; comparing unstandardized regressions across different covariate mixes would not, in general, produce this target quantity.
Worked Example: Integrating a Linear Outcome Regression
Suppose, hypothetically, that there are no covariates and the conditional mediator distributions are \(M\mid A=0\sim N(2,1)\) and \(M\mid A=1\sim N(4,1)\). Suppose the identified outcome regression is \(\mu(a,m)=10+3a+2m\), where \(Y\) is measured in outcome units and \(M\) in mediator units. Assume the identification conditions and the required overlap hold.
The integral defining the mediation functional can be written as an expectation over the mediator distribution under \(a'\):
The four required values are therefore \(\psi(1,0)=10+3+2(2)=17\), \(\psi(0,0)=10+0+2(2)=14\), \(\psi(1,1)=10+3+2(4)=21\), and \(\psi(0,1)=10+0+2(4)=18\).
For the comparison of treatment 1 with treatment 0, the natural direct effect is \(\psi(1,0)-\psi(0,0)=17-14=3\) outcome units. The natural indirect effect is \(\psi(1,1)-\psi(1,0)=21-17=4\) outcome units. Their sum is \(3+4=7\), which equals the total effect \(\psi(1,1)-\psi(0,0)=21-14=7\). Here the linear regression makes the average depend only on the mediator mean; that simplification does not generally hold for nonlinear regressions.
Worked Example: A Nonlinear Regression Uses the Full Mediator Distribution
Consider another hypothetical setting with no covariates. Let \(M\mid A=0\sim N(1,1)\), \(M\mid A=1\sim N(2,1)\), and let \(\mu(a,m)=5+2a+m^2\). Assume the identification assumptions and overlap hold. Because \(M\) is normal with mean \(q\) and variance 1, \(E(M^2)=q^2+1\).
When \(a'=0\), the mediator has mean 1, so \(E(M^2\mid A=0)=1^2+1=2\). When \(a'=1\), it has mean 2, so \(E(M^2\mid A=1)=2^2+1=5\). Substitution into the mediation formula gives \(\psi(a,a')=5+2a+E(M^2\mid A=a')\).
Thus \(\psi(1,0)=5+2+2=9\), \(\psi(0,0)=5+0+2=7\), and \(\psi(1,1)=5+2+5=12\). The natural direct effect is \(9-7=2\) outcome units, and the natural indirect effect is \(12-9=3\) outcome units. Their sum, 5, equals the total effect \(12-7=5\).
If one had substituted only the mediator means into \(m^2\), the resulting values would have been 1 and 4, rather than the correct expectations 2 and 5. The missing 1 in each case is the mediator variance. For this nonlinear regression, integrating the density is essential.
Worked Linear-Gaussian Mediation Model
A linear-Gaussian model gives a compact example in which both pieces of the formula have familiar forms. Suppose the mediator and outcome follow these hypothetical structural equations:
Assume the errors have conditional mean zero, the mediator error is normally distributed with variance \(\sigma_M^2\), and the model and identification assumptions are appropriate for the population being studied. The outcome equation has no treatment-mediator product term. Under this specified model, the mediator density is normal with mean \(\alpha_0+\alpha_A a'+\alpha_C c\), and the outcome regression is \(\beta_0+\beta_A a+\beta_M m+\beta_C c\).
Worked Example: Natural Effects From a Linear-Gaussian Model
For a hypothetical application, take \(A\) to compare 0 with 1 and use the model coefficients \(\alpha_0=1\), \(\alpha_A=2\), \(\alpha_C=0.5\), \(\beta_0=3\), \(\beta_A=1.5\), \(\beta_M=0.8\), and \(\beta_C=-0.4\). Let \(\varepsilon_M\sim N(0,1)\), with mean-zero outcome error. Assume the identification conditions hold. The mediator is measured in mediator units and the outcome in outcome units.
For any covariate value \(c\), the mean mediator under treatment \(a'\) is \(1+2a'+0.5c\). Integrating the linear outcome regression over that normal mediator distribution replaces \(m\) by its conditional mean:
The covariate terms cancel in this particular parameterization, so averaging over the population distribution of \(C\) leaves the same expression. The mediation functional is \(\psi(a,a')=3.8+1.5a+1.6a'\). Therefore, \(\psi(1,0)=5.3\), \(\psi(0,0)=3.8\), and \(\psi(1,1)=6.9\).
The natural direct effect is \(5.3-3.8=1.5\) outcome units. The natural indirect effect is \(6.9-5.3=1.6\) outcome units, and the total effect is \(6.9-3.8=3.1\) outcome units. The arithmetic also gives \(1.5+1.6=3.1\), as required by the additive decomposition. In this model, the direct contrast comes from the coefficient of \(A\) in the outcome equation, and the indirect contrast is the mediator effect \(0.8\) multiplied by the change in the mediator mean \(2\): \(0.8\times2=1.6\). That coefficient shortcut follows from this model's linear form; the integral remains the defining calculation.
Common Pitfalls and Practical Meaning
The formula separates identification from modeling. Identification says that, under stated assumptions, the target counterfactual quantity equals a functional of the observed conditional density and regression. Estimation then requires data methods for those two functions and for averaging over \(C\). The mediator need not actually be normally distributed for the identification formula to hold; normality was used only in the worked examples to evaluate particular integrals.
- Replacing an integral with a sum over a few mediator categories. Categorizing a continuous mediator changes the analysis and can discard information. The natural-effect formula averages over the mediator's continuous conditional density.
- Using the wrong treatment level in one component. In \(\psi(a,a')\), use the outcome regression under \(A=a\), but the mediator density under \(A=a'\). Reversing these generally targets a different quantity.
- Plugging in the mediator mean without checking the outcome regression. For a linear regression in \(m\), the conditional mean may suffice. With curvature, as in \(m^2\), the variance and potentially other features of the distribution matter too.
- Reading identification assumptions as consequences of a fitted model. A well-fitting density and outcome regression do not establish exchangeability or cross-world independence. Those are causal assumptions requiring subject-matter justification.
- Interpreting an observed association as a natural effect. The integral identifies a causal contrast only when its assumptions and positivity conditions are credible. Without them, it is merely a calculation from observed-data models.
For continuous mediators, the central practical task is to combine the outcome regression under one treatment level with the mediator distribution under another, then average over baseline covariates in the target population. Writing that operation explicitly helps prevent a conditional regression coefficient from being mistaken for a natural effect.
Check Your Understanding
Answer each question using the mediation functional and assumptions developed above.
- In \(\psi(a,a')\), which treatment level indexes the outcome regression, and which indexes the mediator density?
- Why can \(E(M^2)\) not generally be calculated by squaring \(E(M)\)?
- State the overlap condition for mediator values in words for a continuous mediator.
- In the linear-Gaussian example, verify that the indirect effect equals the mediator coefficient multiplied by the treatment effect on the mediator mean.
- Does fitting an outcome regression and a mediator density establish cross-world independence? Explain.