Differences between revisions 2 and 3
Revision 2 as of 2025-05-15 15:46:45
Size: 2191
Comment: Clarification
Revision 3 as of 2026-02-17 15:42:31
Size: 1907
Comment: Rewrite
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
'''Mediation analysis''' is a decomposition of causal effects based on a mediator variable.

Note that there is a difference between '''mediation''' and '''moderation'''. The latter deals with how a causal link differs across levels of a moderating variable.
'''Mediation analysis''' is a decomposition of causal effects with [[Statistics/Mediator|mediation]].
Line 13: Line 11:
== Description == == Background ==
Line 15: Line 13:
In circumstances where a significant relationship has been found between an independent and dependent variable, but no causal mechanism has been identified, it is possible to propose hypotheses that a third '''mediator variable''' completes the causal model. [[Statistics/Mediator|Mediation]] looks like the following diagram.
Line 19: Line 17:
The effects pictured are: where the true causal effects are as follows:
Line 27: Line 25:
This can be estimated with the [[Statistics/SobelTest|Sobel test]], but best practice is to use a bootstrapping method.
Line 33: Line 29:
== Example == == Description ==
Line 35: Line 31:
The [[Statistics/SobelTest|Sobel test]] approach, using the [[R/Multilevel|multilevel package]]: === Sobel Test ===

The [[Statistics/SobelTest|Sobel test]] is a common approach for identifying and decomposing the mediated effects.

This example uses
the [[R/Multilevel|multilevel package]]:
Line 49: Line 49:
The bootstrapping approach, using the [[R/Mediation|mediation package]]:

=== Bootstrapping ===

A
bootstrapping approach is more accurate.

This example also
uses the [[R/Mediation|mediation package]]:

Mediation Analysis

Mediation analysis is a decomposition of causal effects with mediation.


Background

Mediation looks like the following diagram.

path.png

where the true causal effects are as follows:

  • direct effect of X on Y = β1

  • direct effect of X on M = β2

  • direct effect of M on Y = β3

  • indirect effect of X on Y = β23

  • total effect of X on Y = β1 + (β23)


Description

Sobel Test

The Sobel test is a common approach for identifying and decomposing the mediated effects.

This example uses the multilevel package:

library(multilevel)

sorel(data$X, data$M, data$Y)

This displays:

  • the component models, including the estimated coefficients and intercepts
  • the indirect effect
  • the pooled standard error
  • the calculated Z statistic

Bootstrapping

A bootstrapping approach is more accurate.

This example also uses the mediation package:

XonY <- lm(Y ~ X, data = data)
XonM <- lm(M ~ X, data = data)
XMonY <- lm(Y ~ X + M, data = data)

library(mediation)

mediate(XonM, XMonY, treat='X', mediator='M', boot=TRUE, sims=500)

This displays:

  • the average causal mediation effects (ACME), the key measure of this bootstrapping method

    • if significantly different than 0, then there is a significant mediation effect

  • the average direct effects (ADE)

  • the total effect
    • total effect = ACME + ADE

  • the proportion of the total effect that was mediated
    • prop = ACME / total effect


CategoryRicottone

Statistics/MediationAnalysis (last edited 2026-02-17 15:42:31 by DominicRicottone)