Coder Social home page Coder Social logo

causalmed's Introduction

causalMed

Causal Mediation analysis for time fixed and time-varying mediator.

  • IORW estimation method was implemented for time-fixed mediation anlaysis.
  • G-formula and IPTW was implemented for time-varying treatment, mediator, confounders.

This package is currently in development, please use with caution.

Note

This package was developed for my thesis, titled as Trajectory Modelling Based Mediation Analysis in Heterogeneous Longitudinal Survival Data

该包是本人博士论文《基于轨迹模型的异质性样本重复测量生存资料中介分析方法研究》的研究成果

Installation

# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("adayim/causalMed")

Usage

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.

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
  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
  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

causalmed's People

Contributors

adayim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.