An R package that implements the conformalized survival analysis methodology.
The goal of cfsurvival is to provide a lower predictive lower bound for the survival time of an individual, with the guarantee that with probability (1-$\alpha$) it is no larger than the true survival time.
To install this package, run the following command in your R console:
if (!require("devtools")){
install.packages("devtools")
}
devtools::install_github("zhimeir/cfsurvival")
The following R packages (version 4.0.2) packages are required:
- quantreg
- grf
- quantregForest
- randomForestSRC
- survival
- tidyverse
- fishmethods
- foreach
- doParallel
- GauPro
- gbm
- np
- conTree
# Library the package
library(cfsurvival)
# Generate data
set.seed(24601)
n <- 2000
X <- runif(n, 0, 2)
T <- exp(X + rnorm(n,0,1))
C <- rexp(n, rate = 0.05)
event <- (T <= C)
censored_T <- pmin(T, C)
data <- data.frame(X = X, C = C, event = event, censored_T = censored_T)
# Prediction point
n_test <- 1000
X_test <- runif(n_test, 0, 2)
T_test <- exp(X_test + rnorm(n,0,1))
# Running cfsurvival under completely independent censoring with c0 = 30
c0 <- 30
pr_list <- rep(0.5, n)
pr_new_list <- rep(0.5, n_test)
# Use the Cox model
res <- cfsurv(x = X_test, c_list = c0, pr_list = pr_list, pr_new_list = pr_new_list,
Xtrain = X, C = C, event = event, time = censored_T,
alpha = 0.1, model = "aft")
# Examine the result
cat(sprintf("The coverage is %.3f.\n", mean(res <= T_test)))
This packakge is is distributed under the MIT license.