bootkm.Rd
Bootstraps Kaplan-Meier estimate of the probability of survival to at
least a fixed time (times
variable) or the estimate of the q
quantile of the survival distribution (e.g., median survival time, the
default).
bootkm(S, q=0.5, B=500, times, pr=TRUE)
a Surv
object for possibly right-censored survival time
quantile of survival time, default is 0.5 for median
number of bootstrap repetitions (default=500)
time vector (currently only a scalar is allowed) at which to compute
survival estimates. You may specify only one of q
and
times
, and if times
is specified q
is ignored.
set to FALSE
to suppress printing the iteration number every
10 iterations
a vector containing B
bootstrap estimates
updates .Random.seed
, and, if pr=TRUE
, prints progress
of simulations
bootkm
uses Therneau's survfitKM
function to efficiently
compute Kaplan-Meier estimates.
Akritas MG (1986): Bootstrapping the Kaplan-Meier estimator. JASA 81:1032–1038.
# Compute 0.95 nonparametric confidence interval for the difference in
# median survival time between females and males (two-sample problem)
set.seed(1)
library(survival)
S <- Surv(runif(200)) # no censoring
sex <- c(rep('female',100),rep('male',100))
med.female <- bootkm(S[sex=='female',], B=100) # normally B=500
#> 10
20
30
40
50
60
70
80
90
100
med.male <- bootkm(S[sex=='male',], B=100)
#> 10
20
30
40
50
60
70
80
90
100
describe(med.female-med.male)
#> med.female - med.male
#> n missing distinct Info Mean pMedian Gmd .05
#> 100 0 87 1 -0.01575 -0.01962 0.08495 -0.12179
#> .10 .25 .50 .75 .90 .95
#> -0.11216 -0.08030 -0.01734 0.01819 0.09412 0.15126
#>
#> lowest : -0.139027 -0.136873 -0.136775 -0.122804 -0.121741
#> highest: 0.151802 0.152362 0.154363 0.157939 0.160357
quantile(med.female-med.male, c(.025,.975), na.rm=TRUE)
#> 2.5% 97.5%
#> -0.1301387 0.1534129
# na.rm needed because some bootstrap estimates of median survival
# time may be missing when a bootstrap sample did not include the
# longer survival times