# Sample size for Survival Analysis (Cox regression) with discrete time

I have a study where the patients come to the hospital every two months for check-ups. T0 ( one week before surgery), T1 (two months after surgery), T2 (4 months after surgery) up to T9 (18 months after surgery).

I need to run a Cox regression including two covariates (one continuous and one binary time dependent covariate).

It seems that time can be considered as discrete (please correct me if I am wrong).

Question: Is there any function-formula (package in R) to calculate the sample size for a Cox regression when time is discrete.*

• Since there a finite number of time points, one could use logistic regression to estimate the hazard (i.e. probability of death by each time). The survival function would be estimated as the cumulative product of survival probabilities for each time point. This would allow you to use sample size calculations for logistic regression, which I mention here Commented May 31 at 22:47
• @ Demetri Pananos, thank you very much for your time, we have about 10 time points. But there are censored observations in the data. Can we still use logistic regression when we have censored data? There is also a time dependent covariate in the model. Can we still use logistic regression? Commented Jun 1 at 7:46

As Demetri Pananos implies in a comment, a discrete-time survival model (which seems appropriate in your case) is based on binomial regressions. You set up a separate data row for each individual during each time interval at which the individual is at risk, with covariate values in place during that time interval. You include the time period as a covariate in some fashion, to allow for changes in baseline hazard over time. A quick search shows nearly 300 entries relating to discrete-time survival on this site.

Having a separate row for each individual and time period, with corresponding covariate values, allows for time-varying covariates within individuals. As you don't have a data row for an individual who's no longer at risk, that individual is no longer considered at later event times; that accounts for censoring just as in a continuous-time proportional hazards model.

A sample-size estimate based on binomial regression thus could make sense, if you take into account the changing numbers of individuals over time. Nevertheless, a binomial regression with a complementary log-log link is just a "grouped proportional hazards model"; Cox models can handle tied event times (with some methods to handle ties). You thus should do pretty well to start with a standard power estimate for continuous-time Cox models, and perhaps do some simulations to see how much power you lose from the binning of times.

• thank you for your time. I am new to this topic. So please let me ask a few questions to make sure I could fully understand the points. Thanks again for your time and your patience. So based on my understanding, you recommend using binomial regression with a complementary log-log link. Am I right? In R there are some functions to analyse this kind of data like glm(, family=binomial(link=cloglog))) or coxph( ties="exact") (from the survival package). Which function is the right one to use for the analysis based on my question? Commented Jun 2 at 18:06
• To calculate the sample size, you kindly recommend starting with the power calculation for the continuous time Cox regression, right? So there is no need to go through the binomial distribution with the clog function to calculate the sample size? Commented Jun 2 at 18:07
• @Stat2024 the binomial regression with complementary log log link is the discrete-time equivalent to the assumptions underlying proportional hazards regressions. I suspect that will work better than a Cox regression. According to the coxph() help page, calculating the exact partial likelihood is "numerically intense... With (start, stop) data it is much worse." I suspect that the usual sample-size calculation for Cox regression will be good enough, but you would be wise to check its adequacy with some simulated data based on the assumptions that you're making in that power calculation.
– EdM
Commented Jun 2 at 20:41
• @Stat2024 the power calculations for both binomial regression and continuous-time proportional hazards models are based on the number of events, the assumed log-hazard ratio (log-odds for logistic regression), and the variances in predictor values. That's why I suspect that you will get similar estimates either way, but again it would be good to double check. Be very careful with time-varying covariates, however, as there can be a risk of non-causality or survivorship bias. See this page for example.
– EdM
Commented Jun 2 at 20:50
• great, Thanks so much. I am truly value your time and kindness. Commented Jun 2 at 20:54