Interpretation, reliability summaries, and resumable tuning

The executable English example is system.file("examples/07_interpretation_reliability_workflow.R", package = "survlearning"). It uses the Cox and parametric AFT engines already supplied by the mandatory survival dependency. No Torch, Python, or additional plotting framework is needed.

Interpreting a fixed predictor

The following small example is self-contained. Censoring is generated independently of failure conditional on the two predictors, which are fixed at the time origin.

set.seed(20261026)
d <- data.frame(load = runif(300, -1, 1), design = rbinom(300, 1, .5))
failure_time <- rexp(300, rate = .02 * exp(.8 * d$load - .3 * d$design))
censor_time <- pmin(80, rexp(300, rate = .02 * exp(.6 * d$load)))
d$time <- pmin(failure_time, censor_time)
d$event <- as.integer(failure_time <= censor_time)
train <- d[1:200, ]
test <- d[201:300, ]
f <- Surv(time, event) ~ load + design
fit <- surv_fit(f, train, "cox")
profiles <- data.frame(load = c(-.5, .5), design = c(0, 1))
importance <- surv_importance(fit, test, n_repeats = 3, seed = 10)
effects <- surv_ale(fit, test, variable = "load", bins = 10,
  type = "failure", time = 10)
plot(importance)

plot(effects)

Permutation importance is the decrease in Harrell concordance after permuting original predictor columns. A named list groups columns for a shared permutation. Formula transformations are reevaluated; no fit is changed. SD measures only permutation variation. Correlated predictors complicate marginal importance. ALE accumulates within-bin prediction differences and centers upper-bin values by empirical frequencies. Repeated quantile boundaries and empty bins are merged. Neither calculation estimates a causal effect or supplies an uncertainty interval. Do not repeatedly select features using a final test sample.

Remaining-time summaries

remaining <- surv_reliability(fit, profiles, age = 5,
  horizons = c(10, 20), probs = c(.1, .5), grid_points = 501)
remaining$summary
#>          observation age horizon  survival   failure restricted_remaining_mean
#> t=15.00            1   5      10 0.8411914 0.1588086                  9.207807
#> t=25.00            1   5      20 0.7275031 0.2724969                 17.111741
#> t=15.001           2   5      10 0.7983135 0.2016865                  8.984909
#> t=25.001           2   5      20 0.6607485 0.3392515                 16.349294
remaining$quantiles
#>   observation age probability remaining_time                     status
#> 1           1   5         0.1           6.72            reached_on_grid
#> 2           1   5         0.5             NA not_reached_within_horizon
#> 3           2   5         0.1           4.96            reached_on_grid
#> 4           2   5         0.5             NA not_reached_within_horizon

With fixed covariates, conditional survival is S(age+u|x)/S(age|x). The restricted remaining mean uses trapezoidal integration only to the supplied horizon. Quantiles are first grid crossings; unreached quantiles remain missing. This does not estimate unrestricted lifetime, cure, or a prediction interval. Attained time refers to the fitted model’s origin, not necessarily installation. Requests beyond follow-up require explicit parametric extrapolation; risk-only models cannot provide these summaries.

Conditional censoring weights

g <- surv_censor_fit(Surv(time, event) ~ load + design, train, method = "cox")
surv_evaluate(fit, test, c("ipcw_c", "auc", "brier"),
  times = 10, tau = 15, censoring_model = g)
#>   metric time  estimate lower upper   n events status message
#> 1 ipcw_c   15 0.6608440    NA    NA 100     49     ok        
#> 2    auc   10 0.6935472    NA    NA 100     49     ok        
#> 3  brier   10 0.1558383    NA    NA 100     49     ok

The formula uses the original failure indicator, not an already reversed indicator. Methods are "km", "stratified", and "cox". Cox is a working proportional-hazards model for censoring; its adequacy is an assumption. Stratified KM supports joint categorical groups with observed reference support. At tied times, original failures depart before censoring hazards are estimated. Event weights use G(T-|x); control weights use G(t|x). No silent clipping or extrapolation repairs a lack of support.

Conditional AUC weights both cases and controls. The "ipcw_c" criterion uses strictly ordered pairs and weight 1/{G(T_i-|x_i) G(T_i|x_j)}. It is deliberately distinct from historical marginal "uno". Bootstrap intervals condition on the fixed event and censoring fits. Within surv_tune() and surv_validate(), supply a formula or list specification through censoring; it is refitted on each analysis fold, never globally.

Local parallel execution and recovery

checkpoint <- tempfile("survlearning-vignette-")
tuned <- surv_tune(f, train, "aft",
  grid = list(distribution = c("weibull", "lognormal")), folds = 2,
  workers = 2, seed = 20, checkpoint = checkpoint)
# Repeat exactly to reuse committed folds and the completed winning refit.
resumed <- surv_tune(f, train, "aft",
  grid = list(distribution = c("weibull", "lognormal")), folds = 2,
  workers = 2, seed = 20, checkpoint = checkpoint)
resumed$execution
#> $workers_requested
#> [1] 2
#> 
#> $workers_used
#> [1] 0
#> 
#> $resumed_jobs
#> [1] 4
#> 
#> $computed_jobs
#> [1] 0
#> 
#> $checkpoint
#> [1] "C:/Users/pedro/AppData/Local/Temp/Rtmpctsygm/survlearning-vignette-11b04632a5284"
#> 
#> $resumption
#> [1] "same data, row order, grid, resamples, metric, settings, R/platform and engine versions"
#> 
#> $refit_reused
#> [1] TRUE
#> 
#> $elapsed_seconds
#> [1] 0.01
stopifnot(resumed$execution$computed_jobs == 0L,
  resumed$execution$refit_reused)

Defaults remain serial and disk-free. Local PSOCK tasks are grouped by analysis fold to preserve SVM workspace reuse. Data, formulas, row order, fold plan, parameters, seeds, RNG/contrast settings, and software versions must match a checkpoint. Captured custom closures are not portable. Failed folds remain ineligible; retry_failed = TRUE explicitly retries their records. Within-fold solver warm-start histories are rebuilt, not restored. Only one live search may own a directory. Ordinary errors release its lock; after a hard crash, confirm no process remains before removing a stale lock. Workers duplicate data and numerical workspaces. Set engine threads = 1 when using multiple workers, and choose their number to fit available memory. Neither a universal speedup nor aggregate-memory monitoring is promised.

mirror server hosted at Truenetwork, Russian Federation.