plot_mediation: Dose-Response Curve: Natural Direct and Indirect Effects

View source: R/plot_mediation.R

plot_mediationR Documentation

Dose-Response Curve: Natural Direct and Indirect Effects

Description

Plots NDE, NIE, and (optionally) total effect as smooth spline curves over the full range of treatment values, with pointwise bootstrap confidence bands. This is the signature visualisation of RobustMediate and is publication-ready out of the box.

Usage

plot_mediation(
  x,
  estimands = c("NDE", "NIE"),
  show_total = FALSE,
  facet = FALSE,
  ...
)

Arguments

x

A robmedfit object.

estimands

Character vector of estimands to display. Any subset of c("NDE", "NIE", "TE"). Default c("NDE","NIE").

show_total

Shorthand for adding "TE" to estimands. Default FALSE.

facet

Logical. Split estimands into separate facets? Default FALSE.

...

Ignored.

Value

A ggplot2 object.

Examples


fit <- robustmediate(
  treatment_formula = X ~ Z1 + Z2 + Z3,
  mediator_formula  = M ~ X + Z1 + Z2 + Z3,
  outcome_formula   = Y ~ X + M + Z1 + Z2 + Z3,
  data = sim_mediation, R = 50
)
plot_mediation(fit)
plot_mediation(fit, estimands = c("NDE", "NIE", "TE"), facet = TRUE)



RobustMediate documentation built on April 16, 2026, 5:08 p.m.