unsurv-package: unsurv: Unsupervised clustering of individualized survival...

unsurv-packageR Documentation

unsurv: Unsupervised clustering of individualized survival curves

Description

The unsurv package provides tools for unsupervised clustering of individualized survival curves using medoid-based clustering (PAM).

Details

It is designed for settings where each individual is represented by a survival probability curve evaluated on a common time grid, such as predictions from:

  • Kaplan–Meier estimates,

  • Cox models,

  • parametric survival models,

  • deep learning survival models,

  • or other individualized survival predictors.

Core features include:

  • PAM clustering using weighted L1 or L2 distances,

  • automatic cluster selection via silhouette width,

  • optional monotonicity enforcement,

  • optional median smoothing,

  • prediction of cluster membership for new curves,

  • stability assessment via resampling and Adjusted Rand Index,

  • base R and ggplot2 visualization methods.

Main functions:

  • unsurv — fit clustering model

  • predict.unsurv — predict cluster membership

  • plot.unsurv — plot medoid curves

  • summary.unsurv — summarize clustering

  • unsurv_stability — assess stability

Author(s)

Imad EL BADISY

References

Kaufman, L., & Rousseeuw, P. J. (1990). Finding Groups in Data: An Introduction to Cluster Analysis. Wiley.

See Also

Useful links:

Examples

if (requireNamespace("cluster", quietly = TRUE)) {
  set.seed(1)
  n <- 10
  times <- seq(0, 5, length.out = 40)
  rates <- sample(c(0.2, 0.6), n, TRUE)
  S <- sapply(times, function(t) exp(-rates * t))

  fit <- unsurv(S, times, K = 2)
  plot(fit)
}

unsurv documentation built on Sept. 1, 2026, 1:06 a.m.