# Cox Regression model with time-dependent covariates - violated assumption of proportional hazards (PH)

I am currently performing some Cox regression models. The image attached shows a Schönfeld residual based on one of the cox models with a significant p-value which means that the proportional hazards assumption is violated.

Now I want to perform a cox regression with time-dependent covariates. In order to do so I need to obtain some points in time (in days) where there is an interaction of the covariate with time (if I understood correctly). How can I read this Schönfeld residual and obtain the 'turning points" that I need.

My description is a bit inconcrete, apologies for that. If someone could help me out with a different method, I am also glad. All I want to do is perform a Cox regression with a violated proportional hazards assumption.

• There are many other quantities that can be estimated for survival outcomes that are superior to hazard ratios. Hazard ratios are non-collapsible, confounded even in randomized experiments, and the PH assumption is never met in practice but is required to validly interpret the coefficient from a Cox model. I recommend using a different estimand that doesn't suffer from these problems, like the restricted mean survival time or risk difference at specified time points.
– Noah
Commented Jun 14, 2023 at 14:51

The R time-dependence vignette is a useful resource on this type of problem, deserving careful study to help figure out what to do in such situations. A few thoughts that might help.

First, sometimes an apparent violation or proportional hazards (PH) comes from a poorly specified model. Two answers on this page provide (1) an explanation of how this can happen with a poorly modeled continuous covariate and (2) a brief outline of how to proceed. Even though the predictor in question here seems to be categorical, if there is a poorly modeled continuous predictor in the model that is correlated with this predictor you could end up in the same trouble.

This might also represent a missing predictor or interaction term in the model. For example, if these are criminal recidivism data, might there be a change in the association of this predictor with outcome when an individual is released from probation or parole? Then the model might need to include a time-varying covariate for the probation/parole status, which could fix this apparent violation of PH.

Second, decide whether the violation of PH is big enough to worry about. If PH is violated, the reported coefficient is a type of event-averaged hazard that can sometimes be good enough to use in practice. The dashed lines are supposed to represent the error estimate for the smooth, in which case you can see if the trend is large compared to the error in estimating the trend. If other predictors are more strongly associated with outcome, you might decide, based on your understanding of the subject matter, not to worry about a PH violation for this particular predictor.

Unfortunately, it's hard to gauge that from the plot you show, which seems to be based on software in the survminer package that had a serious error in this type of plot for many years. In this plot, unlike what you would get from a standard plot of cox.zph() output directly, those lines are much too far apart and the y-axis limits make it difficult to see details in the pattern of residuals. Although that error might have been fixed in more recent versions, the extraordinary delay in removing two erroneous characters from a single line of code has led me not to trust the package at all. Use the standard plot of cox.zph() output instead.

Third, I think that what you really want to add (if necessary) is a time-varying coefficient for the predictor rather than a time-varying covariate. Yes, a time-varying coefficient is effectively modeled by constructing a time-varying covariate within the model, but thinking in terms of the coefficient is simpler. Apply your understanding of the subject matter to gauge whether there is some reason why the association of the predictor with outcome might change over time. For example, is something happening at 365 days that might change the association of the predictor with outcome? If so, then a step-change coefficient as demonstrated in Section 4.1 of the time-dependence vignette might be a good choice. Otherwise, a continuously varying coefficient might be needed, as in Section 4.2. Either way, focus on how you think the form of the association over time should change, and let the software (via the tt() term in a coxph() model) construct the time-varying covariate that underlies the estimation of the time-varying coefficient.

• Thank you so much for taking your time to answer my question. Indeed I am doing research on recidivism. I am checking if the control group has a greater hazard of committing further recidivism compared to the treatment group after release from the detention center. The difficulty that I am having is that before applying survival analyses I am matching CG and TG using Propensity score matching on a bunch of variables. In my cox model I then only have the covariate of group-belongingness, so either CG or TG.
– user389026
Commented Jun 12, 2023 at 11:47
• I attached another Schönfeld residual again with the plot-function in the original question posted above. I am still unsure how to interpret it in terms of where the hazard changes. Is it possible to read that from the Kaplan-Meier curves? I feel like that is much easier. I am attaching the Kaplan-Meier curves in the original question post as well. Here its clearly visible that there is a violation of the hazards after approximately 600 days. Before, however, there are also crossings between the lines of the two groups.
– user389026
Commented Jun 12, 2023 at 11:47
• @PeteG the survival plot tells the story. Crossing survival curves can indicate a big problem with PH. At around 300 days, Group 1 has very few further events while Group 0 continues to have events. First, try to understand why that might be happening in Group 1 to lead to that phenomenon. Make sure it's not an artifact of your propensity-score matching. Once you understand what's going on at that time point, that time point would seem to be a good choice at which to have a step-change in the regression coefficient.
– EdM
Commented Jun 12, 2023 at 12:45
• @PeteG also consider whether propensity score matching rather than control by mulltiple regression is a good choice here. This page and this page are good introductions to the pros and cons.
– EdM
Commented Jun 12, 2023 at 12:49
• Thank you. So now I am wondering how to use the splitsurv function correctly as I am having trouble understanding the vignette.
– user389026
Commented Jun 12, 2023 at 13:31