Title: | Compositional Mediation Model |
---|---|
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>. |
Authors: | Ziqiang Lin [aut, cre], Jinqun Cheng [aut], Qiaoxuan Lin [aut], Wayne Lawrence [aut], Wangjian Zhang [aut], Yanhui Gao [aut] |
Maintainer: | Ziqiang Lin <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2025-03-12 04:02:10 UTC |
Source: | https://github.com/cran/CMMs |
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.
data(CMM_test_data)
data(CMM_test_data)
A compositional mediation model for continuous outcome and binary outcomes to deal with mediators that are compositional data
CMMs(data,outcome,med,pred,cov_con=NULL,cov_cat=NULL, weight=NULL,family="identity",boot=5000)
CMMs(data,outcome,med,pred,cov_con=NULL,cov_cat=NULL, weight=NULL,family="identity",boot=5000)
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) |
This code can be used to model with a situation when the mediators are compositional data.
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) |
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.
data(CMM_test_data) result=CMMs(CMM_test_data,1,3:22,2,cov_con=23:24,cov_cat=NULL,weight=NULL,boot=100)
data(CMM_test_data) result=CMMs(CMM_test_data,1,3:22,2,cov_con=23:24,cov_cat=NULL,weight=NULL,boot=100)