boot_km_ratio: Bootstrap CI for an SBW-weighted KM survival ratio

View source: R/km_ratio.R

boot_km_ratioR Documentation

Bootstrap CI for an SBW-weighted KM survival ratio

Description

Bootstraps the standard error of km_ratio_greenwood()'s log-ratio, then builds either a Wald CI (log scale) or a percentile CI (log scale). If the point estimate or bootstrap SE come out non-finite, falls back to the unadjusted KM ratio and sets MC_fail = TRUE; if even the unadjusted ratio is undefined (a double-degenerate case with no valid fallback), throws an error rather than returning a nonsense finite estimate. If the SBW fit or weighted KM ratio fails on an individual bootstrap resample, the unadjusted KM ratio is used for that resample; boot_fail_rate reports the fraction of resamples where this happened.

Usage

boot_km_ratio(
  time,
  status,
  A,
  X_subset,
  t0,
  B = 1500,
  alpha = 0.05,
  ci_method = c("wald", "percentile"),
  seed = NULL
)

Arguments

time

Event/censoring time.

status

Event indicator (1 = event, 0 = censored).

A

Treatment indicator (0/1).

X_subset

Covariate data frame for the full study sample, used to fit the SBW weights.

t0

Time at which to evaluate the survival ratio.

B

Number of bootstrap replicates.

alpha

Significance level for the confidence interval (default 0.05).

ci_method

Either "wald" (default) or "percentile".

seed

Optional seed set at the start of the bootstrap.

Value

A list with MC_fail, log_est, est, se_log, ci_log, ci, boot_fail_rate, boot_n_finite_reps, and SBW clipping diagnostics (sbw_n_clipped_full, sbw_max_abs_clipped_full, sbw_n_clipped_boot_mean, sbw_n_clipped_boot_max, sbw_max_abs_clipped_boot_max).


sbwadjust documentation built on Oct. 10, 2026, 5:08 p.m.