Causal Mediation Analysis with Diagnostics and Sensitivity Analysis

Provides tools for causal mediation analysis with continuous treatments. Estimates natural direct and indirect effects by g-computation over a user-defined treatment grid, with bootstrap intervals that can resample whole clusters, and supports nonlinear dose-response through spline terms in the model formulas. Includes balance diagnostics based on standardized mean differences and stabilized inverse probability weights. Provides sensitivity analysis for confounding of the mediator-outcome relationship using the error correlation parameter of Imai, Keele, and Yamamoto (2010) , and path-wise and indirect-effect robustness values in the partial R-squared metric of Cinelli and Hazlett (2020) , for both joint-significance and Sobel tests of the indirect effect. Additional utilities include visualization of dose-response mediation functions and formatted outputs for applied research.


RobustMediate

Causal mediation analysis for continuous treatments with embedded balance diagnostics, dose-response curves, and sensitivity analysis for mediator-outcome confounding.

What it does

Function What it gives you
robustmediate() Fit treatment / mediator / outcome models, NDE/NIE/TE curves by g-computation with bootstrap CIs, and the sensitivity analysis in one call
plot_balance() Dual love plot: covariate balance before/after weighting for both pathways simultaneously
plot_mediation() Dose-response curves of NDE, NIE, TE with pointwise confidence bands
sensitivity_paths() Robustness values for each path and for the indirect effect under joint-significance and Sobel tests (Cinelli & Hazlett, 2020)
sensitivity_rho() Indirect effect as a function of the mediator-outcome error correlation rho (Imai, Keele & Yamamoto, 2010)
plot_sensitivity() Plot of the indirect effect against rho
diagnose() Formatted report with a paste-ready Results paragraph

Installation

# Development version from GitHub
# install.packages("pak")
pak::pkg_install("subirhait/RobustMediate")

Quick start

library(RobustMediate)

fit <- robustmediate(
  treatment_formula = X ~ Z1 + Z2,
  mediator_formula  = M ~ X + Z1 + Z2,
  outcome_formula   = Y ~ X + M + Z1 + Z2,
  data = mydata,
  R    = 500
)

plot_balance(fit)                        # love plot
plot_mediation(fit)                      # NDE / NIE dose-response curve
plot_sensitivity(fit)                    # indirect effect vs rho
diagnose(fit)                            # paste into Results section

Why this package?

cobalt and WeightIt give balance diagnostics for the treatment model only, and mediation targets binary or categorical treatments. RobustMediate puts balance checks for both pathways, dose-response curves for a continuous treatment, and a sensitivity analysis into one workflow.

References

  • Imai, K., Keele, L., & Yamamoto, T. (2010). Identification, inference and sensitivity analysis for causal mediation effects. Statistical Science, 25(1), 51-71.

Contributing

Bug reports and feature requests via GitHub Issues.

License

MIT

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("RobustMediate")

0.3.1 by Subir Hait, 3 days ago


https://github.com/subirhait/RobustMediate


Report a bug at https://github.com/subirhait/RobustMediate/issues


Browse source code at https://github.com/cran/RobustMediate


Authors: Subir Hait [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports cli, ggplot2, rlang, scales, stats, broom

Suggests covr, dplyr, knitr, lme4, pkgdown, rmarkdown, splines, testthat, tidyr


See at CRAN