-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
304 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
^\.github$ | ||
^LICENSE\.md$ | ||
^Meta$ | ||
^docs$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | ||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | ||
on: | ||
push: | ||
branches: [main, master] | ||
pull_request: | ||
branches: [main, master] | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
|
||
name: pkgdown.yaml | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
pkgdown: | ||
runs-on: ubuntu-latest | ||
# Only restrict concurrency for non-PR jobs | ||
concurrency: | ||
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: r-lib/actions/setup-pandoc@v2 | ||
|
||
- uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
|
||
- uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: any::pkgdown, local::. | ||
needs: website | ||
|
||
- name: Build site | ||
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) | ||
shell: Rscript {0} | ||
|
||
- name: Deploy to GitHub pages 🚀 | ||
if: github.event_name != 'pull_request' | ||
uses: JamesIves/[email protected] | ||
with: | ||
clean: false | ||
branch: gh-pages | ||
folder: docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
Package: bayesmsm | ||
Type: Package | ||
Title: Bayesian Marginal Structural Models | ||
Title: Fitting Bayesian Marginal Structural Models for Longitudinal observational Data | ||
Version: 0.1.0 | ||
Author: Kuan Liu, Xiao Yan | ||
Maintainer: Xiao Yan <[email protected]> | ||
Date: 2024-10-07 | ||
Authors@R: c( | ||
person("Kuan", "Liu", , "[email protected]", role = c("aut", "cre"), | ||
comment = "https://Kuan-Liu.com/"), | ||
person("Xiao", "Yan", , "[email protected]", role = c("aut", "cre"), | ||
comment = "https://www.linkedin.com/in/xiaoyan1596/"), | ||
person("Martin", "Urner", , role = "aut", | ||
comment = "https://criticalcaretoronto.com/our-fellows/dr-martin-urner/"), | ||
person("Olli", "Saarela", , "[email protected]", role = "aut", | ||
comment = "https://www.dlsph.utoronto.ca/faculty-profile/saarela-olli/"), | ||
) | ||
Maintainer: Kuan Liu <[email protected]> | ||
Description: Fitting 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. Based on the Bayesian marginal structural models of Saarela et al (2015) <DOI: 10.1111/biom.12269> and Liu et al (2020) <DOI: 10.1177/0962280219900362>. | ||
Depends: | ||
R (>= 4.2.0) | ||
Suggests: | ||
|
@@ -22,6 +33,5 @@ Imports: | |
coda (>= 0.19-4) | ||
NeedsCompilation: no | ||
Config/testthat/edition: 3 | ||
Description: This package provides tools for estimating causal effects using Bayesian Marginal Structural Models. It includes functions for estimating Bayesian weights using JAGS and for Bayesian non-parametric bootstrap to calculate causal effects. | ||
URL: https://kuan-liu-lab.github.io/bayesmsm/ | ||
BugReports: https://github.com/Kuan-Liu-Lab/bayesmsm/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- | ||
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 Olli Saarela 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]> | ||
|
||
|
||
# Getting help or contributing | ||
|
||
Please report bugs by opening an | ||
[issue](https://github.com/Kuan-Liu-Lab/bayesmsm/issues/new). If you have | ||
a question regarding the usage of `bayesmsm`, please open a | ||
[discussion](https://github.com/Kuan-Liu-Lab/bayesmsm/discussions/new/choose). | ||
If you would like to contribute to the package, please open a pull request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,40 @@ | ||
# R package bayesmsm | ||
|
||
This package provides tools for estimating causal effects using Bayesian Marginal Structural Models. It includes functions for estimating Bayesian weights using JAGS and for Bayesian non-parametric bootstrap to calculate causal effects. | ||
<!-- README.md is generated from README.Rmd. Please edit this file --> | ||
|
||
## bayesmsm | ||
|
||
# Reference | ||
<!-- badges: start --> | ||
<!-- badges: end --> | ||
|
||
Reference paper on Bayesian marginal structural models: | ||
# 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. | ||
|
||
- Saarela, O., Stephens, D. A., Moodie, E. E., & Klein, M. B. (2015). On Bayesian estimation of marginal structural models. Biometrics, 71(2), 279-288. | ||
Reference paper on Bayesian marginal structural models: | ||
|
||
- 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. | ||
- 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 | ||
``` r | ||
## install.packages(devtools) ## make sure to have devtools installed | ||
devtools::install_github("Kuan-Liu-Lab/bayesmsm") | ||
library(bayesmsm) | ||
|
@@ -25,19 +43,19 @@ library(bayesmsm) | |
# Dependency | ||
|
||
This package depends on the following R packages: | ||
- `MCMCpack` | ||
- `doParallel` | ||
- `foreach` | ||
- `parallel` | ||
- `R2jags` | ||
- `coda` | ||
|
||
- `MCMCpack` | ||
- `doParallel` | ||
- `foreach` | ||
- `parallel` | ||
- `R2jags` | ||
- `coda` | ||
|
||
# Examples | ||
# Quickstart | ||
|
||
Here are some examples demonstrating how to use the `bayesmsm` package: | ||
|
||
```r | ||
``` r | ||
# Load example data | ||
testdata <- read.csv(system.file("extdata", "continuous_outcome_data.csv", package = "bayesmsm")) | ||
|
||
|
@@ -76,23 +94,32 @@ model <- bayesmsm( | |
summary.bayesmsm(model) | ||
``` | ||
|
||
|
||
# Documentation | ||
|
||
For comprehensive documentation and examples, visit the [Vignette](https://Kuan-Liu-Lab.github.io/bayesmsm/). | ||
|
||
|
||
# License | ||
|
||
This package is licensed under the MIT License. See the LICENSE file for details. | ||
|
||
This package is licensed under the MIT License. See the LICENSE file for | ||
details. | ||
|
||
# Citation | ||
|
||
If you use the `bayesmsm` package in your research, please cite the reference papers listed above. | ||
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 Olli Saarela 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]> | ||
|
||
# Developers | ||
# Getting help or contributing | ||
|
||
- Xiao Yan | ||
- Kuan Liu | ||
Please report bugs by opening an | ||
[issue](https://github.com/Kuan-Liu-Lab/bayesmsm/issues/new). If you | ||
have a question regarding the usage of `bayesmsm`, please open a | ||
[discussion](https://github.com/Kuan-Liu-Lab/bayesmsm/discussions/new/choose). | ||
If you would like to contribute to the package, please open a pull | ||
request. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
url: https://kuan-liu-lab.github.io/bayesmsm/ | ||
|
||
template: | ||
params: | ||
bootswatch: cosmo | ||
|
||
authors: | ||
Kuan Liu: | ||
href: http://Kuan-Liu.com/ | ||
Xiao Yan: | ||
href: https://www.linkedin.com/in/xiaoyan1596/ | ||
Martin Urner: | ||
href: https://criticalcaretoronto.com/our-fellows/dr-martin-urner/ | ||
Olli Saarela: | ||
href: http://individual.utoronto.ca/osaarela/ | ||
|
||
development: | ||
mode: release | ||
|
||
reference: | ||
- title: All functions | ||
contents: | ||
- '`bayesmsm`' | ||
- '`bayesweight`' | ||
- '`bayesweight_cen`' | ||
- '`calculate_effect`' | ||
- '`plot_APO`' | ||
- '`plot_ATE`' | ||
- '`plot_est_box`' | ||
- '`summary_bayesmsm`' | ||
|
||
navbar: | ||
structure: | ||
left: | ||
- home | ||
- Vignettes | ||
- Reference | ||
- Changelog | ||
right: github | ||
components: | ||
home: | ||
icon: fas fa-home fa-lg | ||
href: index.html | ||
articles: | ||
text: Vignettes | ||
menu: | ||
- text: Bayesian MSMs without censoring | ||
href: articles/bayesmsm-vignette.html | ||
reference: | ||
text: Reference | ||
href: reference/index.html | ||
news: | ||
text: Changelog | ||
href: news/index.html |
File renamed without changes.
File renamed without changes.