About MedModr

Version 1.0 Free & Open Source MIT License

Overview

MedModr (Mediation & Moderation) is a free, browser-based statistical tool for conducting simple mediation, serial mediation, moderation, and moderated mediation (conditional process) analyses.

🔒 Privacy Guarantee

All data processing occurs client-side. No data is sent to any server. You can disconnect from the internet after the page loads and still run complete analyses.

Methodological Framework

MedModr follows the regression-based approach detailed in Hayes (2022) Introduction to Mediation, Moderation, and Conditional Process Analysis. The tool implements Ordinary Least Squares (OLS) regression via matrix algebra, providing both unstandardized (b) and standardized (β) coefficients, bootstrap confidence intervals for indirect effects, and interactive visualizations.

Features & Capabilities

📊
Simple Mediation
X → M → Y with full path coefficients, Sobel test, bootstrap CIs, and interactive path diagram.
🔗
Serial Mediation
X → M1 → M2 → Y with specific indirect paths, total indirect effects, and bootstrapped CIs.
Moderation
X × W → Y with simple slopes at ±1 SD and mean, annotated slopes plot.
🔄
Moderated Mediation
Conditional indirect effects, index of moderated mediation (IMM), bootstrap CIs.
📈
Bootstrap Inference
Percentile bootstrap confidence intervals for all indirect effects (1,000–10,000 samples).
🎨
Interactive Diagrams
Path diagrams with toggle for unstandardized/standardized coefficients, p-values, black/white mode.
📋
APA Reporting
APA-formatted summaries, Word document export, copy-to-clipboard functionality.
🔧
Covariates Support
Unlimited covariates automatically mean-centered in all regression models.

Quick Start Guide

1
Prepare your data

Each variable as one numeric value per line (no header row). All variables must have the same number of rows (N). For multiple variables, enter each variable's data in separate columns (space or comma separated).

2.5 3.2 4.1
4.8 2.1 3.5
3.2 4.5 2.8
5.1 1.9 4.3
3.9 3.8 5.2
2
Select analysis type

Choose from Simple Mediation, Serial Mediation, Moderation, or Moderated Mediation.

3
Enter variable names and data

Provide meaningful names (e.g., "Stress", "Coping", "Wellbeing") and paste your numeric data.

4
Add covariates (optional)

First line = variable names (space separated), subsequent lines = numeric values.

5
Set options & run

Choose confidence level (90%, 95%, 99%), bootstrap samples (None [Sobel only], 1000, 5000, 10000), centering options for moderation models.

6
Interpret results

Review regression tables, path diagrams, simple slopes plots, and APA-formatted summaries. Export to Word or copy results.


Simple Mediation (X → M → Y)

1
Select analysis type

In MedModr, click the Simple Mediation tab (X → M → Y).

2
Enter independent X, mediator M, outcome Y

Provide names and data for independent X, mediator M, and outcome Y. All three variables must have the same number of rows.

3
Add covariates (optional)

Enter control variables in the Covariates box: first line = names (space separated), subsequent lines = numeric values.

4
Set options & run

Choose confidence level (90%, 95%, 99%), bootstrap samples (0, 1000, 5000 or 10000). Click Run Analysis

5
Interpret results

The output includes: a‑path (X→M), b‑path (M→Y), total effect, direct effect, indirect effect (a×b), Sobel test, bootstrap CI, and interactive path diagram.

Mathematical Formulas

a-path (X → M): M = i₁ + a·X + e₁

b-path (M → Y): Y = i₂ + c'·X + b·M + e₂

Total effect (c): Y = i₃ + c·X + e₃
Indirect Effect: IE = a × b

Sobel Standard Error: SE = √(b²·SEₐ² + a²·SE_b²)

Sobel z-test: z = IE / SE

p-value: p = 2 × [1 - Φ(|z|)]
Bootstrap Percentile CI (B = 1,000-10,000):
1. Draw B samples with replacement (size n)
2. For each sample b, compute θ̂ᵦ = aᵦ × bᵦ
3. Sort θ̂(1), θ̂(2), ..., θ̂(B)
4. 95% CI = [θ̂(₀.₀₂₅×B), θ̂(₀.₉₇₅×B)]

Serial Mediation (X → M1 → M2 → Y)

1
Select analysis type

Click the Serial Mediation button (X→M1→M2→Y).

2
Enter independent X, first mediator M1, second mediator M2, outcome Y

Provide names and data for independent X, first mediator M1, second mediator M2, and outcome Y. All four variables must have the same number of rows.

3
Add covariates (optional)

Enter control variables in the Covariates box: first line = names (space separated), subsequent lines = numeric values.

4
Set options & run

Choose confidence level (90%, 95%, 99%), bootstrap samples (0, 1000, 5000 or 10000). Click Run Analysis

5
Interpret results

Results include three specific indirect effects: X→M1→M2→Y (serial), X→M1→Y, X→M2→Y, plus total indirect, direct effect, and bootstrap CIs.

Mathematical Formulas

M1 model: M1 = i₁ + a₁·X + e₁

M2 model: M2 = i₂ + a₂·X + d₂₁·M1 + e₂

Y model: Y = i₃ + c'·X + b₁·M1 + b₂·M2 + e₃
Specific Indirect Effects:
IE₁ (via M1 only) = a₁ × b₁
IE₂ (via M2 only) = a₂ × b₂
IE₃ (serial M1→M2) = a₁ × d₂₁ × b₂

Total Indirect Effect: IEₜₒₜₐₗ = IE₁ + IE₂ + IE₃
📖 Interpretation

If the bootstrap confidence interval does not contain zero, the indirect effect is statistically significant at α = 0.05 (two-tailed). Mediation is supported when the indirect effect is significant, regardless of whether the total effect (c) or direct effect (c') is significant (Hayes, 2022).

📊 Bootstrap Recommendation

Hayes (2009) recommends at least 5,000 bootstrap samples for stable confidence intervals of indirect effects. MedModr offers up to 10,000 bootstrap samples.

Reference: Hayes, A. F. (2009). Beyond Baron and Kenny: Statistical Mediation Analysis in the New Millennium. Communication Monographs, 76, 408-420.

Moderation (X × W → Y)

1
Select analysis type

Click Moderation (X × W → Y).

2
Enter independent X, moderator W, outcome Y

Provide variable names and numeric data for independent X, moderator W, and outcome Y. All three variables must have the same number of rows.

3
Select mean‑centering strategy

Options: Mean Centering (All variables), Mean Centering (Only continuous variables), or No Mean Centering.

4
Run & interpret interaction term

The table shows b₃ (X×W) coefficient with p‑value. If significant, moderation is present. Simple slopes at low (−1 SD), mean, and high (+1 SD) levels of W are displayed together with an annotated slopes plot.

Mathematical Formulas

Moderation Model: Y = i + b₁·X + b₂·W + b₃·(X×W) + e
Simple Slopes at Three Levels of W:
Low (-1 SD): θ = b₁ + b₃ × (W̄ - SD_w)
Mean (0 centered): θ = b₁ + b₃ × W̄
High (+1 SD): θ = b₁ + b₃ × (W̄ + SD_w)

Simple Slope SE: SE(θ) = √[Var(b₁) + W²·Var(b₃) + 2W·Cov(b₁,b₃)]

Mean-Centering Options

  • All variables centered: (X - X̄) × (W - W̄)
  • Continuous-only centered: Center continuous X and W, leave binary (0/1) variables raw
  • No centering: Raw X × Raw W

Moderated Mediation (Conditional Process)

1
Select analysis type

Click Moderated Mediation tab (X → M → Y, with W moderating the a‑path).

2
Enter independent X, mediator M, moderator W, outcome Y

Provide variable names and numeric data for independent X, mediator M, moderator W, and outcome Y. All four variables must have the same number of rows.

3
Select mean‑centering strategy

Options: Mean Centering (All variables), Mean Centering (Only continuous variables), or No Mean Centering.

4
Run & interpret results

Output includes: simple slopes of X→M at three levels of W, conditional indirect effects (a·b) at each level, analytic and bootstrap CIs, and the index of moderated mediation (a₃·b)

Mathematical Formulas

Stage 1 (Moderated a-path): M = i₁ + a₁·X + a₂·W + a₃·(X×W) + e₁

Stage 2 (b-path): Y = i₂ + c'·X + b·M + e₂

Conditional Indirect Effect at level w of W: IE(w) = (a₁ + a₃·w) × b

Index of Moderated Mediation (IMM): IMM = a₃ × b
Conditional Indirect Effects at ±1 SD and Mean:
IE(Mean) = a₁ × b
IE(Low) = (a₁ - a₃·SD_w) × b
IE(High) = (a₁ + a₃·SD_w) × b
📊 Index of Moderated Mediation

The Index of Moderated Mediation (IMM = a₃ × b) quantifies the linear change in the indirect effect as a function of the moderator W. A bootstrap confidence interval that excludes zero indicates statistically significant moderated mediation (Hayes, 2015).

Reference: Hayes, A. F. (2015). An Index and Test of Linear Moderated Mediation. Multivariate Behavioral Research, 50(1), 1-22.


OLS Regression (Matrix Algebra)

All regressions in MedModr are computed using Ordinary Least Squares (OLS) via matrix algebra, the same method used in major statistical software packages.

Coefficients: β = (X'X)⁻¹X'y
Standard Errors: SE(βⱼ) = √[MSE × (X'X)⁻¹ⱼⱼ] where MSE = Σ(yᵢ - ŷᵢ)² / (n - k - 1)
t-Statistic: tⱼ = βⱼ / SE(βⱼ) with df = n - k - 1
Confidence Interval: CI = βⱼ ± t(α/2, df) × SE(βⱼ)
R-squared: R² = 1 - [Σ(yᵢ - ŷᵢ)² / Σ(yᵢ - ȳ)²]
Adjusted R-squared: R²ₐdj = 1 - (1 - R²)(n - 1)/(n - k - 1)
F-Statistic: F = (R²/k) / ((1 - R²)/(n - k - 1)) with df₁ = k, df₂ = n - k - 1

Standardized Coefficients (β)

Every regression table includes both unstandardized b and standardized β. Standardized coefficients are obtained by re‑running the same regression on z‑scored variables (mean = 0, SD = 1).

zₓ = (x - μₓ) / σₓ  |  z_y = (y - μ_y) / σ_y

Then: β = (Zₓ'Zₓ)⁻¹Zₓ'z_y
📖 Interpretation

A one standard deviation change in X produces a β standard deviation change in Y. Standardized coefficients allow direct comparison of effect sizes across predictors measured in different units.

Bootstrap Confidence Intervals

For all indirect effects (simple, serial, conditional, index), MedModr implements the percentile bootstrap method. User‑selectable resamples: 1000, 5000, or 10000.

Step 1: Draw B bootstrap samples by sampling n observations with replacement from original data.

Step 2: For each bootstrap sample b, compute the statistic of interest θ̂ᵦ (e.g., a×b, a₃×b).

Step 3: Sort all B estimates: θ̂(1), θ̂(2), ..., θ̂(B).

Step 4: For 95% CI: lower bound = θ̂(₀.₀₂₅×B), upper bound = θ̂(₀.₉₇₅×B).
📊 Interpretation

If the bootstrap confidence interval (e.g., 95% BootLLCI to BootULCI) does not contain zero, the indirect effect is statistically significant at α = 0.05 (two‑tailed). This method does not assume normality of the sampling distribution — a critical advantage for indirect effects which are often non-normal.

p-value Calculation

MedModr computes exact two-tailed p-values using the cumulative distribution function (CDF) of the t-distribution:

p = 2 × P(T > |t|) where T ~ t(df = n - k - 1)

P(T > t) = 1 - Iₓ(df/2, 1/2) with x = df/(df + t²) and I = regularized incomplete beta function

For indirect effects (when bootstrap is not used), p-values come from the Sobel z-test assuming normality:

p = 2 × [1 - Φ(|z|)] where Φ is the standard normal CDF

Covariate (Control Variable) Handling

All specified covariates C₁, C₂, ..., Cₖ are automatically mean-centered and included in every regression model:

a-path model: M = i₁ + a·X + Σγⱼ·Cⱼ + e₁

b-path model: Y = i₂ + c'·X + b·M + Σδⱼ·Cⱼ + e₂

Total effect model: Y = i₃ + c·X + Σθⱼ·Cⱼ + e₃

Covariates are mean-centered (Cⱼ - C̄ⱼ) to improve interpretability of the intercept and reduce multicollinearity with interaction terms.

📎 Covariates Example
age education_level
25 2
30 3
28 2
45 4
32 3

Path Diagrams

Simple Mediation (X → M → Y)

Simple Mediation Diagram

🔍 Click image to view full size

Serial Mediation (X → M1 → M2 → Y)

Serial Mediation Diagram

🔍 Click image to view full size

Moderation (X × W → Y)

Moderation Diagram

🔍 Click image to view full size

Moderated Mediation (Conditional Process)

Moderated Mediation Diagram

🔍 Click image to view full size

📐
Interactive path diagrams
Click "View full‑screen diagram" to open a modal. Toggle between unstandardized/standardized coefficients, hide/show p‑values, toggle black/white mode, download as PNG.
🎨
Customization Options
• Unstandardized (b) or Standardized (β) coefficients
• Show/Hide p-values
• Black & White mode for publication
• Dotted or solid direct effect line
• Download high-resolution PNG
📖 Diagram Features

All path diagrams automatically wrap long variable names to prevent text overflow. The black & white mode creates publication-ready diagrams suitable for manuscripts.

Simple Slopes Plots

The Simple Slopes Plot is available for Moderation and Moderated Mediation analyses, showing the effect of X on Y (or X on M) at three levels of the moderator W: Low (−1 SD), Mean, and High (+1 SD).

Simple Slopes Plot

For Moderation & Moderated Mediation Analysis

Simple Slopes Plot

🔍 Click image to view full size and toggle between versions

📖 Simple Slopes Features

The simple slopes plot displays separate regression lines for X predicting Y at three conditional values of the moderator W. Toggle between the standard version (no p-values) and the annotated version (with p-values shown on each slope line) using the buttons above the plot or inside the full-screen viewer.


License & Permissions

MIT License

Copyright (c) 2026 Mudasir Mohammed Ibrahim

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
📋 What This Means For You

1. You can download and use MedModr for free, including for commercial purposes.
2. You can modify the source code and create your own versions.
3. You can host MedModr on your own institutional domains or servers.
4. You can include MedModr in your research or teaching materials.
5. You must retain the copyright notice and license in any distributed copies.
️6. The software is provided "as is", without warranty of any kind.

How to Contribute

MedModr is open source and welcomes contributions from the community! Whether you want to fix a bug, add a feature, improve documentation, or translate the interface, your help is appreciated.

Contribution Workflow

  1. Fork the repository on GitHub: https://github.com/shinyhealthtools/medmodr
  2. Clone your fork locally: git clone https://github.com/YOUR_USERNAME/medmodr.git
  3. Create a new branch for your feature: git checkout -b feature/your-feature-name
  4. Make your changes and test them thoroughly
  5. Commit your changes with a clear message: git commit -m "Add: description of your change"
  6. Push to your fork: git push origin feature/your-feature-name
  7. Submit a Pull Request on GitHub describing your changes
🔧 Ways to Contribute

• Report bugs or suggest features by opening an issue on GitHub
• Improve documentation or add examples
• Add new analysis types or visualization options
• Optimize performance for large datasets
• Translate the interface to other languages
• Fix existing bugs or issues


Data Input Format

All data entry is text‑based: one numeric value per line, no header row. Example:

3.4
5.1
2.8
4.2
3.7
4.5
2.1

All variables must have the exact same number of rows (N). Covariates are optional: first line = variable names (space or comma separated), subsequent lines = numeric data.

Binary Variables (Dummy Coding)

⚠️ Important

Manual dummy coding required. MedModr does not automatically convert categorical variables (e.g., gender, treatment group, education level) into dummy codes. All categorical predictors including moderators and covariates must be converted by the user into numeric 0/1 dummy variables before pasting data into the tool. For a categorical variable with k levels, create k−1 dummy variables. The reference group should be coded as 0 on all dummies. Continuous variables can be used as-is and will be automatically mean-centered when appropriate.

Limitations

📐
OLS only — models are based on ordinary least squares regression; no multilevel or SEM.
🔢
Listwise deletion — rows with missing values must be removed before pasting data.
📦
Large N — performance may degrade with N > 5000 due to client-side matrix inversion.
🧩
Manual dummy coding — categorical variables must be converted into 0/1 dummy variables before use.
📊
Sample size recommendations — Simple mediation: n ≥ 50; Serial mediation: n ≥ 100; Moderation: n ≥ 80; Moderated mediation: n ≥ 200.

Citation

Ibrahim, M. M. (2026). MedModr: Mediation and moderation analysis tool1 (Version 1.0) [Software]. https://shinyhealthtools.github.io/medmodr/

References

  • Hayes, A. F. (2022). Introduction to Mediation, Moderation, and Conditional Process Analysis: A Regression-Based Approach (Vol. 3). The Guilford Press.
  • Hayes, A. F. (2015). An Index and Test of Linear Moderated Mediation. Multivariate Behavioral Research, 50(1), 1-22.
  • Hayes, A. F. (2009). Beyond Baron and Kenny: Statistical Mediation Analysis in the New Millennium. Communication Monographs, 76, 408-420.

Developer Information

MI

Mudasir Mohammed Ibrahim

Department of Internal Medicine (M3), Tamale Teaching Hospital, Tamale, Ghana

Contact & Support

📧 Get Help

For bug reports, feature requests, or general inquiries, please email:
mudassiribrahim30@gmail.com

You can also open an issue on GitHub: github.com/shinyhealthtools/medmodr/issues