Learn R Programming

robmed (version 0.6.0)

m: Create an object of hypothesized mediators or control variables

Description

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

covariates(...)

Arguments

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

Value

m() returns an object of class "parallel_mediators" and covariates() returns an object of class "covariates". Typically, these inherit from class "matrix".

Details

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

See Also

fit_mediation(), test_mediation()

Examples

Run this code
# NOT RUN {
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