Predicted median survival time
predict_surv_time.RdGet the survival time at a given probability of survival. A convenience
wrapper for survival::quantile.survfit.
Arguments
- object
An object of either
- df
A data frame in which to interpret the variables in
object.For
object = survival::coxph, may beNULLor the usualnewdatastyle argument.For
object = formula, must be the data frame used for fitting insurvival::survfit.
- probs
A numeric vector of probabilities. This argument applies to the cumulative distribution function F(t) = 1-S(t). For example,
prob = 0.9will return the survival time at the point of 10% probability of surviving.- conf.level
The level for a two-sided confidence interval on the survival time(s). Default is 0.95.
- scale
A numeric value to rescale the survival time, e.g., if the input data to survfit were in days, scale = 365.25 would scale the output to years.
- ...
Optional arguments passed to
survival::survfit.
Details
If the survival curve or its confidence limits do not cross the probability of
interest (i.e. they extend out to infinity time without crossing the chosen
probability), then NA is returned for the time estimate.
The probabilities are defined using the cumulative distribution function
F(t) = 1-S(t). For example, prob = 0.9 will return the survival time at the
point of 10% probability of surviving.
Examples
#----------------------------------------------------------------------------
# surv_time() examples.
#----------------------------------------------------------------------------
library(survival)
library(bkstat)
bkstat::predict_surv_time(
object = coxph(Surv(time, status) ~ sex + ph.ecog, data = lung),
df = data.frame(expand.grid(sex = 1:2, ph.ecog = 0:3)),
probs = c(0.5, 0.9)
)
#> sex ph.ecog prob time lower_ci upper_ci
#> 1 1 0 0.1 883 731 NA
#> 2 1 1 0.1 655 574 765
#> 3 1 2 0.1 455 363 624
#> 4 1 3 0.1 310 230 524
#> 5 2 0 0.1 NA NA NA
#> 6 2 1 0.1 NA 765 NA
#> 7 2 2 0.1 689 558 NA
#> 8 2 3 0.1 473 350 814
#> 9 1 0 0.5 371 310 524
#> 10 1 1 0.5 283 223 329
#> 11 1 2 0.5 186 166 245
#> 12 1 3 0.5 145 105 210
#> 13 2 0 0.5 583 455 791
#> 14 2 1 0.5 390 337 533
#> 15 2 2 0.5 286 222 371
#> 16 2 3 0.5 197 163 340
bkstat::predict_surv_time(
Surv(time, status) ~ sex + ph.ecog,
df = lung,
probs = c(0.5, 0.9)
)
#> sex ph.ecog prob time lower_ci upper_ci
#> 1 1 0 0.1 883 643 NA
#> 2 1 1 0.1 624 519 NA
#> 3 1 2 0.1 533 329 NA
#> 4 1 3 0.1 118 NA NA
#> 5 2 0 0.1 NA 705 NA
#> 6 2 1 0.1 765 731 NA
#> 7 2 2 0.1 654 444 NA
#> 8 1 0 0.5 353 303 558
#> 9 1 1 0.5 239 207 363
#> 10 1 2 0.5 166 105 288
#> 11 1 3 0.5 118 NA NA
#> 12 2 0 0.5 705 350 NA
#> 13 2 1 0.5 450 345 687
#> 14 2 2 0.5 239 199 444
bkstat::predict_surv_time(
object = coxph(Surv(time, status) ~ 1, lung),
probs = c(0.5, 0.9)
)
#> prob time lower_ci upper_ci
#> 1 0.1 765 689 NA
#> 2 0.5 310 285 363
bkstat::predict_surv_time(
Surv(time, status) ~ 1,
df = lung,
probs = c(0.5, 0.9)
)
#> prob time lower_ci upper_ci
#> 1 0.1 735 689 NA
#> 2 0.5 310 285 363