I would like to model a recurrent event with subjects that move in and out of risk over the course of the observation period of the study.
I have data on the out-of-risk periods (start and end dates) where the subject cannot experience the event.
I would appreciate any help on how to convert my data to this counting process format with start stop times that reflect both event occurrence and interval truncation in R. I can convert the data to counting process format with event occurrence, but do not know how to partition my start stop times to reflect unobserved periods (other than manually creating the data set which I would very much like to avoid).
This is a very simplified example on my input data structure in wide format:
This is what I want to achieve:
id t0 t1 outcome
1 0 36 0
2 0 5 1
2 5 15 1
2 15 36 0
3 0 9 0
3 11 20 1
3 20 36 0
In my illustration, Subject 1 never experiences the event at get right-censored at 36 months. Subject 2 experiences the event twice and stays in the risk period throughout the observation period. Subject 3 experiences the event once and exits the risk period at 9 months and re-enters the risk period at 11 months.
Other useful info about my study:
- Subjects have a common start time of 0 months.
- Subjects are right-censored at 36 months if no event is experienced.
- Subjects are observed for 3 years.
- Subjects can move in and out of risk for varying amounts of time and frequency during the 3 year observation period.
Thank you!