# Time related categorical variable for cox regression

I am trying to fit a Cox regression model to my time-to event data and besides other subject specific variables, I have two specific calendar dates that I want to analyze the effect of. For these two dates t_x and t_y given that t_x< t_y, I attempt to introduce a categorical variable with 3 levels: before_t_x, between_tx_ty and after_t_y. Is this a meaningful approach? Also, if I drop, let's say, between_tx_ty, how would I interpret the hazard ratios?

The data covers the interval from 2018 to 2023 but I normalized all the dates to start from t=0.

Thanks!

• Please edit the question to say more about the data. How is the time origin (time=0) chosen for the survival model? Is it a calendar date or something specific to each individual? Are there predictors besides the two cutoff dates (and thus the 3 levels of your categorical variable)? Please answer by editing the question, as comments are easy to overlook and can be deleted.
– EdM
Commented Jul 11 at 16:30
• I edited the question but why is the time origin important? I normalized the data to start from t=0, and used days as measure, but I can still classify the time to events as before or after the specific calendar date. @EdM Commented Jul 11 at 22:56

You think that there are 2 calendar-date cutoffs at which hazards might have taken step changes: at t_x and then later at t_y. In that case you need to set this up with time-varying covariates in your survival model and the "counting process" data format. That's explained in the R time-varying covariates vignette.
For each individual you have a separate data line for each time interval during which the individual is at risk for an event and the covariate values are constant, with the starting and ending times of each interval expressed relative to time=0 for that individual.
In your case, if the other predictors are constant in time, the first interval, with before_t_x the value for your 3-level categorical predictor, would start at time=0 and end at the time relative to the individual's time=0 when t_x was reached, or at an event or right-censoring time during that interval. The next interval, for those still at risk after t_x and with between_tx_ty as the value, would start at the end of the previous interval and end at the time relative to the individual's time=0 that t_y was reached (or at the event or right- censoring time within that interval). The last interval, for those still at risk after t_y and with after_t_y as the value, would start at the end of the prior interval and end at the event or right-censoring time.
That makes a strong assumption that those calendar dates had sudden effects on hazards independent of other predictors. If you use before_t_x as the reference level, then hazards for between_tx_ty and after_t_y would be relative to that calendar-date period. If you omitted between_tx_ty from that categorical predictor, then the reference would be all times up to t_y and the hazard for after_t_y would be relative to that longer period.
• It seldom makes sense to omit data, and what you propose has risks. The subjects that fall within the between_tx_ty category provide information about times prior to tx as they are at risk for the event during that period. Omitting them can lead to bias, just like omitting cases with right-censored event time leads to bias. There's no need to run separate models. Including the time-varying covariate for calendar date lets you model the time-invariant predictors for all individuals while you can check the coefficients of the time-varying covariate to determine its significance.