Learn R Programming

dpasurv

R-package for Dynamic Path Analysis of survival data.

Overview

The dpasurv package is designed to perform dynamic path analysis via calls to the following principal functions:

  • dpa() fits the dynamic path models corresponding to a given dynamic path diagram; returns an object of class dpa
  • effect() estimates the cumulative direct and indirect effects from the fitted dpa-object; returns an object of class effect

The effect-objects can be summed together to obtain the total effect (i.e. direct effect + indirect effect) as well as plotted with bootstrap confidence intervals.

Installation

# To install the most recent stable version on CRAN:
install.packages("dpasurv")

# To get bug fixes or new features, install the development version:
devtools::install_github("Novartis/dpasurv")

Usage

A vignette on how to use the dpasurv package can be found here, and basic usage is summarized below:

library(dpasurv)

# Perform dynamic path analysis
s <- dpa(Surv(start, stop, event) ~ M + x, list(M ~ x), id = "subject", data = simdata, boot.n = 500)

# Extract direct, indirect and total effect
direct <- effect(x ~ outcome, s, alpha=0.05)
indirect <- effect(x ~ M ~ outcome, s, alpha=0.05)
total <- sum(direct, indirect)

# Plot the results
par(mfrow=c(1,3))
plot(direct); abline(h=0, lty=2, col=2)
plot(indirect); abline(h=0, lty=2, col=2)
plot(total); abline(h=0, lty=2, col=2)

# Plot the results with ggplot2 graphics:
ggplot.effect(list(direct, indirect, total))

Citation

The dpasurv package was created as supplementary code for the following manuscript:

@article{dpasurv,
  title={Dynamic path analysis for exploring treatment effect mediation processes in clinical trials with time-to-event endpoints},
  author={Kormaksson, M. and Lange, M. R. and Demanse, D. and Strohmaier, S. and Duan, J. and Xie, Q. and Carbini, M. and Bossen, C. and Guettner, A. and Maniero, A.},
  journal={Statistics in Medicine (Accepted)},
  volume={},
  number={},
  pages={},
  year={2024},
}

If you publish results obtained from the dpasurv package, please cite the above paper.

Code authors

Copy Link

Version

Install

install.packages('dpasurv')

Monthly Downloads

155

Version

0.1.0

License

MIT + file LICENSE

Maintainer

Matthias Kormaksson

Last Published

September 2nd, 2024

Functions in dpasurv (0.1.0)

effect

Effect estimation in dynamic path analysis
ggplot.effect

Plot effects from dynamic path analysis along with bootstrap confidence bands
add.ci

Calculate bootstrap confidence bands for effect of interest
Mreg

Internal mediator regression function storing a linear regression estimate for each event time
dpa

Dynamic Path Analysis
plot.effect

Plot effects from dynamic path analysis along with bootstrap confidence bands
sum.effect

Sum of direct and indirect effects from dynamic path analysis
get.meta

Internal function that gathers meta data on the input to function dpa
Areg

Internal Aalen's Additive Hazards Model storing a linear effect estimate for each event time
check.dag

Internal check of whether the formulas passed to the function dpa follow a directed acyclic graph (DAG)
find.variables

Find variables of a given formula
simdata

Simulated data
Surv

A wrapper function for survival::Surv