-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME.Rmd
174 lines (132 loc) · 5.95 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# R/`medltmle`
[![Travis-CI Build Status](https://travis-ci.org/podTockom/medltmle.svg?branch=master)](https://travis-ci.org/podTockom/medltmle)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/podTockom/medltmle?branch=master&svg=true)](https://ci.appveyor.com/project/podTockom/medltmle)
[![Coverage Status](https://img.shields.io/codecov/c/github/podTockom/medltmle/master.svg)](https://codecov.io/github/podTockom/medltmle?branch=master)
[![CRAN](http://www.r-pkg.org/badges/version/medltmle)](http://www.r-pkg.org/pkg/medltmle)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/medltmle)](https://CRAN.R-project.org/package=medltmle)
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](http://www.repostatus.org/badges/latest/wip.svg)](http://www.repostatus.org/#wip)
[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
> Estimation for Natural Mediation Effect in Longitudinal Data
**Authors:** [Ivana Malenica](https://github.com/imalenica), [Wenjing Zheng]() and [Mark van der
Laan](https://vanderlaan-lab.org)
## Description
`medltmle` estimates the natural mediation effect for a longitudinal setting
with time-varying mediators. This R package implements several estimators of the
data dependent parameter (SE) and non-data dependent parameter (NE) for direct
and indirect mediation effects over multiple time points, adjusting for measured
time-varying confounding and informative right-censoring. The theoretical
justifications for using either of the aforementioned parameters are outlined in
the vignette.
Currently available estimators include
1. TMLE for longitudinal data
2. The longitudinal G-computation
3. Inverse Probability of Treatment Weighted (IPTW)
Future releases will support longitudinal data in long format and will integrate
with the [`stremr` package](https://github.com/osofr/stremr) in order to handle
more elaborate longitudinal data structures.
---
## Installation
You can install the most recent _stable release_ from GitHub via
[`devtools`](https://www.rstudio.com/products/rpackages/devtools/) with:
```{r gh-installation, eval = FALSE}
devtools::install_github("podTockom/medltmle")
```
---
## Issues
If you encounter any bugs or have any specific feature requests, please [file an
issue](https://github.com/podTockom/medltmle/issues).
---
## Example
To get an idea of how `medltmle` works, let's try using it with a simple
simulated data set:
```{r simulate, eval=FALSE}
# setup
suppressMessages(library(medltmle))
set.seed(67394)
# simulation parameters
end.time = 2
n <- 400
# simulate data
data <- GenerateData(n = n, end.time = end.time)
```
Next, we can generate simple models for conditional densities and
iterative expectations, and define counterfactual exposures:
```{r models-counterfacts, eval=FALSE}
# define models
spec <- make.sim.spec(2)
# define counterfactuals
abar <- 1
abar.prime <- 0
```
Having gone through the above steps, we can now obtain IPTW and TMLE estimates
of the _natural mediation effect_:
```{r estimate, eval=FALSE}
# let's fit the longitudinal TMLE for the mediation parameter
result_10 <- suppressMessages(
medltmle(data = data,
Anodes = names(data)[grep("^A", names(data))],
Cnodes = names(data)[grep("^C", names(data))],
Znodes = names(data)[grep("^Z", names(data))],
Lnodes = names(data)[grep("^L", names(data))],
Ynodes = names(data)[grep("^Y", names(data))],
survivalOutcome = TRUE,
QLform = spec$QL.c,
QZform = spec$QZ.c,
gform = spec$g.c,
qzform = spec$qz.c,
qLform = spec$qL.c,
abar = rep(abar, end.time),
abar.prime = rep(abar.prime, end.time),
CSE = TRUE,
time.end = end.time
)
)
```
---
## Citation
After using the medltmle R package, please cite the following:
```{r citation, eval=FALSE}
@software{malenica2018medltmle,
author = {Malenica, Ivana and Zheng, Wenjing and {van der Laan}, Mark J},
title = {{medltmle}: Natural mediation effect for a longitudinal setting with time-varying mediators},
year = {2018},
doi = {},
url = {https://github.com/imalenica/medltmle},
note = {R package version 0.1.0}
}
```
---
## License
© 2018 Ivana Malenica
The contents of this repository are distributed under the MIT license. See
below for details:
```
The MIT License (MIT)
Copyright (c) 2018 Ivana Malenica
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```