Survival Confidence Band - Tutorial (RLT)
Ruoqing Zhu
Last Updated: October 27, 2026
Source:vignettes/articles/confidence-interval.Rmd
confidence-interval.RmdOverview
This page demonstrates uncertainty bands for the conditional survival
curve at chosen predictor values. These describe uncertainty about the
curve, not a prediction interval for an individual’s event time. The
example uses the smoothed approach in get.surv.band().
Assess how much information supports each estimated curve:
- Target predictor values should be represented in the training data, especially for the important variables, to limit extrapolation.
- Inspect the number of observations still at risk over time. The far tail has less support when few observations remain under follow-up without an event.
Data
We simulate right-censored survival data from a proportional hazards model. The first and third predictors carry signal; the rest are noise.
Target Points
We choose two target points at interior quantiles of the important
variables X1 and X3. The remaining variables
are fixed at their training medians.
target_base <- apply(X, 2, median)
testX <- matrix(rep(target_base, times = 2), nrow = 2, byrow = TRUE)
colnames(testX) <- colnames(X)
testX[, 1] <- quantile(X[, 1], probs = c(0.35, 0.65))
testX[, 3] <- quantile(X[, 3], probs = c(0.35, 0.65))
rownames(testX) <- c("Interior lower-risk target", "Interior higher-risk target")
testX[, c(1, 3)]
## X1 X3
## Interior lower-risk target -0.5695469 -0.3250708
## Interior higher-risk target 0.4737417 0.4440657Fit and Predict with Variance
We use var.mode = "matched" to estimate the covariance
of the predicted cumulative hazard over time, which is the scale used by
the confidence-band calculation. Matched mode requires an even number of
trees and uses paired half-samples without replacement. Here the 1,000
trees form 500 pairs; the required sampling settings are explicit in the
call. This mode automatically enables distributed importance when
importance = FALSE.
fit <- RLT(
X, Y, Censor, model = "survival",
ntrees = 1000, mtry = min(p, 10), nmin = 5,
nsplit = 3,
resample.prob = 0.5, resample.replace = FALSE,
importance = FALSE, verbose = FALSE,
ncores = 1,
var.mode = "matched",
split.rule = "logrank"
)
RLTPred <- predict(fit, testX, var.est = TRUE, ncores = 1)Choose a Display Range
The prediction object includes the full observed failure-time grid.
For this example, we display only
and report the smallest risk-set count in that range. Time 2 is a
display choice, not a validated threshold for adequate support. The band
below is still constructed using every time in
RLTPred$timepoints.
risk_set <- vapply(RLTPred$timepoints, function(t) sum(Y >= t), integer(1))
plot_time_max <- 2
plot_id <- which(RLTPred$timepoints <= plot_time_max)
if (length(plot_id) == 0) {
plot_id <- 1
}
list(
Plot_Time_Range = "t <= 2",
Minimum_At_Risk_in_Plotted_Range = min(risk_set[plot_id]),
Number_of_Plotted_Timepoints = length(plot_id)
)
## $Plot_Time_Range
## [1] "t <= 2"
##
## $Minimum_At_Risk_in_Plotted_Range
## [1] 24
##
## $Number_of_Plotted_Timepoints
## [1] 140Simultaneous Confidence Band
With alpha = 0.05, get.surv.band()
constructs a nominal 95% simultaneous band for the conditional survival
curve over the returned time grid. The default i = 0
returns a separate band for each target point; the nominal coverage
applies to each curve separately, not jointly across the two targets or
over every time between grid points.
The computed reference curve is exp(-RLTPred$CHF). The
function first constructs a band around RLTPred$CHF on the
cumulative-hazard scale, then transforms its limits to the survival
scale. For an ordinary survival forest the reference curve equals the
returned $Survival; linear combination forests instead
return the mean of tree product-limit curves, whose sampling variation
is not directly estimated by this CHF-based calculation.
The smoothed approach uses a low-rank covariance approximation and a
residual correction to form the marginal standardizing scales. Here
k_rank = 10 allows up to ten components in that
approximation. The Gaussian simulations retain the original supplied
covariance. The nsim simulations estimate the critical
value needed for simultaneous coverage over the grid.
SurvBand <- get.surv.band(RLTPred, alpha = 0.05, approach = "smoothed",
k_rank = 10, nsim = 5000)
par(mfrow = c(1, 2), mar = c(4, 4, 3, 1))
for (i in seq_len(nrow(testX))) {
tp <- RLTPred$timepoints[plot_id]
S <- exp(-as.numeric(RLTPred$CHF[i, plot_id]))
truth <- exp(-xlink(testX)[i] * tp)
b_lower <- pmin(pmax(as.numeric(SurvBand[[i]]$lower)[plot_id], 0), 1)
b_upper <- pmin(pmax(as.numeric(SurvBand[[i]]$upper)[plot_id], 0), 1)
plot(tp, S, type = "n", ylim = c(0, 1),
xlab = "Time", ylab = "Survival Probability",
main = rownames(testX)[i])
polygon(c(tp, rev(tp)), c(b_lower, rev(b_upper)),
col = rgb(0.23, 0.51, 0.96, 0.25), border = NA)
lines(tp, truth, col = "#E41A1C", lwd = 2, lty = 2)
lines(tp, S, type = "s", lwd = 2)
legend("topright",
legend = c("Estimated S(t)", "True S(t)", "Simultaneous 95% Band"),
lty = c(1, 2, NA), lwd = c(2, 2, NA),
col = c("black", "#E41A1C", NA),
fill = c(NA, NA, rgb(0.23, 0.51, 0.96, 0.35)),
border = c(NA, NA, NA),
bty = "n", cex = 0.75)
}
The higher-risk target has larger values of both signal variables, so
its true survival curve falls faster. The black curve is the estimate
exp(-RLTPred$CHF) of the conditional survival curve, and
the shaded band describes uncertainty about that target curve. A nominal
95% simultaneous band need not contain the true curve in every simulated
dataset; this one simulation does not establish coverage. Each band was
constructed on the full returned grid, with only the portion through
time 2 displayed here.
Optional Rank Selection
The rank controls the covariance approximation used for the marginal
scales. Instead of a fixed k_rank, the smoothed approach
can choose it by cumulative eigenvalue proportion:
SurvBand_prop <- get.surv.band(
RLTPred, alpha = 0.05,
approach = "smoothed",
k_mode = "proportion",
k_prop = 0.95
)Increasing nsim reduces Monte Carlo variability in the
estimated critical value at the cost of runtime. It does not change the
fitted forest or the supplied covariance used in simulation. See
get.surv.band() for the smoothing details and the fallback
to the naive calculation with fewer than three time points.