-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
122 lines (89 loc) · 3.2 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
---
output: github_document
editor_options:
chunk_output_type: inline
---
<!-- README.md is generated from README.Rmd. Please edit this file -->
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%"
)
```
## bayesmsm
<!-- badges: start -->
<!-- badges: end -->
# Overview
*bayesmsm* is an R package that implements the Bayesian marginal structrual models to estimate average treatment effect for drawing causal inference with time-varying treatment assignment and confoudning with extension to handle informative right-censoring. The Bayesian marginal structural models is a semi-parametric approach and features a two-step estimation process. The first step involves Bayesian parametric estimation of the time-varying treatment assignment models and the second step involves non-parametric Bayesian bootstrap to estimate the average treatment effect between two distinct treatment sequences of interest.
Reference paper on Bayesian marginal structural models:
- Saarela, O., Stephens, D. A., Moodie, E. E., & Klein, M. B. (2015). On Bayesian estimation of marginal structural models. Biometrics, 71(2), 279-288.
- Liu, K., Saarela, O., Feldman, B. M., & Pullenayegum, E. (2020). Estimation of causal effects with repeatedly measured outcomes in a Bayesian framework. Statistical methods in medical research, 29(9), 2507-2519.
# Installation
Install using `devtools` package:
```{r echo=TRUE, eval=FALSE}
## install.packages(devtools) ## make sure to have devtools installed
devtools::install_github("Kuan-Liu-Lab/bayesmsm")
library(bayesmsm)
```
# Dependency
This package depends on the following R packages:
- `MCMCpack`
- `doParallel`
- `foreach`
- `parallel`
- `R2jags`
- `coda`
# Quickstart
Here are some examples demonstrating how to use the `bayesmsm` package:
```{r echo=TRUE, eval=FALSE}
# Load example data
testdata <- read.csv(system.file("extdata", "continuous_outcome_data.csv", package = "bayesmsm"))
# Calculate Bayesian weights
weights <- bayesweight(
trtmodel.list = list(
a_1 ~ w1 + w2 + L1_1 + L2_1,
a_2 ~ w1 + w2 + L1_1 + L2_1 + L1_2 + L2_2 + a_1
),
data = testdata,
n.iter = 250,
n.burnin = 150,
n.thin = 5,
n.chains = 2,
seed = 890123,
parallel = TRUE
)
# Perform Bayesian non-parametric bootstrap
model <- bayesmsm(
ymodel = y ~ a_1 + a_2,
nvisit = 2,
reference = c(rep(0, 2)),
comparator = c(rep(1, 2)),
family = "gaussian",
data = testdata,
wmean = weights,
nboot = 1000,
optim_method = "BFGS",
seed = 890123,
parallel = TRUE,
ncore = 2
)
# View model summary
summary.bayesmsm(model)
```
# License
This package is licensed under the MIT License. See the LICENSE file for details.
# Citation
Please cite our software using:
```
@Manual{,
title = {bayesmsm: An R package for longitudinal causal analysis using Bayesian Marginal Structural Models},
author = {Xiao Yan and Martin Urner and Kuan Liu},
year = {2024},
note = { https://github.com/Kuan-Liu-Lab/bayesmsm},
url = {https://kuan-liu-lab.github.io/bayesmsm/},
}
```
# Contact
* e-mail: <[email protected]>, <[email protected]>
* Please report bugs by opening an [issue](https://github.com/Kuan-Liu-Lab/bayesmsm/issues/new).