Simple Mediation (X→M→Y)

Verified

Mediation (legacy hub)

Independently verified. Every statistic this test reports has been re-derived against an independent reference — never the library the pipeline itself calls — the rendered output was read back in a browser, and the result is locked with a committed regression suite.

Run this test straight away on a free built-in teaching dataset — no data of your own needed — or bring your own. Either opens the guided workspace: variable setup, assumption diagnostics, results with effect sizes and confidence intervals, figures, and APA-ready reporting.

Loading teaching datasets…

Or use your own dataset

Loading your datasets…

Tests whether an independent variable affects an outcome THROUGH a mediator (X → M → Y).

Simple mediation estimates the indirect effect (a × b) of X on Y via one mediator with a bootstrap confidence interval; a significant indirect effect means the mediator carries part of X's influence.

Worked example

Does exercise improve mood by improving sleep?

Exercise (X) → sleep quality (M) → mood (Y) was tested with bootstrapped mediation (5,000 samples, n = 200).

Result

The indirect effect was significant (ab = 0.15, 95% CI [0.06, 0.25]); sleep partially mediated the exercise→mood link.

How you'd report it (APA)

Sleep significantly mediated the effect of exercise on mood, indirect effect = 0.15, 95% CI [0.06, 0.25].

Try it yourself: Load this ready-made sample and follow the run above.

When to use it

  • One mediator, a clear causal order
    You can defend that X precedes M precedes Y in time or logic. e.g. exercise (X) → sleep quality (M) → mood (Y).
  • You want to know the mechanism, not just the effect
    A total X→Y effect is already plausible; the question is how much of it runs through M.
  • Continuous mediator and outcome
    M and Y are both interval-scaled, so ordinary regressions estimate the a and b paths.

When NOT to — use instead

  • The outcome is yes/no
    A binary Y needs logistic paths and an odds/probability-scale indirect effect. Binary-outcome mediation
  • Two or more mediators
    Model them together so each specific indirect effect is adjusted for the others. Parallel mediation
  • The mediators form a chain
    If M1 feeds M2, the sequence is the whole point. Serial mediation
  • The effect depends on a moderator
    If the indirect effect is expected to differ across groups or levels. Moderated mediation

Hypotheses

H₀: a·b = 0 — the indirect effect of X on Y through the mediator M is zero (X does not act on Y via M).
Hₐ: a·b ≠ 0 — the indirect effect is non-zero, so M carries part of X's effect. Inference is by a bootstrap CI, not a p-value: mediation is supported when the 95% CI for a·b excludes 0.

Parameter tested: a·b — the product of the X→M path (a) and the M→Y path (b), estimated with a percentile bootstrap (default 5,000 resamples)

Assumptions (and what to do if they fail)

Correct causal order (X → M → Y)high

Check: Justify from design or theory that X precedes M and M precedes Y — the data alone cannot tell you the direction.

If violated: The indirect effect is uninterpretable; a reversed M and Y can fit equally well. Only a temporal or experimental design settles it.

No unmeasured confounding of M–Yhigh

Check: Ask whether a common cause could drive both the mediator and the outcome. Randomising X does not protect the M–Y link.

If violated: The b path — and so a·b — is biased. Measure and adjust for plausible M–Y confounders, or treat the estimate as associational.

Linear, additive pathsmedium

Check: Inspect residuals of the M and Y regressions for curvature.

If violated: A curved relationship distorts a or b. Transform the variable, or move to a model that allows X×M interaction.

Enough resamples for a stable CIlow

Check: Use ≥ 5,000 bootstrap resamples (the default).

If violated: Too few resamples make the CI endpoints jump between runs; the decision to reject can flip on noise.

Ready to run a Simple Mediation (X→M→Y) on your own data?

Guided setup, automatic assumption checks, effect sizes, figures and an APA write-up.

Run this test →