Convert a multi-state dataset with irreversible transitions containing 3 health states to a dataset with one row per patient and progression-free survival (PFS) and overall survival (OS) time-to-event outcomes.

as_pfs_os(
  data,
  patient_vars,
  status = "status",
  time_stop = "time_stop",
  transition = "transition_id"
)

Arguments

data

A multi-state dataset.

patient_vars

Character vector of the names of patient specific variables.

status

Character string with the name of the status variable (1 = event, 0 = censored).

time_stop

Character string with the name of the stopping time variable (i.e., time patient transitions from state \(r\) to state \(s\)).

transition

Character string with the name of the variable identifying a transition. The transition variable should be integer valued with values 1, 2, and 3 for the Stable -> Progression, Stable -> Death, and Progression -> Death transitions, respectively.

Value

A data.table with one row per patient containing each variable in patient_vars as well as a time variable and status indicator for both PFS (pfs_status, pfs_time) and OS (os_time, os_status).

Examples

as_pfs_os(onc3, patient_vars = c("patient_id", "strategy_name", "female", "age")) 
#> Key: <patient_id, strategy_name, female, age>
#>       patient_id strategy_name female      age  pfs_time pfs_status os_status
#>            <int>        <fctr>  <int>    <num>     <num>      <num>     <int>
#>    1:          1         New 2      0 59.85813 2.4202260          1         1
#>    2:          2         New 2      0 62.57282 7.4974635          0         0
#>    3:          3           SOC      1 61.44379 2.3658666          1         1
#>    4:          4         New 2      0 62.90770 9.3422652          1         0
#>    5:          5         New 1      1 63.94785 4.4758108          0         0
#>   ---                                                                        
#> 2996:       2996         New 2      0 57.56747 8.1176909          1         0
#> 2997:       2997           SOC      0 59.78248 2.5573202          0         0
#> 2998:       2998         New 2      0 52.53633 9.1286646          1         1
#> 2999:       2999         New 1      0 60.39916 0.1838243          0         0
#> 3000:       3000           SOC      1 64.66686 4.2119803          1         1
#>          os_time
#>            <num>
#>    1: 14.6202585
#>    2:  7.4974635
#>    3:  2.3658666
#>    4: 11.3830946
#>    5:  4.4758108
#>   ---           
#> 2996: 15.0000000
#> 2997:  2.5573202
#> 2998:  9.1286646
#> 2999:  0.1838243
#> 3000: 11.3425810