Sample size and number of covariates in Cox regression

I am starting to work on survival analysis using Cox regression.

1. Is there a formula or function (SAS; R) to figure out for a given number of sample sizes what would be the number of independent variables that can be studied (and vice versa)?

2. I also have a covariate that is time dependent. However, I could not find a function to calculate the sample size (cox regression) when there is a time dependent covariate in the model. Can I treat this variable as a time-independent covariate while calculating the sample size?

Thanks so much for your time.

This has been solved by Richard Riley et al: https://pubmed.ncbi.nlm.nih.gov/30357870 and there is an R package to help with the calculations.

• @ Frank Harrell. Dear Dr. Harrell, Thank you so much for your time and great help. I am just looking at the package and article very quickly. Do you think the package can be used even when there is a time dependent covariate in the cox model? Commented May 31 at 17:03
• @ Frank Harrell, Also, do you think the following comment is true?? #time varying covariates do not impact the power/sample size considerations for the Cox model# Commented May 31 at 18:52
• I’m guess that they impact it to a huge degree. It depends on the formulation. If you are relaxing the PH assumption by putting a time x treatment term in the model, then treatment has 2 d.f., and will require a larger sample size, especially when not using Bayesian regression. Commented Jun 1 at 13:08
• @ Frank Harrell, Thank you very much for the reply, so probably the package cannot be used in a case of having time dependent covariate in the model. Please correct me if I am wrong. The last question is: can the method be used when survival time has a discrete format (a finite number of time points- less than 10 time points)? Commented Jun 2 at 7:04
• I think that when you have time-dependent covariates or non-PH, simulation is required to compute power. For discrete time you may be better using a discrete model such as discrete time Markov state transition models which generalize to all kinds of outcomes including recurrent events - hbiostat.org/rmsc/markov Commented Jun 2 at 12:23

As far as I can tell, the answer is "no". In SAS, there is the COXREG option in the POWER procedure, but it only handles a single covariate. In R, there is the powerSurvEpi package, but this has a maximum of two covariates, one of which has to be binary.

When neither R nor SAS has the ability to do something, there is likely to be a statistical reason. Power for Cox regression is complex and I do not believe there is an analytic solution, so, you will have to simulate data. This can be done in either R or SAS (you might need the IML addon, although you can now call R from SAS).

• thanks so much for your time. This means that there is no formula to work out, for example, how many independent variables in the model would be sufficient for 20 samples. Please correct me if I am not right. Also, is there any reference-article to see how I should generate the simulated data and calculate the sample size in R or SAS? Commented May 31 at 11:08
• That is correct, as far as I know. SAS regularly publishes articles on simulation, among other things, but I haven't looked lately. You can Google, of course. You might also want to browse Rick Wicklin's blog. Commented May 31 at 11:25
• Dear Dr. Flom, again thank you so much for your time and feedback. I really appreciate it. Commented Jun 2 at 12:32
• You're welcome. If my answer meets your needs, you can accept it by clicking the check mark Commented Jun 2 at 13:01
• @ Peter Flom, Your expertise and advice is very valuable to me. I wish the website had given me the opportunity to take both your advice and that of Dr Harrells advice. Commented Jun 2 at 18:14