It seems like you have things set up OK. What you describe is a person-period data format, with one row per individual at risk for each time interval. Each row contains the time-interval value, the covariate values in place during that time interval, and an indicator of whether the event occurred. After an individual experiences the event, there are no further rows for that individual. For individuals lost to follow up, there would be no data rows after the last observation time and the event marker for that last time interval would be for no-event
.
Analyzing these data with a standard Cox model, as you seem to be doing, presumably means that you have the data in the counting-process format described in the R time-dependence vignette. Each data row then contains both the start and the stop times for each time interval, along with the covariate values. That allows for a lot of flexibility, as different individuals can have completely different time intervals; under the proportional hazards assumption, the software can readily determine the individuals at risk and their covariate values for any event time that is being analyzed.
Your situation is different from that, however. First, in counting-process format, the event indicator is supposed to mean that the event occurred at the stop time of the interval. In your situation, it means that the even occurred during the interval. Technically, those are "interval-censored" event times; you have upper and lower limits for the event times, but not the actual time.
Second, your data are far from the continuous time scale implicitly assumed for a Cox model. It's admittedly possible for Cox models to handle tied event times, but sometimes a different approach could be more natural. What you have is a small number of fixed time intervals, which I assumed to be shared by all individuals in the first versions of this question and answer.
A situation with a small number of fixed time intervals is probably better handled with a binomial regression, with the event as the modeled outcome. For data formatted the way that you describe, that's "discrete-time survival analysis." Although binomial regression is usually done with the default logit link, it turns out that the "cloglog" link provides a direct connection to a proportional hazards model. For the binomial regression in your situation you don't need both the start and stop times of each time interval, just a variable representing the time interval itself. To be closest to a Cox model with its lack of assumptions about the baseline hazard, just treat the time-interval variable as an unordered factor predictor in the regression.
For your particular type of data, you have to be careful about causality. With interval-censored event times, it's possible that the event preceded the reported covariate values for the corresponding time interval. For example, perhaps someone developed Covid early in an interval, wore a mask thereafter as a result, and gave a positive answer to "did I wear a mask." That would also, however, be an issue if you analyzed counting-process data in a Cox model that assumes the event occurred at the end of the time interval.
In response to edited question
With the data sample that you show, you don't have exactly the same time intervals for all individuals. That puts this more into the context of interval-censored data and makes the binomial regression a bit more unwieldy, unless it's good enough for your purpose to analyze the data by "week" after time = 0
without regard to the actual number of days elapsed (between 5 and 8 days in what you show).
A Cox model of this type of counting-process data would be of when you observed the event, not when it happened. That is frequently done, for example in models of cancer recurrence times. You might consider the tools in the icenReg
package, which can fit Cox models of event times to interval-censored data. The choice depends on what you are trying to learn from the model.