Home / Articles / Research & Statistics
Research & Statistics · 6 min read

Mediation and Moderation Analysis Explained

Learn the difference between mediation and moderation, calculate indirect effects, Sobel tests and simple slopes by hand, and report results in APA style.

"Does X affect Y through M?" and "Does the effect of X on Y depend on W?" sound alike, but they are two different research questions. They lead to two different analyses, mediation and moderation. Mixing them up is one of the most common mistakes in MS and PhD theses in management, psychology and education, so this guide separates them clearly and works through each one by hand.

The Core Difference

  • A mediator (M) explains how or why X affects Y. It sits on the causal path: X → M → Y. For example, training raises self-efficacy, which in turn improves job performance.
  • A moderator (W) changes the strength or direction of the X–Y relationship. For example, training improves performance more for employees with high supervisor support.

A quick test: if your hypothesis contains "through", "via" or "because of", you have mediation. If it contains "depends on", "strengthens" or "weakens", you have moderation.

Mediation: The Paths

A simple mediation model has three regressions:

$$ M = i_1 + aX, \qquad Y = i_2 + c'X + bM, \qquad Y = i_3 + cX $$

  • a: the effect of X on M
  • b: the effect of M on Y, controlling for X
  • c′ (direct effect): the effect of X on Y, controlling for M
  • c (total effect): the effect of X on Y ignoring M

For ordinary least squares with one mediator, these always satisfy

$$ c = c' + ab $$

The indirect effect is \( ab \), and this is what mediation analysis tests.

Baron and Kenny vs the Modern Approach

The classic Baron and Kenny (1986) steps required a significant total effect \( c \) before you could test mediation. Modern methodologists, notably Andrew Hayes, recommend testing \( ab \) directly with bootstrap confidence intervals. A significant indirect effect can exist even when \( c \) is not significant. The Sobel test is still reported in some papers, but it assumes \( ab \) is normally distributed, which is rarely true in small samples.

Worked Example 1: Mediation by Hand

A survey of \( n = 120 \) employees measures training hours (X), self-efficacy (M) and job performance (Y). All variables are standardised, and the correlations are:

$$ r_{XM} = 0.50, \qquad r_{YM} = 0.60, \qquad r_{XY} = 0.40 $$

Step 1: Path a. With one predictor, the standardised slope equals the correlation:

$$ a = r_{XM} = 0.50 $$

Step 2: Paths b and c′. With two standardised predictors:

$$ b = \frac{r_{YM} - r_{XY}\,r_{XM}}{1 - r_{XM}^2} = \frac{0.60 - 0.20}{0.75} = 0.533 $$

$$ c' = \frac{r_{XY} - r_{YM}\,r_{XM}}{1 - r_{XM}^2} = \frac{0.40 - 0.30}{0.75} = 0.133 $$

Step 3: Indirect and total effects.

$$ ab = 0.50 \times 0.533 = 0.267, \qquad c = c' + ab = 0.133 + 0.267 = 0.400 = r_{XY} \checkmark $$

So about \( 0.267 / 0.400 = 67\% \) of the total effect passes through self-efficacy.

Step 4: Standard errors. For path a:

$$ SE_a = \sqrt{\frac{1 - a^2}{n - 2}} = \sqrt{\frac{0.75}{118}} = 0.0797 $$

The model predicting Y has \( R^2 = (0.16 + 0.36 - 0.24)/0.75 = 0.373 \), so

$$ SE_b = \sqrt{\frac{1 - R^2}{(n - 3)(1 - r_{XM}^2)}} = \sqrt{\frac{0.627}{117 \times 0.75}} = 0.0845 $$

The direct effect has the same standard error here, giving \( t = 0.133/0.0845 = 1.58 \) and \( p = .117 \), which is not significant.

Step 5: Sobel test.

$$ SE_{ab} = \sqrt{b^2 SE_a^2 + a^2 SE_b^2} = \sqrt{(0.533)^2(0.0797)^2 + (0.50)^2(0.0845)^2} = 0.0599 $$

$$ z = \frac{0.267}{0.0599} = 4.45, \qquad p < .001 $$

In a real thesis you would also report a bootstrap 95% CI for \( ab \), using 5,000 resamples. If the interval excludes zero, the indirect effect is significant.

Interpretation: the indirect effect is significant but the direct effect is not. Older terminology called this "full mediation", but many journals now simply describe it as an indirect-only effect.

APA report: Training had a significant indirect effect on job performance through self-efficacy, ab = 0.27, Sobel z = 4.45, p < .001. The direct effect was not significant, c′ = 0.13, p = .117, and the indirect effect accounted for 67% of the total effect.

Moderation: The Interaction Term

Moderation is tested by adding the product of X and W to a regression:

$$ Y = b_0 + b_1 X + b_2 W + b_3 (X \times W) + \varepsilon $$

A significant \( b_3 \) means W moderates the X–Y relationship. Rearranging shows why:

$$ Y = (b_0 + b_2 W) + (b_1 + b_3 W)\,X $$

The slope of X is \( b_1 + b_3 W \), so it changes with W.

Good practice:

  • Mean-centre X and W before creating the product. This makes \( b_1 \) and \( b_2 \) interpretable as effects at the average of the other variable and reduces non-essential multicollinearity.
  • Report the change in \( R^2 \) (\( \Delta R^2 \)) when you add the interaction term.
  • Probe a significant interaction with simple slopes, usually at the mean and at ±1 SD of W, or with the Johnson–Neyman technique.

Worked Example 2: Simple Slopes

Using mean-centred variables, a study of 150 students predicts exam score (Y) from study hours (X) and parental support (W, SD = 1.5):

$$ \hat{Y} = 60 + 0.50X + 0.30W + 0.20(X \times W) $$

The interaction is significant, \( b_3 = 0.20 \), \( p = .004 \), \( \Delta R^2 = .05 \).

Step 1: Low support (W = −1.5).

$$ \text{slope} = 0.50 + 0.20(-1.5) = 0.50 - 0.30 = 0.20 $$

Step 2: Average support (W = 0).

$$ \text{slope} = 0.50 + 0.20(0) = 0.50 $$

Step 3: High support (W = +1.5).

$$ \text{slope} = 0.50 + 0.20(1.5) = 0.80 $$

Interpretation: each extra study hour is worth 0.8 marks for highly supported students but only 0.2 marks for students with low support. Support strengthens the benefit of studying. Plot these three lines in your results chapter, because examiners love an interaction plot.

Sanity check: the slope at W = 0 equals \( b_1 \). That holds only because W was mean-centred, which is why centring matters.

APA report: Parental support significantly moderated the effect of study hours on exam scores, b = 0.20, p = .004, ΔR² = .05. Simple slopes analysis showed that the effect of study hours was stronger at high support (b = 0.80) than at low support (b = 0.20).

Moderated Mediation and Software

Real models often combine both ideas, for example when an indirect effect is stronger for some groups. Hayes' PROCESS macro is the standard tool here. Model 4 is simple mediation, Model 1 is moderation, and Models 7 and 14 are common moderated-mediation designs.

  • SPSS and SAS: the PROCESS macro, which reports bootstrap CIs automatically.
  • R: the lavaan package for path models, or the mediation package.
  • SmartPLS and AMOS: popular for structural equation models with latent variables.
  • Stata: sem followed by estat teffects.

r library(lavaan) model <- 'M ~ a*X Y ~ c*X + b*M ab := a*b' fit <- sem(model, data = df, se = "bootstrap", bootstrap = 5000)

Did You Know?

  • Baron and Kenny's 1986 paper on mediation and moderation is one of the most cited articles in psychology.
  • Mediation analysis with cross-sectional survey data cannot prove causation. Strong designs measure X, M and Y at different times.
  • A variable can be both a mediator and a moderator in different theories, so your literature review must justify which role it plays.

Key Takeaways

  • Mediation explains how X affects Y (X → M → Y), while moderation explains when or for whom the effect changes.
  • The indirect effect is \( ab \), and \( c = c' + ab \). Test \( ab \) with bootstrap confidence intervals.
  • Moderation is tested with an interaction term \( X \times W \). Mean-centre the predictors and probe with simple slopes.
  • Report coefficients, p-values, confidence intervals and \( \Delta R^2 \) in APA style, and draw an interaction plot.

Need help setting up PROCESS, lavaan or SmartPLS models for your thesis? Amathify's subject experts and PhD scholars can give you step-by-step solutions and analysis support. Contact us on WhatsApp or use the Ask a Question form.

Stuck on a problem or assignment?

Our experts and PhD scholars solve maths, physics and chemistry — step by step.

WhatsApp usAsk a question

Related articles