Learn R Programming

adjustedCurves

Author: Robin Denz

Description

adjustedCurves is an R-Package which can be used to estimate and plot confounder-adjusted survival curves + confidence intervals as well as cause-specific confounder-adjusted cumulative incidence functions + confidence intervals using a variety of methods. It provides a convenient wrapper around existing R-Packages on the topic and adds additional methods and functionality on top of it. Those additional features include the calculation of adjusted restricted mean survival times and testing whether two confounder-adjusted survival curves are different in a given interval.

Detailed descriptions of each method can be found in the literature cited in the documentation.

Installation

A stable version can be installed directly from CRAN using:

install.packages("adjustedCurves")

The developmental version can be installed using the devtools R-Package:

library(devtools)

devtools::install_github("https://github.com/RobinDenz1/adjustedCurves")

Bug Reports and Feature Requests

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

Examples

This minimal example shows how to estimate and plot adjusted survival curves using Direct Adjustment with this package:

library(adjustedCurves)
library(survival)

# simulate some data as example
set.seed(31)
sim_dat <- sim_confounded_surv(n=250, max_t=1.2, group_beta=0)
sim_dat$group <- as.factor(sim_dat$group)

# estimate a cox-regression for the outcome
cox_mod <- coxph(Surv(time, event) ~ x1 + x2 + x4 + x5 + group,
                 data=sim_dat, x=TRUE)

# use it to estimate adjusted survival curves
adjsurv <- adjustedsurv(data=sim_dat,
                        variable="group",
                        ev_time="time",
                        event="event",
                        method="direct",
                        outcome_model=cox_mod,
                        conf_int=TRUE)

# plot with confidence intervals
plot(adjsurv, conf_int=TRUE)

Here is an example of how to estimate and plot adjusted survival curves using Inverse Probability of Treatment Weighting:

# estimate a treatment assignment model
glm_mod <- glm(group ~ x2 + x3 + x5 + x6, data=sim_dat,
               family="binomial"(link="logit"))

# use it to estimate adjusted survival curves
adjsurv <- adjustedsurv(data=sim_dat,
                        variable="group",
                        ev_time="time",
                        event="event",
                        method="iptw_km",
                        treatment_model=glm_mod,
                        conf_int=TRUE)

# plot with confidence intervals
plot(adjsurv, conf_int=TRUE)

It is also possible to plot the difference between two curves using the plot_curve_diff() function:

plot_curve_diff(adjsurv, conf_int=TRUE, color="blue")

To test whether the two adjusted survival curves are different in a specified interval (here 0 to 0.75), the adjustedsurv call has to be made with bootstrap=TRUE:

adjsurv <- adjustedsurv(data=sim_dat,
                        variable="group",
                        ev_time="time",
                        event="event",
                        method="direct",
                        outcome_model=cox_mod,
                        conf_int=TRUE,
                        bootstrap=TRUE,
                        n_boot=1000)

adj_test <- adjusted_curve_test(adjsurv, from=0, to=0.75)
summary(adj_test)

More examples can be found in the documentation and the vignettes.

Citation

The main paper associated with this R-Package is:

Robin Denz, Renate Klaaßen-Mielke, and Nina Timmesfeld (2023). A comparison of different methods to adjust survival curves for confounders. Statistics in Medicine. 42.10, pp. 1461-1479. doi:10.1002/sim.9681

In addition, the relevant primary literature of the respective method should be cited. This can be found in the documentation of the method.

License

© 2021 Robin Denz

The contents of this repository are distributed under the GNU General Public License. You can find the full text of this License in this github repository. Alternatively, see http://www.gnu.org/licenses/.

Copy Link

Version

Install

install.packages('adjustedCurves')

Monthly Downloads

711

Version

0.11.2

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Robin Denz

Last Published

July 29th, 2024

Functions in adjustedCurves (0.11.2)

adjusted_rmst

Estimate Confounder-Adjusted Restricted Mean Survival Times
CSC_MI

Cause-Specific Cox Regression with Multiple Imputation
adjustedsurv

Estimate Confounder-Adjusted Survival Curves
adjusted_curve_test

Test if there is a difference between two Confounder-Adjusted Survival Curves or CIFs
adjustedCurves-package

Confounder-Adjusted Survival Curves and Cumulative Incidence Functions
FGR_MI

Fine & Gray Model with Multiple Imputation
adjusted_rmtl

Estimate Confounder-Adjusted Restricted Mean Time Lost
adjusted_curve_diff

Estimate the difference between or the ratio of two Confounder-Adjusted Survival Curves or CIFs
adjusted_surv_quantile

Estimate Confounder-Adjusted Survival Time Quantiles
adjustedcif

Estimate Cause-Specific Confounder-Adjusted Cumulative Incidence Functions
cif_aiptw

Augmented Inverse Probability of Treatment Weighted CIFs
cif_direct

Direct Adjusted Cumulative Incidence Functions
as_ggsurvplot_df

Extract a data.frame containing the estimated survival curves from a adjustedsurv object
cif_aiptw_pseudo

Augmented Inverse Probability of Treatment Weighted CIFs using Pseudo-Values
cif_aalen_johansen

Group-Specific Aalen-Johansen CIFs
cif_direct_pseudo

Direct Adjusted CIFs using Pseudo-Values
cif_iptw

Inverse Probability of Treatment Weighted CIFs
cif_iptw_pseudo

Inverse Probability of Treatment Weighted CIFs using Pseudo-Values
models_cif_direct

List of supported models in cif_direct
cif_matching

Using Propensity-Score Matching to Calculate Adjusted CIFs
plot.curve_test

Plot Method for curve_test Objects
sim_confounded_crisk

Simulate Competing Risks Data with Confounders
plot_rmtl_curve

Plot Adjusted Restricted Mean Time Lost Curves
plot.adjustedsurv

Plot Confounder-Adjusted Survival Curves
plot_curve_diff

Plot the Difference Between or the Ratio of Two Adjusted Survival Curves or CIFs
models_surv_direct

List of supported models in surv_direct
plot.adjustedcif

Plot Confounder-Adjusted Cumulative Incidence Functions
sim_confounded_surv

Simulate Survival Data with Confounders
print.curve_test

Print Method for curve_test Objects
plot_rmst_curve

Plot Adjusted Restricted Mean Survival Time Curves
surv_iv_2SRIF

Instrumental Variable based Survival Curve Estimation using the Two Stage Residual Inclusion method with a Frailty Term (2SRI-F)
surv_emp_lik

Empirical Likelihood Estimation Survival Curves
surv_iptw_cox

Inverse Probability of Treatment Weighted Survival using Cox-Regression
surv_direct_pseudo

Direct Adjusted Survival Curves using Pseudo-Values
surv_aiptw

Augmented Inverse Probability of Treatment Weighted Survival Curves
surv_direct

Direct Adjusted Survival Curves
surv_iptw_km

Inverse Probability of Treatment Weighted Kaplan-Meier estimates
surv_iptw_pseudo

Inverse Probability of Treatment Weighted Survival Estimates using Pseudo-Values
surv_aiptw_pseudo

Augmented Inverse Probability of Treatment Weighted Survival Curves using Pseudo-Values
surv_km

Group-Specific Kaplan-Meier Survival Curves
surv_prox_aiptw

Proximal Augmented Inverse Probability of Treatment Weighted Survival Curve Estimates
surv_matching

Using Propensity-Score Matching to Calculate Adjusted Survival Curves
surv_strat_cupples

Adjusted Survival Curves for Categorical Confounders using the Method by Cupples et al. (1995)
surv_strat_nieto

Adjusted Survival Curves for Categorical Confounders using the Method by Gregory (1988) and Nieto & Coresh (1996)
surv_strat_amato

Adjusted Survival Curves for Categorical Confounders using the Method by Amato (1988)
surv_prox_iptw

Proximal Inverse Probability of Treatment Weighted Survival Curve Estimates