cond_cov {unvs.med} | R Documentation |
Modifications of Data and Models for Moderated Mediation
Description
This function modifies the mediator and outcome model and the dataset according
to the conditions of certain covariates specified by the user.
The conditions are constructed by the character parameter cov_val
with multiple string elements.
This function then modifies the data and models based on rules of conditional regressions.
The amount of sample and model structure are changed correspondingly. The samples and model variables satisfy the conditions
are finally remain. Therefore, This function is only involved when moderated mediation effects are considered in the analysis.
This is an internal function, automatically called by the function FormalEstmed
.
Usage
cond_cov (m_model, y_model, data, X, M, cov_val)
Arguments
m_model |
a fitted model object for the mediator. |
y_model |
a fitted model object for the outcome. |
data |
a dataframe used in the analysis. |
X |
a character variable of the exposure's name. |
M |
a character variable of the mediator's name. |
cov_val |
a character variable of the conditions of the covariates. Each string (element) in the character may include ==, <, >, <=, >=, etc. |
Value
This function returns a list of three objects. A conditional dataframe, an updated mediator model and an updated outcome model.