Type: | Package |
Title: | Compositional Mediation Model |
Version: | 1.0.0 |
Description: | A compositional mediation model for continuous outcome and binary outcomes to deal with mediators that are compositional data. Lin, Ziqiang et al. (2022) <doi:10.1016/j.jad.2021.12.019>. |
Depends: | R (≥ 3.5.0) |
License: | GPL-3 |
Encoding: | UTF-8 |
Imports: | fastDummies,survey,robCompositions,ggplot2,forcats,dplyr |
LazyData: | true |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | no |
Packaged: | 2022-10-14 17:05:49 UTC; linzi |
Author: | Ziqiang Lin [aut, cre], Jinqun Cheng [aut], Qiaoxuan Lin [aut], Wayne Lawrence [aut], Wangjian Zhang [aut], Yanhui Gao [aut] |
Maintainer: | Ziqiang Lin <linziqiang0314@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2022-10-17 06:35:19 UTC |
Test Data
Description
Contains artificial 100 samples with a continuous outcome variable y, a continuous treatment tr, 20 compositional mediators M and 2 covariates X. The true direct and indirect effects of treatment on the outcome both are 1.00. The true component-wise indirect effects (M1-M20) are 0.693, -0.425, 0.135, -0.057, -0.268, 0.970, -0.843, 0.805, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000.
Usage
data(CMM_test_data)
Compositional Mediation Model
Description
A compositional mediation model for continuous outcome and binary outcomes to deal with mediators that are compositional data
Usage
CMMs(data,outcome,med,pred,cov_con=NULL,cov_cat=NULL,
weight=NULL,family="identity",boot=5000)
Arguments
data |
an input dataframe |
outcome |
column number that locate continuous or binary outcome variable in |
med |
a vector of column numbers that locate the compositional mediators in |
pred |
column number that locate continuous or binary exposure in |
cov_con |
a vector of column numbers that locate the continuous covariates in |
cov_cat |
a vector of column numbers that locate the categorical covariates in |
weight |
column number that locate weights in |
family |
If your outcome variable is continuous, then family="identity"; if your outcome variable is binary, then family="logistic" (default "identity") |
boot |
Number of bootstrap (default 5000) |
Details
This code can be used to model with a situation when the mediators are compositional data.
Value
An object of class CMM
, which is a list with the following components:
Indirect.effect |
Indirect effects of exposure on an outcome variable (with 95% bootstrap confidence intervals) |
Direct.effect |
Direct effects of exposure on an outcome variable (with 95% bootstrap confidence intervals) |
Total.effect |
Total effects of exposure on an outcome variable (with 95% bootstrap confidence intervals) |
Mediation.effect.plot |
A plot shows mediation effect of exposure on an outcome variables (mediation effect with with 95% bootstrap confidence intervals) |
Relative.Effects.plot |
A plot shows relative effect of exposure on an outcome variables (relative effect with with 95% bootstrap confidence intervals) |
References
Lin Z, Zhu S, Cheng J, Lin Q, Lawrence WR, Zhang W, Huang Y, Chen Y, Gao Y. The mediating effect of engagement in physical activity over a 24-hour period on chronic disease and depression: using compositional mediation model. J Affect Disord. 2021 Dec 10:S0165-0327(21)01337-9. doi: 10.1016/j.jad.2021.12.019.
Examples
data(CMM_test_data)
result=CMMs(CMM_test_data,1,3:22,2,cov_con=23:24,cov_cat=NULL,weight=NULL,boot=100)