augment.robmedfit: Augment data with fitted values from a robmedfit object...

View source: R/broom_methods.R

augment.robmedfitR Documentation

Augment data with fitted values from a robmedfit object (broom-compatible)

Description

Returns the original data augmented with IPW weights, fitted mediator values, and fitted outcome values from the pathway models.

Usage

## S3 method for class 'robmedfit'
augment(x, data = NULL, ...)

Arguments

x

A robmedfit object.

data

Optional data frame to augment. Defaults to the data stored in the outcome model's ⁠$data⁠ slot.

...

Ignored.

Value

The original data frame with additional columns:

.ipw_weight

Stabilised inverse probability weights.

.fitted_mediator

Predicted mediator values.

.fitted_outcome

Predicted outcome values.

.resid_mediator

Residuals from the mediator model.

.resid_outcome

Residuals from the outcome model.

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
)
aug <- augment(fit)
hist(aug$.ipw_weight)



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