The main function to generate a predictive conformal confidence interval for a unit's survival time.
cfsurv( x, c_list = NULL, pr_list = NULL, pr_new_list = NULL, Xtrain, C, event, time, alpha = 0.05, seed = 24601, model = "aft", dist = "weibull", I_fit = NULL, ftol = 0.1, tol = 0.1, n.tree = 500 )
x | a vector of the covariate for test point. |
---|---|
c_list | the cutoff for the censoring time (a positive number or a vector). |
pr_list | the censoring probability at the cutoff for the fitting and calibration datasets. |
pr_new_list | the censoring probability at the cutoff for the test points. |
Xtrain | a n-by-p matrix of the covariate of the training data. |
C | a length n vector of the censoring time of the training data. |
event | a length n vector of indicators if the time observed is censored. TRUE corresponds to NOT censored, and FALSE censored. |
time | a vevtor of length n, containing the observed survival time. |
alpha | a number between 0 and 1, speciifying the miscoverage rate. |
seed | an integer random seed (default: 24601). |
model | Options include "aft", "np", "randomforest", "Powell", "Portnoy", "PengHuang", "distBoost", "quantBoost", "gpr". This determines the model used to fit the conformal score (default: "cox"). |
dist | either "weibull", "exponential" or "gaussian" (default: "weibull"). The distribution of T used in the AFT model. |
I_fit | The set of indices corresponding to the fitting data set. (Default: NULL) |
# 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 with c0 = 30 c0 <- 30 pr_list <- rep(0.5, n) pr_new_list <- rep(0.5, n_test) 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)))#> The coverage is 0.932.