Skip to contents

After a type-2 event, subjects are artificially re-entered into the risk set (as in the Fine-Gray sub-distribution hazard model). This function appends those additional rows, split at every censoring time.

Usage

fg_split_cr(data_long, covariate = "z1", event2_level = "event_2")

Arguments

data_long

A long-format data frame, as returned by wide_to_long_cr().

covariate

Character string. Name of the covariate column. Default is "z1".

event2_level

Character string. Factor level in the delta column representing the competing event. Default is "event_2".

Value

A data frame in Fine-Gray format, with additional rows for subjects who experienced the competing event, sorted by id and tstart.

Examples

set.seed(42)
dat <- sim_data_cr(n = 100, censoring = "baseline")
dat_long <- wide_to_long_cr(dat)
dat_long_fg <- fg_split_cr(dat_long)
nrow(dat_long_fg) > nrow(dat_long)
#> [1] TRUE