O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Proportional hazards test

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required