I was wondering if any have advice on what the correct steps/interpretation are with regards to the following questions on Cox regression. As a side note, I am using STATA MP 15.1 to analyse the data and I am quite new to survival analyses.

  1. Are my covariates assumed to be time-variant? I have a dataset that has quarterly info on the diversity composition of a team (gender, age & nationality). The values can be different throughout time whenever a new person joins or leaves the team. However, it is not a fixed change over time such as with a drug who's effect lessens over time for example.

  2. I recently changed the format of my dataset, I believe this formatting is better in case I want to account for time variance. Is this correct? Below the before and after. I also have an observation per quarter, but it might be better to only have an observation when a change occurred in the diversity variables?

enter image description here

  1. My predictor variables are continuous, and using Schoenfeld residuals, the PH assumption seems to be violated. What are potential next steps I can take?

Thank you in advance for your help! Best regards, Laura


1 Answer 1


First, if the values of covariates are changing over time then you have time-varying covariates. Predictable things like age might be handled by simply including the value at study start, but things like "diversity composition" need to be handled time period by time period.

Be warned, however, that the modeling effectively works on individual event times and will only use the covariate values in place for all at-risk cases at each specific time. History of prior values is not considered unless you construct such historical variables. In your case without such historical variables it would be the current "diversity composition" that is associated with risk of failure, not the diversity history.

Second, your reformatting of the data set puts it into the "person-period" format used for discrete-time survival analysis, which seems like it might be better for your application than a continuous-time Cox model. That then becomes a binomial regression, with right-censoring taken into account by the omission of cases at times after they are no longer under observation. Using a complementary log-log link instead of a logit link for the binomial regression provides a "grouped" proportional hazards model. See this page.

For a Cox model you could use the alternate format that you suggest, only starting a new data row when the covariate values change, but a Cox model can work with the person-period format. The only disadvantage of the person-period format in your case is that it might increase the size of the data set, but that's probably not a big issue here.

Third, there are multiple ways to handle violations of proportional hazard assumptions, with details depending on the specific situation. Chapter 6 of Therneau and Grambsch is a useful resource on that, as are many pages on this site. I'd first make sure that the continuous predictors have appropriate functional forms in the model. If you incorrectly assume a linear association between log-hazard and a predictor, then that incorrect assumption could end up expressing itself as an apparent violation of proportional hazards. Model the continuous predictors flexibly, for example with regression splines.

  • $\begingroup$ Thanks for your reply and help! Also thank you for making me aware of the issue of current vs historical risk. I might be asking a "stupid" question here, but do you know of ways I could account/create this historical variables? Thanks in advance! $\endgroup$
    – Laura Hill
    May 5 at 6:56
  • $\begingroup$ @LauraHill for incorporating historical data, you need to apply your understanding of the subject matter. A running average of some sort is one type of approach. In person-period format you still need to check linear associations of continuous covariates (other than time) with outcome; splines are often a good choice. For modeling time you might choose to treat each time period individually with its own intercept and thus not worry about linearity in time. That gets unwieldy with larger numbers of time periods, however, and you might choose to treat time as a continuous covariate. $\endgroup$
    – EdM
    May 5 at 12:32
  • $\begingroup$ I also wanted to refer to this post (statalist.org/forums/forum/general-stata-discussion/general/…), with regards to the time-varying issue. In any case I would assume since the PH assumption is violated it makes sense for me to include time-variance for the different diversity variables. Thanks again for your help! $\endgroup$
    – Laura Hill
    May 5 at 12:33

Your Answer

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

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