Concept map / Path analysis and mediation

Share

Path analysis and mediation

Fit a mediation model X → M → Y with a direct path, split the total effect into direct and indirect parts, and compare Sobel and bootstrap intervals for the indirect effect.

Prerequisites CFA model fit, Regression

1Does X act on Y through M?

A tutoring program (X) may raise test scores (Y) partly because it raises study time (M). Path analysis writes that idea as two regressions: M on X with slope a, and Y on X and M with slopes c′ and b. The part of X’s effect that runs through M is the indirect effect a·b. The rest, c′, is the direct effect, and the two add up to the total effect c. It is the smallest kind of structural equation model, fitted by the same maximum likelihood as a CFA.

Set the true paths and the sample size. The lab simulates the people, fits the model, and puts an interval around a·b. How far can that interval be trusted?

a = 0.40true 0.40b = 0.35true 0.40c′ = 0.14true 0.10XMY
Estimated path, thicker when largerNot significant at .05
Indirect a·b0.13895% bootstrap [0.050, 0.249]
Direct c′0.142p = .246
Total c = c′ + a·b0.281p = .020

The sliders set the true paths. X and the residuals of M and Y each have variance 1.

In this sample of 100, a = 0.40 and b = 0.35, so the indirect effect is a·b = 0.399 × 0.347 = 0.138. The direct effect c′ is 0.142, and the total effect, their sum, is 0.281. The bootstrap interval for a·b excludes zero; the total effect is significant (p = .020).

More controls

Sample 1, the one R draws after set.seed(1). The sliders rescale the same draws.

2No total effect: is there anything to mediate?

A study of 200 people regresses Y on X alone and finds a total effect of 0.07, p = .421. The first of Baron and Kenny's steps stops here. Could the data still show a clear indirect effect of X on Y through M?

3Two intervals for a·b

The indirect effect is a product, and a product of two estimates does not have a normal sampling distribution. The Sobel interval assumes it does. The percentile bootstrap resamples the 100 people 1000 times, refits both regressions each time, and keeps the middle 95% of the products.

0.000.100.200.30Bootstrap estimate of a·b
Bootstrap estimatesBootstrap interval (top)Sobel interval and its normal curveEstimate a·b
Sobel:   a^ b^  ±  1.96 b^2 SEa2+a^2 SEb2\text{Sobel: }\; \htmlClass{term-ind}{\hat a\,\hat b} \;\pm\; 1.96\,\htmlClass{term-se}{\sqrt{\hat b^{2}\,\mathrm{SE}_a^{2} + \hat a^{2}\,\mathrm{SE}_b^{2}}}
Bootstrap:   [ q.025,  q.975 ] of a^∗b^∗ over 1000 resamples\text{Bootstrap: }\; \htmlClass{term-boot}{\big[\,q_{.025},\; q_{.975}\,\big]} \text{ of } \hat a^{*}\hat b^{*} \text{ over 1000 resamples}
Bootstrap: [ q.025,  q.975 ]of a^∗b^∗ over 1000 resamples\begin{aligned}&\text{Bootstrap: } \htmlClass{term-boot}{\big[\,q_{.025},\; q_{.975}\,\big]} \\ &\text{of } \hat a^{*}\hat b^{*} \text{ over 1000 resamples}\end{aligned}

Point at a part of a formula to light up its part of the histogram.

With your numbers: SE = √(0.347² × 0.107² + 0.399² × 0.108²) = 0.0567, so Sobel gives 0.138 ± 1.96 × 0.0567 = [0.027, 0.249]. The bootstrap gives [0.050, 0.249], with the upper arm 1.26 times as long as the other.

When a and b are both well away from zero, the products pile up symmetrically and the two intervals agree. When one path is small relative to its standard error, the products bunch near zero on one side and trail off on the other. The bootstrap interval follows that skew; the Sobel interval cannot, so it reaches too far toward zero and misses real effects more often.

4What “the effect disappears” gets wrong

Baron and Kenny's 1986 steps test mediation by asking whether X predicts Y, then whether the X–Y effect shrinks once M is in the model. With the current sample:

  1. X predicts Y on its own: c = 0.281, p = .020.
  2. X predicts M: a = 0.399, p < .001.
  3. M predicts Y with X held fixed: b = 0.347, p = .001.
  4. The direct effect c′ = 0.142 is not significant, so the steps say full mediation.

Both ends of this recipe can mislead. Step 1 fails whenever c′ and a·b have opposite signs and cancel, as in the prediction above, though M still carries an effect. Step 4 reads a non-significant c′ as a zero c′, which in a small sample it often is not. The modern practice is to estimate a·b and report its bootstrap interval directly.

None of these numbers is a causal effect unless nothing unmeasured drives both M and Y. Randomizing X does not randomize M: a trait that raises both M and Y would inflate b and a·b, and no interval on this page can detect it.

5Check yourself

The tasks use the controls in section 1, including Draw another sample under More controls. They tick themselves when you meet them.

  • Set a true direct effect c′ of 0.20 or more, then find a sample in which the estimated c′ is not significant while the bootstrap interval for a·b excludes zero. Baron and Kenny would call this full mediation.Now: true c′ = 0.10; estimated c′ = 0.14, p = .246; bootstrap interval excludes zero
  • Find a sample in which the bootstrap interval for a·b excludes zero but the Sobel interval does not.Now: bootstrap [0.050, 0.249], Sobel [0.027, 0.249]
  • Make the bootstrap interval lopsided: one arm, from the estimate to an end, at least 1.5 times as long as the other.Now: lower arm 0.088, upper arm 0.111, ratio 1.26

6Fit the mediation model with lavaan

The snippet draws the lab’s starting sample with set.seed(1) and fits it with sem(), labeling the paths so := can define the indirect and total effects. The estimates match the lab: a = 0.399, b = 0.347, a·b = 0.138, c′ = 0.142 with p = .246, and a total of 0.281 with p = .020. lavaan’s default interval for ind, [0.027, 0.249], is the Sobel interval. Its bootstrap interval, [0.049, 0.243], differs a little from the lab’s [0.050, 0.249] because R draws different resamples.

A mediation model with lavaan, delta method and bootstrapShow the code
library(lavaan)
# The lab's starting sample: a = 0.4, b = 0.4, c' = 0.1
set.seed(1)
N <- 100
X <- rnorm(N)
M <- 0.4 * X + rnorm(N)
Y <- 0.1 * X + 0.4 * M + rnorm(N)
d <- data.frame(X, M, Y)

# Label the paths, then define the indirect and total effects
model <- "
  M ~ a * X
  Y ~ cp * X + b * M
  ind := a * b
  total := cp + a * b
"
# Delta-method (Sobel) standard errors
fit <- sem(model, data = d)
pe <- parameterEstimates(fit)
print(pe[pe$label != "", c("label", "est", "se", "pvalue",
                           "ci.lower", "ci.upper")], digits = 3)

# Percentile bootstrap interval from 1000 resamples
fitb <- sem(model, data = d, se = "bootstrap", bootstrap = 1000)
pb <- parameterEstimates(fitb, boot.ci.type = "perc")
print(pb[pb$label == "ind", c("est", "ci.lower", "ci.upper")],
      digits = 3)

Uses lavaan. Install once with install.packages(c("lavaan")).

What a mediation model can and cannot say