Learn R Programming

multimedia (version 0.2.0)

estimate: 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)

Value

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

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab