Per the approach in *A review of survival stacking: a method to cast survival regression analysis as a classification problem* <https://www.degruyterbrill.com/document/doi/10.1515/ijb-2022-0055/html>
<https://arxiv.org/abs/2107.13480>, we provide df_to_survival_stacked as
a helper function for converting traditional survival data (one observation = one row) into
the survival stacked data structure, a repeated observations data structure where
multiple rows exist for each individual for each timepoint at which they were still in the
risk set up to and including their event time.
Usage
df_to_survival_stacked(
data,
id_col = NULL,
time_col,
status_col,
covariate_cols,
period_duration = 1,
custom_times = NULL
)Arguments
- data
A data frame with survival -type outcomes including an event indicator and a time-to-event-or-censoring column
- id_col
(string) name of the id column that is unique to each observation in
data. If one is not specified, one will be created (called.id) assuming that each row is a unique observation.- time_col
(string) name of the time‐to‐event column
- status_col
(string) name of the 0/1 event indicator column
- covariate_cols
(string vector) names of your predictors
- period_duration
(numeric) length of each time-period (e.g. 1)
- custom_times
(numeric vector) [optional] A vector of the time-period breakpoints. If events could have occurred at any time after zero, this should begin with 0.
