| combine_competing_risks | R Documentation |
Reduces several latent event times to the one observed first: the observed
time is their row-wise minimum and the event code says which process won.
Naming one of them in censor turns that process into censoring, so its code
is 0 and the remaining processes are coded 1, 2, ... in the order they
appear in events. Without censor every row is an event and no code is
0. Ties are broken in favor of the earlier entry of events.
combine_competing_risks(
data,
events,
censor = NULL,
time = "time",
event = "event",
type = "event_type",
keep_events = FALSE
)
data |
Base |
events |
Event-time variable names. A character vector of at least two
names, all present in |
censor |
Optional name of the one entry of |
time |
Name of the observed-time variable. A single string, defaulting
to |
event |
Name of the integer event-code variable. A single string,
defaulting to |
type |
Name of the character event-type variable, holding the winning
process name. A single string, defaulting to |
keep_events |
Retain the component event-time variables. A single flag,
defaulting to |
A simulab_sim base data.frame with one row per input row: the
columns of data (without the entries of events unless keep_events is
TRUE) followed by time, event and type under the names given by
those arguments. The component events, reached with
as.data.frame(x, what = "events"), is the codebook, one row per process
with columns event_type, event_code and the logical censoring.
data <- data.frame(id = 1:100, treatment = rep(0:1, each = 50))
data <- augment_survival(
data,
specification = define_survivals(
define_survival("time_relapse", formula = -8, shape = 0.3),
define_survival("time_death", formula = -9, shape = 0.3)
),
seed = 1
)
result <- combine_competing_risks(
data, events = c("time_relapse", "time_death")
)
head(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.