recur_survival_table {card} | R Documentation |
Recurrent Survival Data Format
Description
Reformats recurrent event data (wide) into different models for survival analysis, but can also be used for simple survival analysis tables as well. Importantly, for large datasets, this function will show significant slow-down since it uses an intuitive approach on defining the datasets. Future iterations will create a vectorized approach that should provide performance speed-ups.
For recurrent events, the final censoring event can include death, or can be ignored if its not considered a failure event.
For simple survival analysis, death censoring should be left as NULL, and the event (e.g. "date_of_death"), should be used as a single
event.dates
parameter. The function will do the rest.
Usage
recur_survival_table(
data,
id,
first,
last,
event.dates,
model.type,
death = NULL
)
Arguments
data |
A dataframe containing the subsequent parameters |
id |
Column in dataframe that contains unique IDs for each row |
first |
Column with left/enrollment dates |
last |
Column with right/censoring time point, or last contact |
event.dates |
Vector of columns that contain event dates |
model.type |
Character/string = c("marginal", "pwptt", "pwpgt") |
death |
Column created for if death is known (0 or 1), original dataframe (e.g. can add column of zeroes PRN). Death defaults to null for intermediate calculations otherwise. |
Details
This function takes every data event date, and creates several types of recurrent event tables. It orders the data chronologically for repeat events. Currently does marginal and conditional A and B models. The large
Value
A data frame organized into a survival table format
Examples
# Data
data("mims")
# Parameters
id <- "patid"
first <- "first_visit_date_bl"
last <- "ldka"
event.dates <- c("mi_date_1", "mi_date_2", "mi_date_3")
model.type <- "marginal"
death <- "DEATH_CV_YN"
# Run analysis
tbl <- recur_survival_table(
mims, id, first, last, event.dates, model.type, death
)