Skip to content

R/medltmle: Estimation and Inference for Natural Mediation Effect in Longitudinal Data

License

Notifications You must be signed in to change notification settings

imalenica/medltmle

Repository files navigation

R/medltmle

Travis-CI Build Status AppVeyor Build Status Coverage Status CRAN CRAN downloads Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. MIT license

Estimation for Natural Mediation Effect in Longitudinal Data

Authors: Ivana Malenica, Wenjing Zheng and Mark van der Laan

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 in order to handle more elaborate longitudinal data structures.


Installation

You can install the most recent stable release from GitHub via devtools with:

devtools::install_github("podTockom/medltmle")

Issues

If you encounter any bugs or have any specific feature requests, please file an issue.


Example

To get an idea of how medltmle works, let’s try using it with a simple simulated data set:

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

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

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

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

Releases

No releases published

Packages

No packages published