Why Binary Outcomes Require Care
For a continuous outcome in a linear model, coefficients can sometimes be compared across models to investigate mediation. With a binary outcome, logistic regression introduces a complication: the odds ratio is noncollapsible. Even when a covariate is not a confounder, adding it to a logistic model can change the exposure coefficient. Consequently, the change in a logistic-regression coefficient after adjusting for a mediator is not, by itself, an estimate of a mediated effect.
The solution is to state the effect scale and the target contrast explicitly. For binary outcomes, one useful approach is to predict risks under specified exposure and mediator distributions, average those risks, and then contrast them. These standardized risks provide direct and indirect contrasts on a chosen scale, such as the risk difference. They are not generally obtained by subtracting logistic-regression coefficients.
Conditional and Marginal Odds Ratios
For a binary outcome \(Y\), a risk is a probability such as \(P(Y=1\mid X=x,M=m)\). The corresponding odds are \(p/(1-p)\), where \(p\) is that probability. A logistic regression model expresses the log odds as a linear predictor. For example, with a binary exposure \(X\) and binary mediator \(M\), a model without interaction is
At a fixed value of \(M\), the conditional exposure odds ratio is \(\exp(\beta_X)\). But a marginal risk averages over the distribution of \(M\). If \(w_m\) is the proportion with mediator value \(m\), then the standardized risk at exposure level \(x\) is \(q_x=\sum_m P(Y=1\mid x,m)w_m\), and its odds are \(q_x/(1-q_x)\). In general, the marginal odds ratio formed from these averaged risks is not \(\exp(\beta_X)\).
Worked Example: Noncollapsibility Without Mediation
Suppose a hypothetical population has a binary exposure \(X\) and a binary prognostic factor \(M\). Assume \(X\) and \(M\) are independent, \(P(M=1)=0.5\), and the outcome model is \(\operatorname{logit}P(Y=1\mid X,M)=-2+\log(2)X+\log(4)M\). Thus, at either value of \(M\), the conditional exposure odds ratio is 2. The mediator distribution is the same for both exposure groups, so there is no exposure-to-mediator pathway in this example.
For \(X=0\), the two conditional risks are \(\operatorname{expit}(-2)=0.1192\) when \(M=0\), and \(\operatorname{expit}(-2+\log 4)=0.3512\) when \(M=1\). Averaging over the equal mediator proportions gives
For \(X=1\), the conditional risks are \(\operatorname{expit}(-2+\log 2)=0.2130\) and \(\operatorname{expit}(-2+\log 2+\log 4)=0.5198\). Therefore,
The marginal odds ratio is approximately
Thus the marginal odds ratio is about 1.880, although the conditional odds ratio is 2. This difference arises from averaging over a prognostic factor and then converting the averaged risks to odds. It is not evidence of confounding or mediation in this example: \(M\) is independent of \(X\), and its distribution is unchanged across exposure levels.
This example establishes the central warning. A logistic-regression coefficient can change when a mediator is added even if the change does not represent mediation. In mediation analysis, the mediator also typically has a distribution that changes with exposure, so a coefficient comparison can mix noncollapsibility with genuine changes in outcome risk. The coefficient difference alone does not separate those sources.
Risk-Scale Mediation Contrasts
To define a mediation contrast, first specify the risks being compared. Let \(R(x,x')\) denote the outcome risk if the outcome exposure were set to \(x\), while the mediator were drawn from the distribution it would have under exposure \(x'\). In a simple binary-mediator setting, this standardized risk is
Under the usual causal mediation identification conditions, this expression can identify the risk of the corresponding counterfactual outcome \(Y_{x,M_{x'}}\). These conditions include consistency, positivity, and adequate control of exposure–outcome, exposure–mediator, and mediator–outcome confounding; identifying natural effects also requires that no mediator–outcome confounder be caused by exposure. Without the required assumptions, the formula still defines a standardized association, but its causal interpretation is not established.
One additive decomposition uses the mediator distribution under \(X=0\) for the direct contrast and the outcome exposure \(X=1\) for the indirect contrast:
The direct and indirect contrasts sum to the total risk difference because the intermediate term \(R(1,0)\) cancels. This is an algebraic decomposition on the risk-difference scale. Other effect scales or reference distributions can produce different decompositions, so the scale and contrast must be reported.
Worked Example: Standardizing Risks Under a Mediator Shift
Consider hypothetical data generated under the outcome model \(\operatorname{logit}P(Y=1\mid X,M)=-2+\log(1.5)X+\log(4)M\). Assume the mediator probabilities are \(P(M=1\mid X=0)=0.2\) and \(P(M=1\mid X=1)=0.6\). Suppose the causal identification assumptions just stated hold, so the standardized contrasts can be interpreted causally.
The outcome risks predicted by the model are \(P(Y=1\mid 0,0)=0.1192\), \(P(Y=1\mid 0,1)=0.3512\), \(P(Y=1\mid 1,0)=0.1687\), and \(P(Y=1\mid 1,1)=0.4481\). Standardizing the outcome exposure to \(0\) and the mediator distribution to that under \(X=0\) gives
Holding the outcome exposure at \(1\), but retaining the mediator distribution under \(X=0\), gives
Finally, standardizing to the mediator distribution under \(X=1\) gives
The direct risk difference is \(0.2246-0.1656=0.0590\), or about 5.90 percentage points. The indirect risk difference is \(0.3364-0.2246=0.1118\), or about 11.18 percentage points. The total risk difference is \(0.3364-0.1656=0.1708\), or about 17.08 percentage points. The first two contrasts sum to the total, up to rounding.
The conditional exposure odds ratio in the fitted model is 1.5, with log coefficient \(\log(1.5)\approx0.4055\). That coefficient is neither the indirect risk difference of 0.1118 nor the total risk difference of 0.1708. Even comparing it with a marginal log odds ratio would not turn their difference into a mediated effect: those are log-odds contrasts, while the mediation contrasts above are risk differences.
Interaction Changes the Conditional Effect
If the outcome model includes an exposure–mediator interaction, the conditional exposure odds ratio itself depends on the mediator value. In the model below, the exposure coefficient describes the log odds ratio at \(M=0\), while the exposure coefficient plus the interaction coefficient describes it at \(M=1\). Standardization remains available: predict risks for each exposure–mediator combination, average using the specified mediator distributions, and form contrasts on the chosen scale.
Worked Example: Mediation Contrasts With Interaction
Suppose a hypothetical outcome model has intercept \(-2\), exposure coefficient \(\log 2\), mediator coefficient \(\log 3\), and interaction coefficient \(\log 2\). Let \(P(M=1\mid X=0)=0.25\) and \(P(M=1\mid X=1)=0.65\). Assume the causal identification conditions hold. The conditional exposure odds ratio is 2 at \(M=0\), and \(2\times2=4\) at \(M=1\).
The model gives risks \(0.1192\) at \((X,M)=(0,0)\), \(0.2888\) at \((0,1)\), \(0.2130\) at \((1,0)\), and \(0.6189\) at \((1,1)\). The standardized risks are
Using the unrounded model predictions, the direct risk difference is approximately \(0.1529\), the indirect risk difference approximately \(0.1624\), and the total risk difference approximately \(0.3153\). These contrasts describe changes in outcome probability, not changes in the logit coefficient. The interaction also means there is no single conditional exposure odds ratio that applies at both mediator values.
Derivation: Why Averaging Does Not Preserve an Odds Ratio
Suppose that, in every mediator stratum \(m\), the conditional exposure odds ratio equals the same value \(\theta\). Write the baseline risk in stratum \(m\) as \(p_{0m}\). The exposure risk in that stratum is then
To see this, the baseline odds are \(p_{0m}/(1-p_{0m})\). Multiplying those odds by \(\theta\) and converting back to a probability gives the displayed expression. For mediator weights \(w_m\), the marginal risks are \(q_0=\sum_m w_mp_{0m}\) and \(q_1=\sum_m w_mp_{1m}\). The marginal odds ratio is therefore
The operation converting a risk to odds is nonlinear, and \(p_{1m}\) is itself a nonlinear function of \(p_{0m}\). Thus the sums in this expression do not generally simplify to \(\theta\). The numerical example above shows the consequence: the stratum-specific odds ratio is 2, while the marginal odds ratio is about 1.880, despite identical mediator weights in the two exposure groups.
Common Mistake and Practical Interpretation
Wrong reasoning: “The exposure coefficient fell after adding the mediator to the logistic regression, so the amount it fell is the indirect effect.” This treats a change between conditional log odds as though it were a mediation contrast. It ignores noncollapsibility, can be affected by exposure–mediator interaction and model specification, and does not state an effect scale for the proposed indirect effect.
Correction: Define the target contrast first. If the question concerns changes in outcome probability, estimate the relevant conditional risks, average them over the stated mediator distributions, and calculate direct, indirect, and total risk contrasts. If odds ratios are reported, identify whether each is conditional or marginal and avoid interpreting a difference in logistic coefficients as a mediated effect without a separate justification.
In genetic mediation, these calculations do not remove the need for causal identification assumptions. A well-fitting logistic model alone does not establish that the exposure or mediator effects are causal. Report the model, standardization distribution, effect scale, and assumptions that support the interpretation. This makes clear whether a result is a conditional association, a standardized risk contrast, or a causal mediation estimate.
Check Your Understanding
Use the definitions and calculations above to answer the following questions.
- How can a conditional odds ratio differ from a marginal odds ratio when exposure and mediator are independent?
- In the second worked example, which mediator distribution defines \(R(1,0)\), and which defines \(R(1,1)\)?
- Why is the difference between two logistic-regression exposure coefficients not automatically an indirect effect?
- With an exposure–mediator interaction, what does the exposure coefficient alone represent in the stated logistic model?
- Name two assumptions needed before interpreting standardized mediation contrasts causally.