estimate: Estimate a Mediation Model

View source: R/estimators.R

estimateR Documentation

Estimate a Mediation Model

Description

estimate provides a unified interface to estimate all the models that can be encapsulated within a multimedia class. It simply calls the multimedia object. The resulting estimates can be used for downstream direct effect estimation.

Usage

estimate(model, exper)

Arguments

model

An object of class multimedia containing the estimated mediation and outcome models whose mediation and outcome predictions we want to compare.

exper

An object of class multimedia_data containing the mediation and outcome data from which the direct effects are to be estimated.

Value

A version of the input modified in place so that the @estimates slot has been filled.

Examples

exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
multimedia(exper) |>
    estimate(exper)

# example with another dataset
exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
multimedia(exper) |>
    estimate(exper)

# example with another model
exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
multimedia(exper, glmnet_model()) |>
    estimate(exper)

multimedia documentation built on Sept. 30, 2024, 9:28 a.m.