Skip to contents

This function takes a survfit object and extracts time estimates, together with the number of events and number of risk. Based on the user specification of time units - either days or years - the function then creates a full sequence of time and event/risk number estimates from 0 to a user-specified maximum age.

Usage

convert_survfit2tibble(
  obj_survfit,
  time_in = c("days", "years"),
  age_max_years = 120L
)

Arguments

obj_survfit

A survfit object generated using survival::survfit() or survival::survfit0().

time_in

Unit in which time is reported. Either days or years.

age_max_years

Maximum age, in years, to which data should be extrapolated. Defaults to 120.

Value

A tibble with age_max_years + 1 rows and three columns. The first column, year, gives the year, the second, n_events the number events (deaths) in this year, and the third, n_start, the number at risk at the start of the year.

Details

Between time points at which an event takes place, the number at risk is retained from the preceding time point with an event, while the number of events is zero. Beyond the last observed time, the number at risk from the last observed time is retained, with no more events taking place.