Last chance! 50% off unlimited learning
Sale ends in
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.
m(...)covariates(...)
variables are supplied as arguments, as usual separated by a comma.
m()
returns an object of class "parallel_mediators"
and covariates()
returns an object of class "covariates"
.
Typically, these inherit from class "matrix"
.
These are essentially wrappers for cbind()
with a
specific class prepended to the class(es) of the resulting object.
# 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