I'm preparing a longitudinal dataset (with up to 5 observations per participant) for Cox regression in R. I have data for the follow-up period and date (FUPeriod
and FU
, respectively), the date of hospital discharge (HospDis
) and the date of death (Death
; if applicable).
ID | FUPeriod | HospDis | FU | Death |
---|---|---|---|---|
1 | 0 | 2017-09-26 | NA | NA |
1 | 1 | 2017-09-26 | 2017-11-16 | NA |
1 | 2 | 2017-09-26 | 2019-02-12 | NA |
1 | 5 | 2017-09-26 | 2021-09-10 | NA |
1 | 10 | 2017-09-26 | NA | 2022-02-20 |
I'm a little stuck on the variables that I need to create from the available temporal data to start my analyses... I know that at the very least I need a censoring/event indicator variable and a survival time variable. My question is whether the survival time and censoring variables need to have values at all time points (i.e., FUPeriod
= 0, 1, 2, 5, 10), or whether they need values only for the last available time point (i.e., FUPeriod
= 10)? Are these the variables and values I should ultimately have (where SurvTime
is survival time since hospital discharge (HospDis
) in months and Event
= 1 if Death
is a valid date and 0 otherwise?
ID | FUPeriod | HospDis | FU | Death | SurvTime | Event |
---|---|---|---|---|---|---|
1 | 0 | 2017-09-26 | NA | NA | 0 | 0 |
1 | 1 | 2017-09-26 | 2017-11-16 | NA | 1.675565 | 0 |
1 | 2 | 2017-09-26 | 2019-02-12 | NA | 16.55852 | 0 |
1 | 5 | 2017-09-26 | 2021-09-10 | NA | 47.47433 | 0 |
1 | 10 | 2017-09-26 | NA | 2022-02-20 | 52.82957 | 1 |