Standard regression models tell you if an independent variable (X) is associated with an outcome variable (Y). However, in many scientific and analytical settings, knowing that a relationship exists isn’t enough — you need to uncover the underlying process driving that relationship. Mediation Analysis allows researchers to test whether the effect of X on Y is transmitted through an intermediate variable, called a mediator (M).
By decomposing a total statistical effect into direct and indirect pathways, mediation analysis turns simple correlations into explanatory causal models.
1. The Baron & Kenny Framework
Historically, linear mediation relies on estimating three regression equations:
- Path c (Total Effect): Y = i₁ + cX + e₁ (X predicts Y directly).
- Path a: M = i₂ + aX + e₂ (X predicts the mediator M).
- Path b & c’ (Direct Effect): Y = i₃ + c’X + bM + e₃ (X and M predict Y together).
The Indirect Effect (the portion transmitted through M) is calculated as a × b, or equivalently c — c’.
2. Types of Mediation
Mediation TypeStatistical PatternInterpretationFull MediationIndirect effect (a×b) is significant; Direct effect (c’) drops to non-significance.The mediator fully accounts for the relationship between X and Y.Partial MediationBoth indirect effect (a×b) and direct effect (c’) remain significant.M explains part of the relationship, but other unmeasured pathways exist.Inconsistent / CompetitiveDirect (c’) and indirect (a×b) effects have opposite signs.The mediator acts as a suppressor variable masking the true net effect.
3. Testing Significance: The Sobel Test vs. Bootstrapping
While the traditional Sobel Test assumes the indirect effect product (a×b) follows a normal distribution, this assumption often breaks down in finite sample sizes. Modern statistical practice strongly favors bootstrapping — a non-parametric resampling technique that generates empirical confidence intervals for the indirect effect without distributional assumptions.
4. Quick Implementation Example (Python using statsmodels & pingouin)
Here is how to run a complete mediation model with bootstrapped confidence intervals in Python:
import pingouin as pgimport pandas as pd# Load or prepare your dataset (columns: 'X_treatment', 'M_mediator', 'Y_outcome')# df = pd.read_csv("data.csv")# Perform mediation analysis with 1000 bootstrap resamplesmediation_results = pg.mediation_analysis( data=df, x='X_treatment', m='M_mediator', y='Y_outcome', alpha=0.05, n_boot=1000)print(mediation_results)
Mediation analysis elevates predictive modeling into mechanistic explanation. By quantifying the indirect pathway (a×b) alongside the direct pathway (c’), you gain a precise statistical breakdown of the exact channels through which your treatment or independent variable operates.
No comments:
Post a Comment