Path Analysis & Structural Equation Modeling

Visualize causal relationships and test structural models

Path Analysis & Structural Equation Modeling

Path analysis extends multiple regression to test complex causal models involving multiple relationships simultaneously. It is the foundation for Structural Equation Modeling (SEM), which adds latent (unobserved) variables.

The Classic Mediation Model

The most common path model is the mediation model: Does variable MM explain the relationship between XX and YY?

  • XX is the independent variable (predictor)
  • MM is the mediator (intervening variable)
  • YY is the dependent variable (outcome)

Classic Mediation Model (X → M → Y)

0.500.400.20XMYeeeObservedLatent

Path Coefficients

Drag the coefficients to reshape the model in real time:

PathCoefficientInterpretation
X→MX \to M0.5Effect of XX on MM
M→YM \to Y0.4Effect of MM on YY (controlling for XX)
X→YX \to Y0.2Direct effect of XX on YY

Understanding Effects

Direct Effect (c′c')

The direct effect is the X→YX \to Y relationship that bypasses the mediator:

c′=0c' = {\cmv{computed}{c_prime_path}}

Indirect Effect (a×ba \times b)

The indirect effect travels through MM:

Indirect=a×b=0×0=0\text{Indirect} = a \times b = {\cmv{computed}{a_path}} \times {\cmv{computed}{b_path}} = {\cmv{computed}{indirect_effect}}

Total Effect (cc)

The total effect combines both pathways:

c=c′+(a×b)=0+0=0c = c' + (a \times b) = {\cmv{computed}{c_prime_path}} + {\cmv{computed}{indirect_effect}} = {\cmv{computed}{total_effect}}

Direct vs Indirect Effects

Direct Effect(c')IndirectEffect (a×b)Total Effect(c)-1-0.500.510.2000.2000.400

Types of Mediation

Partial Mediation: Both direct (0.200) and indirect (0.200) effects are substantial. XX affects YY both directly and through MM.

Proportion Mediated

When the total effect is non-zero, the share flowing through the mediator is:

PM=a×bc′+(a×b)=00=0PM = \frac{a \times b}{c' + (a \times b)} = \frac{{\cmv{computed}{indirect_effect}}}{{\cmv{computed}{total_effect}}} = {\cmv{computed}{proportion_mediated_display}}

Currently, 50% of the total effect is mediated through MM. The proportion only reads as a share when c′c' and a×ba \times b have the same sign: with opposite signs (inconsistent mediation) it falls below 0% or rises above 100%, and researchers report the two effects separately instead.

Statistical Testing

Testing whether the indirect effect differs from zero:

  1. Sobel Test -- z=a×bSEabz = \frac{a \times b}{SE_{ab}} where SEab≈a2⋅SEb2+b2⋅SEa2SE_{ab} \approx \sqrt{a^2 \cdot SE_b^2 + b^2 \cdot SE_a^2}
  2. Bootstrap CIs -- resample the data to build confidence intervals for a×ba \times b (preferred modern approach)
  3. Monte Carlo method -- simulate the sampling distribution of the indirect effect

From Path Analysis to Full SEM

Path analysis uses only observed variables (rectangles). SEM extends it with:

  • Latent variables (ellipses) -- unobserved constructs measured by multiple indicators
  • Measurement models -- how indicators relate to latent constructs
  • Structural models -- relationships among latent variables

Experiment

Try these configurations and watch the diagrams update:

Scenarioaabbc′c'
Full mediation0.50.40.2

Set a=0.5a = 0.5, b=0.5b = 0.5, c′=0c' = 0 for full mediation. Set a=0.4a = 0.4, b=0.4b = 0.4, c′=0.3c' = 0.3 for partial mediation. Set a=0a = 0 for no mediation. Set a=0.5a = 0.5, b=0.5b = 0.5, c′=−0.5c' = -0.5 for inconsistent mediation (suppression).

Direct vs Indirect Effects

Direct Effect(c')IndirectEffect (a×b)Total Effect(c)-1-0.500.510.2000.2000.400

Try it in Code

import math

a = 0.5       # X -> M
b = 0.4       # M -> Y
c_prime = 0.2  # X -> Y (direct)

indirect = a * b
total = c_prime + indirect
prop_mediated = indirect / total if abs(total) > 0.001 else float('nan')

print(f"Direct effect (c'):   {c_prime:.3f}")
print(f"Indirect effect (ab): {indirect:.3f}")
print(f"Total effect (c):     {total:.3f}")
print(f"Proportion mediated:  {prop_mediated*100:.1f}%")

# Sobel test (approximate)
se_a, se_b = 0.1, 0.1
sobel_se = math.sqrt(a**2 * se_b**2 + b**2 * se_a**2)
z = indirect / sobel_se if sobel_se > 0.001 else 0
print(f"Sobel z = {z:.3f}")

What to explore next

You might also like