The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

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

Contributing

Bug reports and feature requests via GitHub Issues.

License

MIT

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.