17  Mediation Analysis

17.1 Mediation in Context

Chapters 15 and 16 asked how well a set of predictors explained an outcome. Mediation analysis asks a narrower and more useful question: through what mechanism does a predictor affect the outcome? Advertising exposure may lift purchases, but does it do so by shifting brand attitude? A training programme may lift performance, but does the lift travel through newly acquired skill? The variable that sits between cause and outcome is called a mediator.

NoteWhat a mediator is and is not

A mediator is a variable on the causal path from X to Y. It is not merely a correlate of Y, and it is not a control variable used to soak up nuisance variance. The defining feature is that changing X changes the mediator, and changing the mediator changes Y.

TipWhy mechanism matters

Two programmes with the same bottom-line lift can work through very different paths. One may move attitude; another may move habit. Mediation analysis separates these stories and tells the business which lever actually carries the effect.

TipFrom correlation to explanation

The most useful findings rarely take the form X is correlated with Y. They take the form X moves Y through M. That distinction is what mediation analysis exists to surface: it converts an association into a story about mechanism, and a story about mechanism is what tells the business which lever to pull.

17.2 The Mediation Model

A simple mediation model has three variables and three coefficients: an a path from X to the mediator M, a b path from M to the outcome Y, and a direct c-prime path from X to Y that remains once M is held fixed. The product a times b is the indirect effect; c-prime is the direct effect; their sum is the total effect c (Baron and Kenny 1986; MacKinnon 2008).

flowchart LR
    X((X)) -- a --> M((M))
    M -- b --> Y((Y))
    X -- "c-prime" --> Y
    X -. "total c = c-prime + a b" .-> Y
    classDef default fill:#004466,color:#ffffff,stroke:#ffcc00,stroke-width:3px,rx:10px,ry:10px;

Mediation path diagram showing direct and indirect effects from X to Y through mediator M
Figure 17.1: Mediation: X affects Y both directly (c-prime) and indirectly through M (the a · b path).
WarningThe path diagram is a causal claim

Reading the arrows as causal requires that X temporally precedes M, M temporally precedes Y, and no unmeasured variable drives both M and Y. Without that warrant the arithmetic still runs, but the interpretation does not.

17.3 Baron and Kenny’s Four Steps

Baron and Kenny (1986) set out a four-step screening procedure:

  1. X predicts Y,
  2. X predicts M,
  3. M predicts Y with X held fixed,
  4. the X to Y path is smaller when M is in the model.

The steps are no longer required by modern guidelines, but they still give the clearest picture of the three fits the analysis rests on.

NoteWhat the four steps show together

The total effect c is the regression of Y on X alone. The a path comes from regressing M on X. The b path and the direct effect c-prime come from a single regression of Y on both X and M. When M truly mediates, c-prime is smaller in magnitude than c.

17.4 Direct, Indirect, and Total Effects

The indirect effect is a times b. The direct effect is c-prime. Their sum equals the total effect c. This product-of-coefficients decomposition is the quantity modern mediation analyses report, independent of whether the four Baron-Kenny screens all pass.

TipProportion mediated

Dividing the indirect effect by the total effect expresses the share of X’s influence on Y that travels through M. A value near 1 says M carries almost all of the effect; a value near 0 says it carries little.

17.5 The Sobel Test

Sobel (1982) proposed a delta-method standard error for the product a times b, which gives a z-statistic and a normal-theory p-value. It is still reported in older work but assumes that the sampling distribution of a*b is symmetric, which is rarely true in finite samples.

WarningSobel is conservative and symmetric

The product of two normal variables is not normal, so the Sobel test tends to underpower the detection of genuine indirect effects in small samples. Bootstrap CIs replace it in modern practice.

17.6 Bootstrap Confidence Intervals

Preacher and Hayes (2004) proposed resampling the data with replacement, refitting the two regressions each time, and reading the percentile interval off the resulting distribution of a*b. The interval makes no symmetry assumption and has become the standard for inference on the indirect effect.

NoteTwo thousand replicates is a reasonable minimum

Two thousand replicates is enough for a stable percentile interval on indirect effects; bias-corrected and accelerated (BCa) intervals become worth the extra cost when the bootstrap distribution is markedly skewed.

17.7 Full versus Partial Mediation

When c-prime is close to zero, the labelling tradition calls M a full mediator; otherwise it is partial. Modern treatments (Hayes 2017) avoid these labels because whether c-prime is statistically distinguishable from zero depends heavily on sample size, and a small direct effect can flip the label without any change in the underlying mechanism.

TipReport the decomposition, not the label

Readers gain more from seeing a*b and c-prime side by side than from a binary full-or-partial verdict. The decomposition is comparable across studies; the label is not.

17.8 Assumptions and Pitfalls

Mediation analysis rests on three assumptions that the arithmetic cannot check: temporal ordering (X precedes M precedes Y), no reverse causation, and no unmeasured confounder of the M to Y relationship. The third is the most common failure mode; the demo shows how a hidden confounder can manufacture an indirect effect that is not really there.

WarningCorrelation on the M to Y edge is not a causal arrow

When the data above are analysed without U, the b coefficient picks up the U-M-Y correlation and makes a*b look nonzero. No resampling fixes this: it is a design problem, not a computation problem. Sensitivity analysis, instrumental variables, or randomisation of M are the standard remedies (MacKinnon 2008).

TipWhat a disciplined mediation analysis looks like

A defensible mediation has five properties: (1) M is pre-specified from theory, not picked because it happened to mediate; (2) the temporal ordering of X, M, and Y is plausible in the data design; (3) the indirect effect a*b is reported with a bootstrap interval, not just a Sobel z-test; (4) the proportion mediated is reported alongside the raw indirect effect; (5) the no-confounding-of-M-and-Y assumption is acknowledged, ideally with a sensitivity check. A finding that meets all five is one the business can act on; a finding that misses two or more is a pattern to investigate further before committing to a lever.

17.9 Parallel Multiple Mediators

When two plausible mediators are proposed (for example attitude and awareness), both are fit together so that each a*b captures the unique pathway, controlling for the other.

NoteEach mediator carries its own story

Reporting the two indirect effects separately lets the business see whether attitude and awareness both carry the campaign, or whether only one of them is doing the work.

17.10 Mediation with Categorical Predictors

When X is categorical (treatment versus control, exposed versus unexposed), dummy coding turns it into a zero-or-one indicator. The mediation arithmetic is unchanged; the a, b, and c-prime coefficients are simply group-contrasts on the original response scales.

TipGroup contrasts retain their mediation meaning

The a path is the difference in the mediator between treatment and control. The b path is the mediator slope on the outcome. Their product is the indirect effect on the outcome scale, expressed per one-unit (control-to-treatment) move in X.

17.11 Reporting a Mediation Analysis

A mediation report uses a six-section skeleton that maps onto the Chapter 11 to 16 structure and adds a decomposition of the total effect.

TipSix-section mediation report
  1. Question and proposed mechanism (X, M, Y, and the hypothesised path), (2) sample, measurement, and temporal ordering, (3) fit table for the a path and for the Y regression, (4) decomposition of the total effect into direct and indirect parts with bootstrap CI, (5) sensitivity check or confounder discussion, (6) business decision and the lever the mechanism implies. Keeping this skeleton aligned with the Chapter 11 to 16 reports makes inferential, predictive, and mechanistic studies directly comparable.

Summary

Concept Description
Concept
What Mediation Is A mediator carries an effect from cause to outcome
Path Diagram Visual representation of the causal chain X -> M -> Y
Baron-Kenny Steps Four steps to test mediation in a regression framework
Effects and Tests
Direct Effect X -> Y holding M constant
Indirect Effect X -> M -> Y, computed as a*b
Total Effect Direct + indirect, the unconditional effect of X on Y
Sobel Test Tests indirect effect significance assuming normality
Bootstrap Confidence Intervals Resampling-based CIs preferred over Sobel for small samples