m {robmed} | R 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 |
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)