Causal Mediation analysis for time fixed and time-varying mediator.
This package is currently in development, please use with caution.
This package was developed for my thesis, titled as Trajectory Modelling Based Mediation Analysis in Heterogeneous Longitudinal Survival Data
该包是本人博士论文《基于轨迹模型的异质性样本重复测量生存资料中介分析方法研究》的研究成果
# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("adayim/causalMed")
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)
## Call:
## iorw(fitY = coxph(Surv(os, cvd) ~ bmi + age0 + smoke, data = dtbase),
## exposure = "smoke", mediator = c("hdl", "ldl", "tg"), family = "binomial")
##
## Outcome Model Call:
## coxph(formula = Surv(os, cvd) ~ bmi + age0 + smoke, data = dtbase)
##
## Exposure Model Call:
## glm(formula = smoke ~ bmi + age0 + smoke + hdl + ldl + tg, family = "binomial",
## data = dtbase)
## ------
## Natural effect model
## with standard errors based on the non-parametric bootstrap
## ---
## Exposure: smoke
## Mediator(s): c, hdl, ldl, tg
## ------
## Parameter estimates:
## Estimate Bias Std.error conf.low conf.high
## Total effect 0.3136 -0.0177 0.4038 -0.4602 1.1228
## Natural Direct effect -0.2574 0.0026 0.4639 -1.1692 0.6492
## Natural Indirect effect 0.5710 -0.0203 0.2561 0.0894 1.0932
## ------
## Proportion Mediated: 182.0809%
For time-varying mediator:
Data structure must be in longitudinal format. Need to add the usage of the time-varying mediation analysis usage in the document.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.