m: Create an object of hypothesized mediators or control...

View source: R/formula.R

mR Documentation

Create an object of hypothesized mediators or control variables

Description

m() and its wrappers parallel_m() and serial_m() create an object of hypothesized mediators, while covariates() creates an object of control variables. Usually, these are used in a formula specifying a mediation model.

Usage

m(..., .model = c("parallel", "serial"))

parallel_m(...)

serial_m(...)

covariates(...)

Arguments

...

variables are supplied as arguments, as usual separated by a comma.

.model

a character string specifying the type of model in case of multiple mediators. Possible values are "parallel" (the default) for the parallel multiple mediator model, or "serial" for the serial multiple mediator model.

Details

m() and covariates() are essentially wrappers for cbind() with a specific class prepended to the class(es) of the resulting object.

parallel_m() and serial_m() are wrappers for m() with the respective value for argument .model.

Value

m() returns an object inheriting from class "mediators" (with subclass "parallel_mediators" or "serial_mediators" as specified by argument .model), and covariates() returns an object of class "covariates". Typically, these inherit from class "matrix".

Author(s)

Andreas Alfons

See Also

fit_mediation(), test_mediation()

Examples

data("BSG2014")

# inside formula
fit_mediation(TeamCommitment ~ m(TaskConflict) + ValueDiversity,
              data = BSG2014)

# outside formula
mediator <- with(BSG2014, m(TaskConflict))
fit_mediation(TeamCommitment ~ mediator + ValueDiversity,
              data = BSG2014)


aalfons/robmed documentation built on July 4, 2023, 7:48 a.m.