I have a question about an extended cox regression model. I have reviewed several materials, such as "D.G. Kleinbaum and M.Klein, Survival Analysis: A Self-Learning Text, Third Edition" but am still concerned I am not using this model correctly. However, I am setting up the data, one row per observation/time interval, correctly and my model is producing results.

Example: I followed a cohort of people for 10 weeks. Each week (approx 7-day intervals) they answered two questions, (1) Did I wear a mask and (2) Was I exposed to a covid-19. The covariates would change week to week based on the answer with the appropriate person-time interval. The outcome is a positive covid test and individuals are right censored after positive.

This is a crude example but I feel it communicates what I am trying to do and determine.

Thank you,

enter image description here

  • $\begingroup$ This sounds OK in principle, but it would help if you could edit the question to show some sample data rows. With only 10 observation times this might be better handled with a discrete-time survival (binomial regression) model; the data setup is pretty much the same either way. Also, when you say that "individuals are right censored after positive" do you just mean that you remove the individual from the study after recording the date of the positive Covid test? Or something else? $\endgroup$
    – EdM
    Commented Jun 7, 2023 at 12:36
  • $\begingroup$ Hi EdM, (1) Yes, when I say that the individuals are right censored after the positive that - the individual is removed from the study after positive covid test. (2) is the discrete-time survival (binomial regression) model just a different statistical test but data set up the same? $\endgroup$
    – Levi M
    Commented Jun 9, 2023 at 12:17
  • $\begingroup$ hi EdM, I forgot to post some sample data, which I just have. Thank you for your answer, I will review and follow up if I have questions. Thank you! $\endgroup$
    – Levi M
    Commented Jun 9, 2023 at 14:18
  • $\begingroup$ I added a bit to the answer to deal with these data. Think about what you are trying to model and learn about as you choose among the options: a binomial model by week (ignoring the actual number of days), a Cox model of observation times of events (modeling as you seem to be already), or a Cox model of event times based on your interval-censored data. $\endgroup$
    – EdM
    Commented Jun 9, 2023 at 15:07

1 Answer 1


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.

  • $\begingroup$ Thank you, EdM. This was a great and detailed explanation. I see what you are saying about the difference between the binomial and my approach of the cox model. I feel that I could essentially approach this with either the binomial regression or the interval censoring cox. Question, for the binomial regression, would I need to use a ordered variable, unlike previously stated "unordered factor variable"? $\endgroup$
    – Levi M
    Commented Jun 9, 2023 at 15:34
  • $\begingroup$ @LeviM if you do a binomial model by "week" (ignoring the actual length of the "week) with a factor variable for the "week," you don't want it to be an ordered factor. As this answer shows, with a cloglog link in a binomial model you get a different intercept for each week, equal to the log of the difference in baseline cumulative hazard between the endpoints of the interval, similar to a Cox model. It's possible to use time as a numeric predictor in discrete-time survival, but then you have a parametric model requiring more assumptions. $\endgroup$
    – EdM
    Commented Jun 9, 2023 at 15:47
  • $\begingroup$ Thanks again for your information. I have already ran the analysis with COX and want to try with discrete-time. I do have two questions. (1) Do I still right censor? If I had participants that test positive for multiple weeks, do I include all of their positive weeks? (2) Is it alright if participants have different number of weeks for observations (ie id A has 12 weeks id B has 13 weeks)? $\endgroup$
    – Levi M
    Commented Jun 13, 2023 at 15:56
  • $\begingroup$ @LeviM (1) based on how you described your approach in a comment on the question, you would remove all data rows for an individual after the first event observation. (You seem to call that "right censoring" although it would better be described as "removal from the risk set." Technically, "right censoring" means that you only have a lower limit on the time to the event, while you have event times for those individuals.) (2) There's no problem with having different individuals observed for different numbers of weeks; that's the same as for continuous-time survival. $\endgroup$
    – EdM
    Commented Jun 13, 2023 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.