Some follow up tests are needed after a cox regression is run. One assumption of cox regression that needs to be tested is that the hazard for an event is purely dependent upon the variables, and not dependent upon time. If it was, time could not be treated as an independent variable. So, we need to test for what is known as proportional hazards. This can be done using the cox.zph function.
Run the following portion of the code, which is listed under the label #coxproptext====
It will do the following:
- Assign the output of the proportional hazard test to the temp object
- Print the results of the test to the console
- Loop through all of the model variables contained in the temp object and plot the proportional hazards: ...