Skip to main content

How to Run Mediation and Moderation Analysis

Mediation analysis shows HOW or WHY one variable affects another; moderation analysis shows FOR WHOM or UNDER WHICH CONDITIONS that effect gets stronger or weaker. In mediation, the independent variable (X) affects a mediator (M), which in turn affects the outcome (Y); the evidence is the indirect effect — the product of the X→M and M→Y paths — and the current standard is to test it with a bootstrap confidence interval based on at least 5,000 resamples: if the interval excludes zero, the indirect effect is significant. In moderation, you add an interaction term between X and the moderator (W) to the model; when the interaction is significant, you follow it with a simple slopes analysis showing how the effect of X changes across levels of W. Baron and Kenny's four-step approach and the Sobel test are both now considered insufficient — in particular, a significant total effect (path c) is not a prerequisite for mediation.

This guide walks through the steps of both analyses, the decision criteria at each stage, and the points reviewers most often flag. If you're stuck specifying the model or interpreting the output, send us your data: we handle everything from defining the variable roles to choosing the model, bootstrap confidence intervals and simple slope plots, and deliver a path diagram and APA-formatted tables you can paste straight into your thesis or manuscript. The initial review is free.

Who is this guide for?

  • Master's and doctoral students whose hypothesis reads "the mediating role of M in the effect of X on Y"

  • Researchers testing whether a relationship differs by gender, age, experience or another grouping variable

  • Anyone whose advisor said "add a mediation analysis" without saying where to start

  • Authors whose reviewers flagged the Baron-Kenny approach as outdated, or noted that no confidence interval was reported for the indirect effect

  • Researchers who need a moderated mediation model but can't tell which template matches their hypothesis

Mediation or moderation? Which one is your hypothesis?

The two aren't alternatives — they answer different questions. Reading your hypothesis sentence and identifying which question it asks is the fastest way to the right model:

CriterionMediationModeration
Question answeredHow / why does X affect Y?For whom, or under what conditions, is the effect strong or weak?
Role of the variableThe mediator (M) sits in the middle of the chain: X → M → YThe moderator (W) acts on the X→Y arrow itself
Typical hypothesis"Sleep quality mediates the effect of workload on burnout""The effect of workload on burnout differs by level of social support"
Core of the modelThe indirect effect (a × b)The interaction term (X × W)
Significance criterionBootstrap confidence interval excluding zerop-value of the interaction term and ΔR²
Temporal assumptionStrong: X must precede M, and M must precede YNone: the moderator is usually a standing characteristic (gender, trait, context)
Supporting outputPath diagram with a, b, c and c′ coefficientsSimple slopes plot, Johnson-Neyman region

Mediation analysis, step by step

The current standard is not to clear four separate hurdles, but to estimate the indirect effect directly:

  1. 01

    Fix the variable roles theoretically

    Which variable is X (predictor), which is M (mediator) and which is Y (outcome) comes from theory, not from the data. Three variables can be ordered six different ways and statistics cannot tell you which ordering is correct — the justification has to come from the literature and from when each variable was measured.

  2. 02

    Estimate the paths

    The model is two regressions: path a from X to M, and path b from M to Y in a model where X and M both predict Y (X's remaining effect there is path c′). The effect of X on Y with neither M nor Y controlled is the total effect, path c.

  3. 03

    Test the indirect effect with bootstrapping

    The indirect effect is the product a × b, and because its sampling distribution isn't normal, classical tests don't apply. The standard approach is a bias-corrected 95% confidence interval from at least 5,000 bootstrap resamples. If the interval excludes zero, the indirect effect is significant — this is the actual evidence for mediation.

  4. 04

    Don't get stuck on "full vs. partial mediation"

    Historically, a c′ path that dropped to non-significance was called full mediation and one that stayed significant partial mediation. That distinction is largely an artefact of sample size and has been abandoned in the current methodological literature. What belongs in the write-up is the magnitude of the indirect effect and its confidence interval.

  5. 05

    Add an effect size

    A standardised indirect effect, or the ratio of the indirect effect to the total effect, conveys what the finding means in practice. "It was significant" is not, on its own, an adequate statement of result for reviewers.

  6. 06

    Decide whether the model needs to grow

    With more than one mediator, you specify a parallel model (mediators don't affect each other) or a serial one (M1 → M2), where the ordering of mediators is itself a theoretical claim. If the mediation depends on a condition, you move to moderated mediation and test whether the indirect effect differs across levels of the moderator via an index.

Moderation analysis, step by step

Moderation is at heart an interaction test; what matters most is what you do after it comes out significant:

  1. 01

    Centre your continuous variables

    When X and W are continuous, it is standard practice to mean-centre (or standardise) them before forming the interaction term. This reduces multicollinearity between the interaction and the main effects and keeps the lower-order coefficients interpretable; the interaction coefficient itself is unaffected by centring.

  2. 02

    Add the interaction term

    The model is X + W + (X × W). A significant interaction term and the ΔR² it contributes are the evidence for moderation. With the interaction in the model, the coefficients for X and W are conditional effects at the mean level of the other variable — reading them as classical main effects is a mistake.

  3. 03

    Run the simple slopes analysis

    A significant interaction alone is an incomplete finding; the substance is what the effect of X on Y actually is at different levels of the moderator. The conventional approach tests the slope separately at one standard deviation below the mean of W, at the mean, and one standard deviation above.

  4. 04

    Report the Johnson-Neyman region where it helps

    The ±1 SD points are arbitrary. The Johnson-Neyman technique identifies the exact value of W at which the effect of X becomes significant — yielding a far more useful statement, such as "the effect of workload on burnout becomes significant once social support falls below 2.8".

  5. 05

    Plot the interaction

    The plot is what makes a moderation finding land with the reader: X on the horizontal axis, Y on the vertical, and two slope lines for low and high levels of the moderator. Nearly every journal expects it.

  6. 06

    Code categorical moderators correctly

    A categorical moderator such as gender is dummy-coded; with more than two categories you need a separate interaction term for each dummy. Splitting a continuous moderator at the median to make it categorical costs statistical power and is not recommended.

Which model number matches your hypothesis?

Mediation and moderation models are commonly referred to by numbered templates (Hayes model numbers). When your advisor says "run Model 4", this is what they mean:

ModelStructureExample hypothesis
Model 1Simple moderation (X × W → Y)The effect varies by level of social support
Model 4Simple mediation (X → M → Y), single or parallel mediatorsSleep quality mediates the effect
Model 6Serial mediation (X → M1 → M2 → Y)The effect runs through stress, which then affects sleep quality
Model 7Moderated mediation — moderator on path aThe effect of X on the mediator differs by gender
Model 8Moderator on both path a and the direct effectThe moderator conditions both the mediator and the remaining direct effect
Model 14Moderator on path bThe mediator's effect on the outcome varies by condition

Common mistakes

  • Relying on Baron and Kenny's four-step approach alone — it never tests the indirect effect directly, so it is no longer the standard; a bootstrap confidence interval is expected

  • Leaning on the Sobel test, which assumes the indirect effect is normally distributed and is underpowered, especially in small samples

  • Abandoning the mediation analysis because the total effect (path c) wasn't significant — significance of c is not a prerequisite; opposing indirect paths can cancel out and pull the total effect toward zero

  • Presenting a mediation model built on cross-sectional data as causal evidence; mediation is a temporal claim theoretically, and the model does not establish it

  • Measuring X, M and Y in the same questionnaire at the same moment while assuming the mediator precedes the outcome — this belongs in the limitations, stated plainly

  • Stopping once the interaction term is significant; a moderation finding cannot be interpreted without simple slopes and a plot

  • "Showing" moderation by splitting the sample into groups and computing a separate correlation in each — one correlation being significant and the other not does not mean the two differ significantly

  • Median-splitting a continuous moderator into categories, which throws away information and statistical power

  • Running a mediation model on a small sample (say 60-80 respondents) and reporting a non-significant indirect effect as "there is no mediation"; detecting an indirect effect takes a larger sample than detecting a direct one

  • Reporting the path coefficients but never giving a confidence interval for the indirect effect — the single most common omission reviewers ask about

Sample size and causality: the honest framing

Mediation models need more participants than a simple group comparison, because what's being tested is the product of two coefficients and its standard error carries the uncertainty of both paths. In practice, 150-200 respondents is reasonable for medium-sized paths, and 300 or more may be needed when one path is weak. In moderation analysis, interaction terms are systematically detected with less power than main effects, so a non-significant interaction usually means "not enough power" rather than "no effect". If you're still at the planning stage, we can run a power analysis specific to your model — see our sample size calculation page.

On causality, being honest doesn't weaken your study — it strengthens it. A mediation model carries the claim that X leads to Y through M; but if all three variables were measured at the same moment in a single questionnaire, statistics cannot verify that ordering. The right move is to present the finding as a pattern consistent with theory and to state the design limitation explicitly in the discussion. If you do have experimental or longitudinal data, the opposite applies — foreground it. We write that distinction into the report for you and keep the claim at the level your data can carry; it is precisely the point reviewers press hardest.

Frequently asked questions

What is the difference between mediation and moderation?

Mediation explains the mechanism through which an effect operates: X affects the mediator (M), which in turn affects the outcome (Y) — it answers "how" or "why". Moderation shows for whom, or under what conditions, the effect gets stronger or weaker; the moderator isn't a link in the chain but a condition that changes the strength of the X→Y relationship. The practical distinction: a mediator theoretically comes AFTER X, whereas a moderator is usually a characteristic that was already there (gender, a personality trait, the context).

Are the Baron-Kenny method and the Sobel test still valid?

They remain useful as a conceptual frame but are considered insufficient as a decision procedure. The core problem with the four-step approach is that it never tests the indirect effect directly and turns the significance of the total effect into an unnecessary prerequisite. The Sobel test assumes the indirect effect is normally distributed, whereas the product of two coefficients is skewed — leaving the test underpowered, particularly in small samples. The current standard is a bias-corrected 95% confidence interval for the indirect effect from at least 5,000 bootstrap resamples.

Can I run mediation if the total effect isn't significant?

Yes. A significant total effect between X and Y (path c) is not a prerequisite for mediation — that belief is a leftover from the old four-step approach. Two indirect paths running in opposite directions can cancel each other out, or the sample may simply lack the power to detect the total effect; in both cases a significant indirect effect can still be present, and it is a valid finding. The decisive criterion is whether the bootstrap confidence interval for the indirect effect excludes zero.

Do you use the PROCESS macro or AMOS?

No — we run the analyses on our own Python-based stack. The results are identical to what you'd get from those tools: the structures behind the same model numbers (simple mediation, serial mediation, moderated mediation), the same path coefficients, bias-corrected bootstrap confidence intervals, simple slopes and Johnson-Neyman output, a path diagram and APA-formatted tables. You don't need a licence for any program, and SPSS-compatible reporting is available too.

How large a sample does mediation analysis need?

Detecting an indirect effect takes more participants than detecting a direct one, because the quantity tested is the product of two coefficients and the uncertainty compounds. For medium-sized paths, 150-200 respondents is usually enough; if one path is weak, 300 or more may be required. In moderation analysis, interaction terms are detected with less power — so a non-significant interaction often means "not enough power" rather than "no effect". We can run a power analysis specific to your model before you start collecting data.

Can mediation be tested with cross-sectional data?

It can, and it is common in the literature — but the strength of the claim has to match the data. When X, M and Y are all collected at a single time point, statistics cannot verify the assumption that M precedes Y; the model assumes that ordering rather than testing it. The right approach is to present the result as a pattern consistent with theory and to state the design limitation explicitly in the discussion. We write that framing into the report for you — it's the point reviewers press hardest, and having it there in advance strengthens the paper rather than weakening it.

Let us build your mediation or moderation model

Send us your dataset and your hypothesis; we'll settle the variable roles with you, specify the model, and deliver the path diagram and APA tables — with bootstrap confidence intervals and simple slope plots — ready to paste into your thesis or manuscript. The initial review is free.

Last updated: August 5, 2026