From a Joint Distribution to Natural Effects
When treatment, mediator, and outcome are binary, the observed data can be summarized by the joint distribution of mediator and outcome within each treatment group. The challenge is to turn those observed probabilities into counterfactual risks that answer questions such as: what would the outcome risk be under treatment if the mediator instead followed the distribution it would have under no treatment?
This tutorial works through that calculation step by step. The outcome is binary, so its expected value is its risk. Effects will be expressed as differences in risk, measured in percentage points when converted to percentages. These are population quantities; the hypothetical distributions below are treated as known exactly, so the examples do not calculate sampling uncertainty.
For a chosen reference value \(a'\), the natural direct effect compares \(E[Y_{1,M_{a'}}]\) with \(E[Y_{0,M_{a'}}]\): treatment changes while the mediator follows its natural value under \(a'\). The corresponding natural indirect effect at treatment value \(a\) compares \(E[Y_{a,M_1}]\) with \(E[Y_{a,M_0}]\): the treatment setting is held fixed while the mediator’s natural distribution changes. A common additive decomposition is
Here \(\text{NDE}(0)\) is the natural direct effect using the untreated mediator as the reference, and \(\text{NIE}(1)\) is the natural indirect effect with treatment set to 1. The total effect (TE) is the contrast between the two natural treatment regimes. These quantities add on the risk-difference scale; a different effect scale need not have the same additive decomposition.
Identification and the Standardization Formula
The observed joint distribution identifies these counterfactual risks only under causal assumptions. In the following formulas there are no baseline covariates; in applications with covariates, the relevant conditional risks and mediator probabilities must also be standardized over the covariate distribution.
Write \(q_a(m)=P(M=m\mid A=a)\) for the observed mediator distribution under treatment \(a\), and \(r_{am}=P(Y=1\mid A=a,M=m)\) for the observed outcome risk in treatment-mediator group \((a,m)\). Under the assumptions above, the mediation formula gives
The standardization is over the mediator distribution for \(a'\), while the outcome risks are taken from treatment group \(a\). That distinction is essential: changing which distribution is used for the weights changes the counterfactual risk being calculated.
A Short Justification
Because \(M_{a'}\) is binary, the natural counterfactual outcome can be partitioned according to whether \(M_{a'}=0\) or \(M_{a'}=1\). Taking expectations gives
where \(I(\cdot)\) equals 1 when its condition holds and 0 otherwise. The cross-world condition lets each term factor as \(E[Y_{a,m}]P(M_{a'}=m)\). Treatment exchangeability and consistency identify \(P(M_{a'}=m)\) as \(P(M=m\mid A=a')\). Mediator exchangeability and consistency identify \(E[Y_{a,m}]\) as \(E[Y\mid A=a,M=m]\). Since \(Y\) is binary, this conditional expectation is \(r_{am}\), yielding the standardization formula.
The additive decomposition follows by adding and subtracting the same intermediate counterfactual risk:
The first bracket is \(\text{NIE}(1)\), and the second is \(\text{NDE}(0)\). The equality is arithmetic on the risk-difference scale, not a claim that effects must add on every scale.
Worked Example: Calculate All Three Effects From Joint Probabilities
Suppose a hypothetical population has the following conditional joint probabilities. Each cell is \(P(M=m,Y=y\mid A=a)\); thus, the four cells in either treatment column sum to 1.
| Mediator \(M\) | Outcome \(Y\) | \(A=0\) | \(A=1\) |
|---|---|---|---|
| 0 | 0 | 0.36 | 0.15 |
| 0 | 1 | 0.04 | 0.15 |
| 1 | 0 | 0.36 | 0.175 |
| 1 | 1 | 0.24 | 0.525 |
First obtain the mediator probabilities by summing over outcome values. Under \(A=0\), \(q_0(0)=0.36+0.04=0.40\) and \(q_0(1)=0.36+0.24=0.60\). Under \(A=1\), \(q_1(0)=0.15+0.15=0.30\) and \(q_1(1)=0.175+0.525=0.70\).
Next calculate the outcome risks within each treatment-mediator group by dividing the \(Y=1\) cell by the mediator probability:
Standardize the treatment-1 outcome risks over the untreated mediator distribution to find \(E[Y_{1,M_0}]\):
The untreated natural risk is \(E[Y_{0,M_0}]=(0.10)(0.40)+(0.40)(0.60)=0.04+0.24=0.28\). The treated natural risk is \(E[Y_{1,M_1}]=(0.50)(0.30)+(0.75)(0.70)=0.15+0.525=0.675\). Therefore,
Under the identifying assumptions, the natural direct effect is an increase of 37 percentage points in outcome risk when treatment changes from 0 to 1 while the mediator follows its untreated natural value. The natural indirect effect is an increase of 2.5 percentage points when the mediator distribution changes from its untreated to treated natural distribution while treatment is held at 1. The total natural-effect contrast is an increase of 39.5 percentage points. These are causal interpretations only if the assumptions hold.
Worked Example: Use the Other Reference Distribution
Using the same hypothetical joint distribution, calculate the alternative additive decomposition that uses the treated mediator distribution as the reference for the direct effect. The additional standardized risk is
The direct effect at the treated mediator distribution is \(E[Y_{1,M_1}]-E[Y_{0,M_1}]=0.675-0.31=0.365\), or 36.5 percentage points. The indirect effect at treatment 0 is \(E[Y_{0,M_1}]-E[Y_{0,M_0}]=0.31-0.28=0.03\), or 3 percentage points. Together they give \(0.365+0.03=0.395\), the same total effect as before.
The two decompositions use different intermediate risks: one holds the mediator to its untreated natural distribution when calculating the direct effect, and the other uses its treated natural distribution. The total contrast is unchanged, but the direct and indirect components need not be. Here they differ only slightly from the first decomposition; that is a feature of these hypothetical risks, not a general rule.
Worked Example: A Larger Indirect Risk Difference
Consider a second hypothetical population with this conditional joint distribution:
| Mediator \(M\) | Outcome \(Y\) | \(A=0\) | \(A=1\) |
|---|---|---|---|
| 0 | 0 | 0.63 | 0.24 |
| 0 | 1 | 0.07 | 0.06 |
| 1 | 0 | 0.15 | 0.14 |
| 1 | 1 | 0.15 | 0.56 |
For \(A=0\), the mediator probabilities are \(q_0(0)=0.63+0.07=0.70\) and \(q_0(1)=0.15+0.15=0.30\). The outcome risks are \(r_{00}=0.07/0.70=0.10\) and \(r_{01}=0.15/0.30=0.50\). For \(A=1\), \(q_1(0)=0.24+0.06=0.30\), \(q_1(1)=0.14+0.56=0.70\), \(r_{10}=0.06/0.30=0.20\), and \(r_{11}=0.56/0.70=0.80\).
The standardized risks are
Thus \(\text{NDE}(0)=0.38-0.22=0.16\), \(\text{NIE}(1)=0.62-0.38=0.24\), and \(\text{TE}=0.62-0.22=0.40=0.16+0.24\). On the risk-difference scale, the natural direct and indirect effects are increases of 16 and 24 percentage points, respectively. The larger indirect component here reflects both a treatment-related shift in the mediator distribution and a difference in outcome risks across mediator values; the calculation itself does not establish that the assumptions are true.
Checks Before Interpreting the Results
A joint table is enough to calculate the standardized risks, but not enough to establish a causal interpretation. Before reporting natural effects, check that the data support all treatment and mediator groups used in the formula, and assess whether the no-unmeasured-confounding and cross-world assumptions are scientifically defensible. Positivity can be checked in observed data; the other causal assumptions generally require design knowledge and substantive argument.
Keep the two ingredients of each standardized risk separate. The outcome risk \(r_{am}\) comes from treatment level \(a\); the mediator weight \(q_{a'}(m)\) comes from the reference level \(a'\). For example, \(E[Y_{1,M_0}]\) uses treated outcome risks and untreated mediator probabilities. Substituting \(q_1(m)\) instead would calculate \(E[Y_{1,M_1}]\), not \(E[Y_{1,M_0}]\).
- Using an observed group risk as a natural risk. The observed risk \(P(Y=1\mid A=a)\) averages over the mediator distribution observed at \(a\). It equals the corresponding natural risk \(E[Y_{a,M_a}]\) under consistency and treatment exchangeability, but it does not by itself provide a cross-treatment standardized risk such as \(E[Y_{1,M_0}]\).
- Reversing the weights. In \(E[Y_{a,M_{a'}}]\), use outcome risks from \(A=a\) and mediator probabilities from \(A=a'\).
- Forgetting the effect scale. The displayed additive decomposition holds for risk differences. Do not assume the direct and indirect risk differences add to a risk ratio or odds ratio.
- Treating assumptions as verified by the table. A complete joint distribution permits arithmetic, but it cannot rule out unmeasured confounding or establish the cross-world condition.
Check Your Understanding
Use the standardization formula and state which mediator distribution supplies the weights in each answer.
- If \(q_0(0)=0.25\), \(q_0(1)=0.75\), \(r_{10}=0.20\), and \(r_{11}=0.60\), calculate \(E[Y_{1,M_0}]\).
- In the first worked example, why is \(E[Y_{1,M_0}]\) not calculated using \(q_1(0)\) and \(q_1(1)\)?
- Using the first example, verify that \(\text{NDE}(0)+\text{NIE}(1)=\text{TE}\).
- Name one assumption needed to identify natural effects that cannot be confirmed merely by checking whether every cell in the observed joint distribution is positive.
- In words, distinguish the mediator distribution used for \(E[Y_{0,M_1}]\) from the treatment group used to obtain its outcome risks.