exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
fit <- multimedia(exper) |>
    estimate(exper)
predict_across(outcome_model(fit), NULL, "outcome_1")
# predict at newdata
newdata <- bind_mediation(exper)
predict_across(
    outcome_model(fit),
    newdata[seq_len(5), ],
    c("outcome_1", "outcome_2")
)
Run the code above in your browser using DataLab