All examples for Mediation & Moderation Analysis Guide

Python-Only Mediation: Feedback → Skills → Confidence

Python-specific mediation analysis with complete worked example showing bootstrap confidence intervals and APA-ready results table.

Input

What you provide to the skill

I want to test if feedback improves skills then confidence in Python, not SPSS or R.

Output

What the skill generates for you

======================================================================
MEDIATION ANALYSIS: Feedback → Skills → Confidence

CONCEPTUAL MODEL (PROCESS Model 4):

Skills
↗ ↘
a b
↗ ↘

Feedback ─────c’─────→ Confidence

Where:
a path = Feedback → Skills
b path = Skills → Confidence (controlling for Feedback)
c’ path = Direct effect of Feedback on Confidence
Indirect effect = a × b (the mediation effect)

======================================================================

DETAILED PATH COEFFICIENTS:

Path a (Feedback → Skills):
b = 0.5828, SE = 0.0594, t = 9.8113, p = 0.0000

Path b (Skills → Confidence, controlling for Feedback):
b = 0.5346, SE = 0.0766, t = 6.9821, p = 0.0000

Direct Effect c’ (Feedback → Confidence, controlling for Skills):
b = 0.2563, SE = 0.0711, t = 3.6053, p = 0.0004

Total Effect c (Feedback → Confidence, without mediator):
b = 0.5679, SE = 0.0636, t = 8.9235, p = 0.0000

======================================================================
BOOTSTRAP INDIRECT EFFECT (5000 samples):

Indirect Effect (a × b):
Point estimate = 0.3112
95% Bootstrap CI = [0.2113, 0.4186]

✓ SIGNIFICANT MEDIATION: Bootstrap CI does not include zero
Interpretation: Skills significantly mediates the effect of
Feedback on Confidence.

Proportion of total effect mediated: 54.8%

======================================================================

APA-FORMATTED RESULTS:

To test whether Skills mediated the relationship between Feedback and
Confidence, we conducted a mediation analysis using Hayes’ PROCESS Model 4
approach with 5,000 bootstrap samples.

Results indicated that Feedback significantly predicted Skills
(a = 0.583, SE = 0.059, t = 9.81, p < .001). Skills
significantly predicted Confidence controlling for Feedback
(b = 0.535, SE = 0.077, t = 6.98, p < .001). The direct
effect of Feedback on Confidence was significant
(c’ = 0.256, SE = 0.071, t = 3.61, p < .001).

Critically, the indirect effect through Skills was significant
(ab = 0.311, 95% CI [0.211, 0.419]), supporting
partial mediation. The proportion of the total
effect mediated was 54.8%.

======================================================================

SUMMARY TABLE:

Effect | b | SE | t | p

Path a (Feedback→Skills) | 0.583 | 0.059 | 9.81 | 0.000
Path b (Skills→Conf) | 0.535 | 0.077 | 6.98 | 0.000
Direct effect (c’) | 0.256 | 0.071 | 3.61 | 0.000
Total effect (c) | 0.568 | 0.064 | 8.92 | 0.000
Indirect (a×b) | 0.311 | 95% CI [0.211, 0.419]

======================================================================

TO USE WITH YOUR DATA:

  1. Replace the simulated data section with:
    import pandas as pd
    df = pd.read_csv(‘your_data_file.csv’)
    feedback = df[‘Feedback’].values
    skills = df[‘Skills’].values
    confidence = df[‘Confidence’].values

  2. Ensure your CSV has three columns:

    • Feedback (independent variable X)
    • Skills (mediator M)
    • Confidence (dependent variable Y)

======================================================================

REQUIRED PACKAGES:

Minimal dependencies:

  • numpy
  • scipy

Install with:
pip install numpy scipy

======================================================================