| unsurv_stability | R Documentation |
Computes a resampling-based stability score for a fitted unsurv model
using the Adjusted Rand Index (ARI) computed on overlap sets across resamples.
unsurv_stability(
S,
times,
fit,
B = 30,
frac = 0.5,
mode = c("bootstrap", "subsample"),
jitter_sd = 0.01,
weight_perturb = 0.3,
eps_jitter = 0.02,
return_distribution = TRUE
)
S |
Numeric matrix of survival probabilities used for stability assessment
( |
times |
Numeric vector of time grid points (length |
fit |
An object of class |
B |
Integer; number of resamples. |
frac |
Numeric in (0, 1]; fraction of rows sampled per resample. |
mode |
Resampling mode: |
jitter_sd |
Nonnegative numeric; curve-space noise level applied before clamping/monotone enforcement. |
weight_perturb |
Numeric in |
eps_jitter |
Nonnegative numeric; feature-space jitter used inside the clustering during resamples. |
return_distribution |
Logical; if |
If return_distribution = TRUE, a list with:
mean: mean ARI across resample-pair overlaps
aris: numeric vector of ARIs
Otherwise, returns a single numeric mean ARI.
if (requireNamespace("cluster", quietly = TRUE)) {
set.seed(2025)
n <- 60; Q <- 40
times <- seq(0, 5, length.out = Q)
rates <- c(0.12, 0.38, 0.8)
grp <- sample(1:3, n, TRUE, c(0.4, 0.4, 0.2))
S <- t(vapply(1:n, function(i)
pmin(pmax(exp(-rates[grp[i]] * times) + rnorm(Q, 0, 0.01), 0), 1),
numeric(Q)
))
fit <- unsurv(S, times, K = NULL, K_max = 6, distance = "L2",
enforce_monotone = TRUE, standardize_cols = FALSE,
eps_jitter = 0, seed = NULL)
stab <- unsurv_stability(S, times, fit, B = 8, frac = 0.55, mode = "bootstrap",
jitter_sd = 0.3, weight_perturb = 0.0, eps_jitter = 0.3,
return_distribution = TRUE)
stab$mean
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.