Learn R Programming

robmed (version 1.2.1)

m: 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(...)

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".

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.

Author

Andreas Alfons

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.

See Also

fit_mediation(), test_mediation()

Examples

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

Run the code above in your browser using DataLab