Package {ROCsurvcomp}


Title: ROC-Based Methods for Comparing Survival Distributions with Right, Left, and Doubly Censored Data
Version: 0.1.2
Date: 2026-05-05
Maintainer: Mohammod Mahmudur Rahman <mahmudur.asif13@gmail.com>
Description: Implements nonparametric and semiparametric methods for comparing two survival distributions under non-proportional hazards (non-PH). The methods are based on the Receiver Operating Characteristic (ROC) curve length (Bantis et al. (2021) <doi:10.1002/sim.8869>) and the overlap coefficient (OVL) (Franco-Pereira et al. (2021) <doi:10.1177/09622802211046386>), as well as a joint ROC length-OVL-based approach. These methods do not require prior knowledge of the underlying non-PH pattern and can accommodate right, left, and doubly censored data.
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.3.3
Imports: survival, interval, stats, utils, ggplot2
Suggests: knitr, rmarkdown, PWEXP, testthat (≥ 3.0.0)
Depends: R (≥ 3.5)
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2026-05-05 20:42:34 UTC; mahmudur_asif
Author: Mohammod Mahmudur Rahman [aut, cre], Leonidas Bantis [aut]
Repository: CRAN
Date/Publication: 2026-05-11 18:50:31 UTC

ROC-Based Methods for Comparing Survival Distributions with Right, Left, and Doubly Censored Data

Description

Performs nonparametric and semiparametric comparisons of two survival distributions under right, left, or double censoring using ROC-based metrics, including ROC curve length, overlap coefficient (OVL), and a joint ROC length–OVL test.

Usage

surv.comp(
  time,
  status,
  group,
  censor_type,
  method,
  n_perm,
  progress = TRUE,
  plot = FALSE
)

Arguments

time

Numeric vector of observed follow-up times (event or censoring times) for all observations.

status

Numeric vector indicating censoring status for each observation:

  • For censor_type = "right": 0 = event, 1 = right-censored

  • For censor_type = "left": 0 = event, -1 = left-censored

  • For censor_type = "double": 0 = event, 1 = right-censored, -1 = left-censored.

group

Numeric vector indicating the group label for each observation. Must contain exactly two groups coded as 1 and 2.

censor_type

Character string specifying the type of censoring. Must be either "right", "left", or "double".

method

Character string specifying the test to perform. Must be one of:

  • "roc_length": ROC curve length-based test

  • "ovl": overlap coefficient-based test

  • "joint_method": joint ROC length-OVL-based test

n_perm

Integer specifying the number of permutation samples used to compute p-values. A small value is used in the example for computational efficiency; larger values are recommended in practice (typically 50,000 or more) to obtain more stable and reliable inference.

progress

Logical value indicating whether to display a progress bar during the permutation test. Default is TRUE. If FALSE, the computation runs silently without showing progress updates.

plot

Logical value indicating whether to generate a convex hull plot based on the joint ROC length–OVL test. Default is FALSE. Plotting is only available when method = "joint_method"; otherwise, an error is returned if plot = TRUE.

Details

This function implements permutation-based two-sided hypothesis tests for comparing two survival distributions without relying on proportional hazards assumptions. The ROC length measures global separation between survival curves, while the overlap coefficient (OVL) quantifies distributional similarity. Density estimation is performed using nonparametric kernel methods, where the cumulative distribution function (CDF) is estimated using the Kaplan–Meier estimator under right censoring and the Turnbull estimator under left and double censoring.

Value

A list containing:

References

Pepe MS (2003). The Statistical Evaluation of Medical Tests for Classification and Prediction. Oxford University Press.

Bantis LE, Tsimikas JV, Chambers G, Capello M, Hanash S, Feng Z (2021). The length of the ROC curve and the two cutoff Youden index within a robust framework for discovery, evaluation, and cutoff estimation in biomarker studies involving improper ROC curves. Statistics in Medicine, 40(7), 1767–1789.

Franco-Pereira AM, Nakas CT, Reiser B, Pardo MC (2021). Inference on the overlap coefficient: The binormal approach and alternatives. Statistical Methods in Medical Research, 30(12), 2672–2684.

Examples

# Example usage
library(ROCsurvcomp)
library(PWEXP)

# Generating right-censored data with crossing survivals
set.seed(126)
n_trt <- 50
break_trt <- c(2, 4)
rate_trt <- c(log(2)/3, log(2)/7, log(2)/20)
rate.censor_trt <- c(log(2)/55, log(2)/62, log(2)/68)
event_trt <- PWEXP::rpwexp(n_trt, rate = rate_trt, breakpoint = break_trt)
censor_trt <- PWEXP::rpwexp(n_trt, rate = rate.censor_trt, breakpoint = break_trt)
n_ctrl <- 50
rate_ctrl <- log(2)/10
rate.censor_ctrl <- log(2)/58
event_ctrl <- rexp(n_ctrl, rate = rate_ctrl)
censor_ctrl <- rexp(n_ctrl, rate = rate.censor_ctrl)

# Observed time and censoring status (0 = event, 1 = right-censored)
time_trt <- pmin(event_trt, censor_trt)
status_trt <- ifelse(event_trt <= censor_trt, 0, 1)
time_ctrl <- pmin(event_ctrl, censor_ctrl)
status_ctrl <- ifelse(event_ctrl <= censor_ctrl, 0, 1)
time <- c(time_trt, time_ctrl)
status <- c(status_trt, status_ctrl)
group <- c(rep(1, n_trt), rep(2, n_ctrl))

# Run surv.comp()
# Note: n_perm = 10 is used here only for illustration purposes.
# Highly recommended n_perm to be set at 50,000 or more.
surv.comp(time = time, status = status, group = group, censor_type = "right",
          method = "roc_length", n_perm = 10, progress = TRUE, plot = FALSE)