mediation_data: 'mediation_data' Constructor

mediation_dataR Documentation

mediation_data Constructor

Description

Convert a SummarizedExperiment, phyloseq object, or data.frame into a mediation_data object. This conversion helps to organize the variables that lie on different parts of the mediation analysis graph, so that they are not all kept in a homogeneous experiment or data.frame. It's possible to specify outcome, mediator, or treatment variables using either string vectors or tidyselect syntax, e.g., starts_with("mediator_") will match all columns of the input data starting with the string mediator.

Usage

mediation_data(x, outcomes, treatments, mediators, pretreatments = NULL)

Arguments

x

A SummarizedExperiment, phyloseq object, or data.frame whose columns contain all the variables needed for the mediation analysis.

outcomes

A vector or tidyselect specification of the names of all outcome variables.

treatments

A vector or tidyselect specification of the names of all treatment variables.

mediators

A vector or tidyselect specification of the names of all mediators.

pretreatments

A vector containing names of all pretreatment variables. Defaults to NULL, in which case the pretreatments slot will remain empty.

Value

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

See Also

mediation_data-class

Examples

# multiple outcomes, one mediator
mediation_data(
    demo_spline(), starts_with("outcome"), "treatment", "mediator"
)

# one outcome, multiple mediators
mediation_data(demo_joy(), "PHQ", "treatment", starts_with("ASV"))

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