I have previously had experience only with Cox PH model and its assumptions checking.
Now for the first time I have my clients data with most of the covariates varying in time, only a few are fixed valued. I did set it up in start/stop format and I have also fitted some models, but cox.zph is showing very small p-values. My understanding is, that extended Cox model is not a PH model. Do I even need the cox.zph test for time-dependent variables? Or when including fixed covariates, then would I need to see large p-values for those or not?
Solved – Extended Cox model and cox.zph
cox-modelproportional-hazards
Best Answer
An extended Cox model is really technically the same as a regular Cox model. If your data set is properly constructed to accommodate time dependent covariates (multiple rows per subject, start and end times etc..), than
cox.ph
andcox.zph
should handle your data just fine.Having time dependent covariates doesn't change the fact that you should check for proportionality assumption, in this case using the Schoenfeld residuals against the transformed time using
cox.zph
. Having very small p values indicates that there are time dependent coefficients which you need to take care of.Two main methods are (1) time interactions and (2) step functions. The former is easier to do and to read, but if it does not change the p values than use the later:
Note that it would be easier if you provided your own data, so the following is based on sample data I use
(1) Interaction with time
Here we use simple interaction with time on the problematic variable(s). Note that you don't need to add time itself to the model as it is the baseline.
Checking for proportional assumption violations:
So
var2
is problematic. lets try using interaction with time:Now lets check again with zph:
As you can see - that's the ticket.
(2) Step functions
Here we create a model devided by time segments according to how the residuals are plotted, and add a strata to the specific problematic variable(s).
Now with zph:
So the
contributions
coefficient appears to be time dependent. I tried interaction with time that didn't work. So here is using step functions: You first need to view the graph (above) and visually check where the lines change angle. Here it seems to be around time spell 8 and 40. So we will create data usingsurvSplit
grouping at the aforementioned times:And then run the model with
strata
:And viola -