compare_fits: Compare Two robmedfit Objects Side by Side

View source: R/plot_utils.R

compare_fitsR Documentation

Compare Two robmedfit Objects Side by Side

Description

Overlays the NDE/NIE/TE curves from two robmedfit objects on the same panel. Useful for sensitivity comparisons (e.g. different spline degrees, trimming thresholds, or model specifications).

Usage

compare_fits(
  fit1,
  fit2,
  label1 = "Model 1",
  label2 = "Model 2",
  estimands = c("NDE", "NIE")
)

Arguments

fit1

First robmedfit object.

fit2

Second robmedfit object.

label1

Label for fit1. Default "Model 1".

label2

Label for fit2. Default "Model 2".

estimands

Estimands to display. Default c("NDE","NIE").

Value

A ggplot2 object.

Examples


fit_a <- 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, spline_df = 3, R = 50
)
fit_b <- 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, spline_df = 6, R = 50
)
compare_fits(fit_a, fit_b, label1 = "df=3", label2 = "df=6")



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