id | t | d | occur | t0 | t_ |
1 | 0 | 0 | 0 | - | - |
1 | 1 | 0 | 0 | - | - |
1 | 2 | 1 | 1 | 0 | 2 |
1 | 3 | 1 | 2 | 2 | 3 |
1 | 4 | 0 | 2 | - | - |
1 | 5 | 0 | 2 | - | - |
1 | 6 | 1 | 3 | 3 | 6 |
Hi,
I'm trying to prepare my panel data for a survival analysis and now trying to generate the t0 variable indicating the starting time for the analysis.
t: time
d: status variable indicating whether individual been through event or not
occur: accumulated event
t0: analysis time when record begins
t_ : analysis time when record ends
So I'm trying to generate t0 variable: when id have experienced event (d=1), t0 is then suppose to obtain the minimum value of t in the previous group of occur
That is how I'm thinking of solving this problem but I cannot manage to solve it! and btw. I am going to delete the rows with the value - after generating all my variables.
(I have sensitive data so I cannot share an example)
Thanks!
Comment