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.

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

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).

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.

17.12 Summary

Summary of mediation-analysis tools introduced in this chapter
Concept Description
Concept and Model
What a mediator is A variable on the causal path from cause to outcome, not a mere covariate
X to M to Y path model Three coefficients: a (X to M), b (M to Y), c-prime (X to Y holding M)
Total = direct + indirect c = c-prime + a*b; the product-of-coefficients decomposition
Classical Tests
Baron and Kenny four steps Classical screening: Y~X, M~X, Y~X+M; now supplementary to modern inference
Sobel z-test Delta-method SE on a*b with a normal-theory p-value; symmetric and conservative
Full vs partial labels Labels based on whether c-prime is near zero; fragile and sample-size dependent
Modern Inference
Product-of-coefficients Report the a*b estimate directly, not a yes-or-no mediation verdict
Bootstrap percentile CI Resample rows, refit two regressions, read the 2.5 and 97.5 percentiles
Replicates and BCa Two thousand replicates for percentile; BCa when the distribution is skewed
Extensions
Parallel multiple mediators Fit Y on X plus all mediators; each a*b is a unique pathway
Categorical predictor Dummy-code X; a, b, and c-prime interpret as group contrasts
Unmeasured confounder sensitivity Hidden drivers of M and Y bias a*b; design and sensitivity analysis, not bootstrap, address this
Reporting
Six-section mediation report Question, design, fits, decomposition, sensitivity, business decision
Proportion mediated a*b / (c-prime + a*b); share of total effect carried by the mediator