Skip to contents

Analysis results data for survival quantiles and x-year survival estimates, extracted from a survival::survfit() model.

Usage

ard_survival_survfit(x, times = NULL, probs = NULL, type = NULL)

Arguments

x

(survival::survfit())
a survival::survfit() object. See below for details.

times

(numeric)
a vector of times for which to return survival probabilities.

probs

(numeric)
a vector of probabilities with values in (0,1) specifying the survival quantiles to return.

type

(string or NULL)
type of statistic to report. Available for Kaplan-Meier time estimates only, otherwise type is ignored. Default is NULL. Must be one of the following:

typetransformation
"survival"x
"risk"1 - x
"cumhaz"-log(x)

Value

an ARD data frame of class 'card'

Details

  • Only one of either the times or probs parameters can be specified.

  • Times should be provided using the same scale as the time variable used to fit the provided survival fit model.

Examples

library(survival)
library(ggsurvfit)

survfit(Surv_CNSR(AVAL, CNSR) ~ TRTA, cards::ADTTE) |>
  ard_survival_survfit(times = c(60, 180))
#> {cards} data frame: 30 x 11
#>    group1 group1_level variable variable_level stat_name stat_label  stat
#> 1    TRTA      Placebo     time             60    n.risk  Number o…    59
#> 2    TRTA      Placebo     time             60  estimate  Survival… 0.768
#> 3    TRTA      Placebo     time             60 std.error  Standard… 0.047
#> 4    TRTA      Placebo     time             60 conf.high  CI Upper… 0.866
#> 5    TRTA      Placebo     time             60  conf.low  CI Lower… 0.682
#> 6    TRTA      Placebo     time            180    n.risk  Number o…    35
#> 7    TRTA      Placebo     time            180  estimate  Survival… 0.626
#> 8    TRTA      Placebo     time            180 std.error  Standard… 0.056
#> 9    TRTA      Placebo     time            180 conf.high  CI Upper… 0.746
#> 10   TRTA      Placebo     time            180  conf.low  CI Lower… 0.526
#>  20 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error

survfit(Surv_CNSR(AVAL, CNSR) ~ TRTA, cards::ADTTE) |>
  ard_survival_survfit(probs = c(0.25, 0.5, 0.75))
#> {cards} data frame: 27 x 11
#>    group1 group1_level variable variable_level stat_name stat_label stat
#> 1    TRTA      Placebo     prob           0.25  estimate  Survival…   70
#> 2    TRTA      Placebo     prob           0.25 conf.high  CI Upper…  177
#> 3    TRTA      Placebo     prob           0.25  conf.low  CI Lower…   35
#> 4    TRTA      Placebo     prob            0.5  estimate  Survival…   NA
#> 5    TRTA      Placebo     prob            0.5 conf.high  CI Upper…   NA
#> 6    TRTA      Placebo     prob            0.5  conf.low  CI Lower…   NA
#> 7    TRTA      Placebo     prob           0.75  estimate  Survival…   NA
#> 8    TRTA      Placebo     prob           0.75 conf.high  CI Upper…   NA
#> 9    TRTA      Placebo     prob           0.75  conf.low  CI Lower…   NA
#> 10   TRTA    Xanomeli…     prob           0.25  estimate  Survival…   14
#>  17 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error

# Competing Risks Example ---------------------------
set.seed(1)
ADTTE_MS <- cards::ADTTE %>%
  dplyr::mutate(
    CNSR = dplyr::case_when(
      CNSR == 0 ~ "censor",
      runif(dplyr::n()) < 0.5 ~ "death from cancer",
      TRUE ~ "death other causes"
    ) %>% factor()
  )

survfit(Surv(AVAL, CNSR) ~ TRTA, data = ADTTE_MS) %>%
  ard_survival_survfit(times = c(60, 180))
#> Multi-state model detected. Showing probabilities into state 'death from
#> cancer'.
#> {cards} data frame: 30 x 11
#>    group1 group1_level variable variable_level stat_name stat_label  stat
#> 1    TRTA      Placebo     time             60    n.risk  Number o…    59
#> 2    TRTA      Placebo     time             60  estimate  Survival… 0.054
#> 3    TRTA      Placebo     time             60 std.error  Standard… 0.026
#> 4    TRTA      Placebo     time             60 conf.high  CI Upper…  0.14
#> 5    TRTA      Placebo     time             60  conf.low  CI Lower… 0.021
#> 6    TRTA      Placebo     time            180    n.risk  Number o…    35
#> 7    TRTA      Placebo     time            180  estimate  Survival… 0.226
#> 8    TRTA      Placebo     time            180 std.error  Standard… 0.054
#> 9    TRTA      Placebo     time            180 conf.high  CI Upper… 0.361
#> 10   TRTA      Placebo     time            180  conf.low  CI Lower… 0.142
#>  20 more rows
#>  Use `print(n = ...)` to see more rows
#>  4 more variables: context, fmt_fn, warning, error