Description Usage Arguments Value Examples
Performing mediation analysis based on the interventional effect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
y |
The outcome variable. |
med |
A vector of the mediators. |
treat |
The exposure variable. |
c |
A vector of covariates. |
ymodel |
A character string specifying the outcome model. Current options are "regression" (for continuous variable), "logistic regression" (for binary variable), and "poisson regression" (for count variable) |
mmodel |
A vector of character string specifying the mediator models. Current options are "regression" (for continuous variable), "logistic regression" (for binary variable), and "poisson regression" (for count variable) |
treat_lv |
Value of the treatment variable used as the treatment condition. Default is 1. |
control_lv |
Value of the treatment variable used as the control condition. Default is 0. |
incint |
A vector of boolean specifying if the exposure-mediator interactions are included into the outcome model. Default is NULL. |
inc_mmint |
A boolean value specifying if the mediator-mediator interactions are included. Default is FALSE. |
data |
A data frame containing all the analysis variables. |
sim |
A numerical value specifying the number of simulation. Default is 1000. |
conf.level |
A numerical value specifying the confidence interval the the estimates. Default is 0.95 |
complete_analysis |
Multiple imputation will be used to fill in missing value. Setting this flag to FALSE will force the analysis to be conducted on complete data. |
digits |
Number of digits shown in the HTML report. |
HTML_report |
A boolean specifying if the HTML will be saved in the R working directory. |
summary_report |
A boolean specifying if a summary report will be printed. |
cores |
A numeric value specifying the number of cores to be used for the Monte Carlo simulation. If this is set to NULL (default), it will auto-detect the number of cores to be used. |
imputed_data |
A boolean specifiying if the data is an imputed data in long format. The dataset much contains .imp (to identify the imputed data) and .id (to identify each observ3ation in each imputed data). |
mediate
generates a report in HTML format based on results from the mediation analysis. This report is saved in the working directory.
The followings will returned by mediate
individual |
If there is no missing data or complete data analysis is performed, |
indirect1, indirect2, indirect3 |
Elements of the |
direct |
Element of the |
dependence |
Element of the |
interaction |
Element of the |
total |
Element of the |
prop1, prop2, prop3 |
Elements of the |
ymodel |
Element of the |
ymodel_te |
Element of the |
m1_model, m2_model, m3_model |
Elements of the |
m2_model_cond |
Element of the |
m3_model_cond_m1, m3_model_cond_m2, m3_model_cond_m1m2 |
Element of the |
combined |
If multiple imputation is used for the analysis, |
direct |
Element of the |
indirect |
Element of the |
total |
Element of the |
prop |
Element of the |
interaction |
Element of the |
dependence |
Element of the |
mids |
Only available if multiple imputation is used. This is the |
y_pooled_res |
Only available if multiple imputation is used. This contains the pooled model estimates from the outcome model. |
m_pooled_res |
Only available if multiple imputation is used. This contains the pooled model estimates from the mediator model(s). |
model_summary |
This is a formatted table for the results from the mediator and outcome models. |
res_html |
This is the HTML code for the result report. |
summary_text |
This is the formatted text of the result summary. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | #One mediator, no HTML report.
#Set HTML_report = TRUE if a HTML report is needed.
med_res <- mediate(y = "y", med = c("m"), treat = "x", ymodel = "regression",
mmodel = c("regression"), treat_lv = 1, control_lv = 0, incint = FALSE, inc_mmint = FALSE,
conf.level = 0.9, data = sim_data, sim = 20, complete_analysis = TRUE,
HTML_report = FALSE, digits = 3, cores = 2)
#One mediator with exposure-mediator interaction
#Results presented in a HTML report (This is the default).
med_res <- mediate(y = "y", med = c("m"), treat = "x", ymodel = "regression",
mmodel = c("regression"), treat_lv = 1, control_lv = 0, incint = TRUE, inc_mmint = FALSE,
conf.level = 0.9, data = sim_data, sim = 1000, complete_analysis = TRUE, digits = 3, cores = 2)
#Two mediators, complete data analysis and no HTML report.
med_res <- mediate(y = "sub_misuse", med = c("dev_peer","sub_exp"), treat = "fam_int",
c = c("conflict","gender"), ymodel = "logistic regression", mmodel = c("logistic regression",
"logistic regression"), treat_lv = 1, control_lv = 0, conf.level = 0.9,
data = substance, sim = 20, complete_analysis = TRUE,
HTML_report = FALSE, digits = 3, cores = 2)
#Two mediators with multiple imputation (missing data are imputed by default)
#Results presented in a HTML report.
med_res <- mediate(y = "sub_misuse", med = c("dev_peer","sub_exp"), treat = "fam_int",
c = c("conflict","gender"), ymodel = "logistic regression", mmodel = c("logistic regression",
"logistic regression"), treat_lv = 1, control_lv = 0, conf.level = 0.9,
data = substance, sim = 1000, digits = 3, cores = 2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.