Causal Mediation analysis for time fixed and time-varying mediator. This package is currently in development, please use with caution.
# Install the development version from GitHub: # install.packages("devtools") devtools::install_github("adayim/causalMed")
devtools::load_all()
For time fixed mediation analysis:
library(causalMed)
library(survival) data(lipdat) dtbase <- lipdat[lipdat$time == 0, ] # Select the first row out <- iorw(coxph(Surv(os, cvd) ~ bmi + age0 + smoke, data = dtbase), exposure = "smoke", mediator = c("hdl", "ldl", "tg"), family = "binomial") summary(out)
For time-varying mediator:
Data structure must be in longitudinal format, and only mediator is time-varying.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.