1. Interpreting the Cox PH model
We briefly touched on the Cox PH model summary. In this video, we'll take a closer look at the model output and its interpretations.
2. The baseline hazards
We learned that the hazard ratio indicates how much hazard increases or decreases relative to the baseline hazard function, but what is the baseline? The baseline hazard function describes the risk for individuals at the baseline levels of covariates. That doesn't mean setting all covariates to 0, but rather the average of all covariates. In the lifelines implementation, it's set to the median.
3. The baseline functions
To visualize the baseline hazards, we use the dot-baseline_hazard_ property to get the baseline hazards and dot-plot to plot them. See how they could vary up and down with time because hazards are instantaneous risks of events. In this plot, there is a 1-point-1% chance individuals will experience an event at time 20 given they survive up to 20. We could also use the dot-baseline_survival_ property to get the survival rates and plot them. The baseline survival function is the survival curve when all covariates are set to their medians. Because the covariates' effects are relative to the baseline, it's important to evaluate them in the context of baseline hazards and survival rates. For instance, the same percentage change in hazards at different times may equate different absolute change in hazards.
4. Interpret the hazard ratio
In the context of our baseline hazard, the interpretation of the hazard ratio becomes intuitive. E to the power of the coefficient, the hazard ratio, indicates the change in hazards relative to the average subject when the covariates change. For example, a hazard ratio of 1-point-5 equals a 50% increase in hazards that's constant across time. In the context of the baseline survival curve, the inverse of the hazard ratio indicates the change in survival time relative to the average subject. For example, 1 over 1-point-5 equals 0-point-67, meaning that the survival time of this subject is 0-point-67 times the median survival time, which is 1 minus 0-point-67, or 23% shorter.
5. Visualize the hazard ratio
It's helpful to visualize hazard ratios as changes in survival curves. Plot_partial_effects_on_outcome, the method we learned when fitting the Weibull model, also applies to the CoxPHFitter class. To call it, we need at least 2 parameters: covariates, which is the name of the covariate we want to vary, and values, which is a list of numerical values we want the covariate to vary over. If we wish to vary over multiple covariates, pass the covariate names as a list and the values as a list of pairs or tuples of values we wish the covariates to take on.
6. Visualize the hazard ratio
For example, say we have covariates A, B, and C and wish to vary A over 1 and 2, and B over 3 and 4. There are 4 value combinations in total: 1 and 3, 1 and 4, 2 and 3, and 2 and 4. Passing in a list of A's value list and B's value list is wrong and will not create the desired plot! The plot_partial_effects_on_outcome method does not automatically aggregate the values in combination tuples for us.
7. Visualize the hazard ratio
Make sure that you pass in all pairs of A and B values explicitly as such. The plot will generate the baseline as well as all the listed combinations of values the covariates take on.
8. Let's practice!
Now, let's practice interpreting the Cox PH model!