-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
55 lines (44 loc) · 1.86 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: "README"
author: Alimu Dayimu
date: Aug 12, 2019
output: md_document
---
# causalMed
Causal Mediation analysis for time fixed and time-varying mediator. This package is currently in development, please use with caution.
## Installation
```r
# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("adayim/causalMed")
```
```{r load-pack, include=FALSE}
devtools::load_all()
```
## Usage
For time fixed mediation analysis:
```{r require, eval=FALSE}
library(causalMed)
```
```{r fixed-mediator, echo=TRUE, warning=FALSE}
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:
```{r time-varying, echo=TRUE, warning=FALSE}
```
Data structure must be in longitudinal format, and only mediator is time-varying.
## TODO
- [ ] Time-varying treatment and covariates.
- [ ] More documentations.
- [ ] More tests is needed.
## References
1. Tchetgen Tchetgen, E. J. (2013). Inverse odds ratio‐weighted estimation for causal mediation analysis. Statistics in medicine, 32(26), 4567-4580. [DOI:10.1002/sim.5864](https://doi.org/10.1002/sim.5864)
2. Lin, S. H., Young, J. G., Logan, R., & VanderWeele, T. J. (2017). Mediation analysis for a survival outcome with time‐varying exposures, mediators, and confounders. Statistics in medicine, 36(26), 4153-4166. [DOI:10.1002/sim.7426](https://doi.org/10.1002/sim.7426)
3. Zheng, W., & van der Laan, M. (2017). Longitudinal mediation analysis with time-varying mediators and exposures, with application to survival outcomes. Journal of causal inference, 5(2). [DOI:10.1515/jci-2016-0006](https://doi.org/10.1515/jci-2016-0006)