Skip to contents

predict() reads the survival curve (or the cumulative hazard) of each group at the given times. summary() gives the fuller table at those times that sits under a survival plot: the number at risk, the events and censorings since the previous time, and the estimate with its standard error and confidence limits.

Usage

# S3 method for class 'kaplan_meier'
predict(object, times, what = c("survival", "cumhaz"), ...)

# S3 method for class 'kaplan_meier'
summary(object, times, ...)

Arguments

object

A kaplan_meier() fit.

times

One or more times.

what

"survival" (the default) for the survival probability, or "cumhaz" for the cumulative hazard.

...

Unused.

Value

predict() gives a data frame with one row per group and time: strata, the grouping variables, time, and estimate. summary() gives strata, the grouping variables, time, n_risk, n_event, n_censor, estimate, std_error, conf_low, and conf_high. Times are sorted in summary(), and the events and censorings are those after the previous time (from the start for the first time) up to and including this one. The number at risk is 0 after the last observed time.

Details

The curves are right-continuous step functions, so the value at time \(t\) is the last step at a time \(\le t\). Before the first step the survival is 1 and the cumulative hazard 0. The cumulative hazard is the Nelson-Aalen estimate, \(\sum_{t_i \le t} d_i / n_i\).

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2),
  sex = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2)
)
fit <- kaplan_meier(Surv(time, status) ~ sex, data = lung)
predict(fit, times = c(200, 400))
#>   strata sex time estimate
#> 1  sex=1   1  200      1.0
#> 2  sex=1   1  400      0.6
#> 3  sex=2   2  200      0.8
#> 4  sex=2   2  400      0.2
summary(fit, times = c(0, 250, 500))
#>   strata sex time n_risk n_event n_censor estimate std_error   conf_low
#> 1  sex=1   1    0      5       0        0      1.0 0.0000000 1.00000000
#> 2  sex=1   1  250      4       1        0      0.8 0.1788854 0.51612576
#> 3  sex=1   1  500      2       2        0      0.4 0.2190890 0.13672178
#> 4  sex=2   2    0      5       0        0      1.0 0.0000000 1.00000000
#> 5  sex=2   2  250      3       2        0      0.6 0.2190890 0.29331643
#> 6  sex=2   2  500      1       2        0      0.2 0.1788854 0.03464912
#>   conf_high
#> 1         1
#> 2         1
#> 3         1
#> 4         1
#> 5         1
#> 6         1