Skip to contents

multimedia objects encapsulate the model and data that underlie a mediation analysis, together with metadata (like graph structure) that contextualize the estimation. This function can be used to construct a new multimedia instances from a mediation_data dataset and pair of estimators.

Usage

multimedia(
  mediation_data,
  outcome_estimator = lm_model(),
  mediation_estimator = lm_model()
)

Arguments

mediation_data

An object of class mediation_data, with separate slots for each of the node types in a mediation analysis diagram.

outcome_estimator

An object of class model that will be used to estimate the outcome model.

mediation_estimator

An object of class model that will be used to estimate the mediation model.

Value

An object of class multimedia encapsulating the full mediation model and data.

See also

multimedia-class

Examples

exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
multimedia(exper)
#> [Multimedia Analysis] 
#> Treatments: treatment 
#> Outcomes: PHQ 
#> Mediators: ASV1, ASV2, ... 
#>   
#> [Models] 
#> mediation: An unfitted lm_model(). 
#> outcome: An unfitted lm_model(). 

exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
multimedia(exper)
#> [Multimedia Analysis] 
#> Treatments: treatment 
#> Outcomes: outcome_1, outcome_2 
#> Mediators: mediator 
#>   
#> [Models] 
#> mediation: An unfitted lm_model(). 
#> outcome: An unfitted lm_model(). 

# real data example with a pretreatment variable
data(mindfulness)
exper <- mediation_data(
    mindfulness,
    phyloseq::taxa_names(mindfulness),
    "treatment",
    starts_with("mediator"),
    "subject"
)
multimedia(exper)
#> [Multimedia Analysis] 
#> Treatments: treatment 
#> Outcomes: Acetanaerobacterium, Acidaminococcus, ... 
#> Mediators: mediator.Cold.cereal, mediator.Fruit..not.juices., ... 
#> Pretreatment: subject 
#>   
#> [Models] 
#> mediation: An unfitted lm_model(). 
#> outcome: An unfitted lm_model().