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 explain the relationship between and ?
- is the independent variable (predictor)
- is the mediator (intervening variable)
- is the dependent variable (outcome)
Classic Mediation Model (X → M → Y)
Path Coefficients
Drag the coefficients to reshape the model in real time:
| Path | Coefficient | Interpretation |
|---|---|---|
| Effect of on | ||
| Effect of on (controlling for ) | ||
| Direct effect of on |
Understanding Effects
Direct Effect ()
The direct effect is the relationship that bypasses the mediator:
Indirect Effect ()
The indirect effect travels through :
Total Effect ()
The total effect combines both pathways:
Direct vs Indirect Effects
Types of Mediation
Partial Mediation: Both direct (
Proportion Mediated
When the total effect is non-zero, the share flowing through the mediator is:
Currently,
Statistical Testing
Testing whether the indirect effect differs from zero:
- Sobel Test -- where
- Bootstrap CIs -- resample the data to build confidence intervals for (preferred modern approach)
- 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:
| Scenario | |||
|---|---|---|---|
| Full mediation |
Set , , for full mediation. Set , , for partial mediation. Set for no mediation. Set , , for inconsistent mediation (suppression).
Direct vs Indirect Effects
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
Activation Functions in Neural Networks
Compare different neural network activation functions and understand their properties
Backpropagation
Step through the forward and backward passes of a 2-layer neural network to see how gradients flow and weights update
The Bias-Variance Tradeoff
Understand how model complexity affects underfitting, overfitting, and generalization error
Classification Metrics and Confusion Matrices
Learn how to evaluate classification models using confusion matrices and key metrics like precision, recall, and F1 score
You might also like
Activation Functions in Neural Networks
ExplorationCompare different neural network activation functions and understand their properties
Backpropagation
ExplorationStep through the forward and backward passes of a 2-layer neural network to see how gradients flow and weights update
Classification Metrics and Confusion Matrices
ExplorationLearn how to evaluate classification models using confusion matrices and key metrics like precision, recall, and F1 score
Cross-Entropy Loss
ExplorationUnderstand binary and categorical cross-entropy loss functions and their relationship to maximum likelihood estimation