CMMs {CMMs} | R Documentation |
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)