Plot covariate effects on survival
Two convicts are on the waitlist to be released. You want to predict their survival function for time-to-arrest using the CoxPHFitter model you just fitted. The covariate values for the individuals are listed below:
| Name | fin | age | wexp | mar | paro | prio |
|---|---|---|---|---|---|---|
| Jack | 0 | 35 | 0 | 1 | 1 | 3 |
| Marie | 1 | 22 | 0 | 0 | 0 | 0 |
Plot Jack's and Marie's survival curves side-by-side with the baseline survival curve using cph. The fitted model cph has been loaded for you.
The CoxPHFitter class has been imported and the matplotlib.pyplot module has been imported as plt. The pandas and numpy libraries are imported as pd and np, respectively.
Deze oefening maakt deel uit van de cursus
Survival Analysis in Python
Oefeninstructies
- Use
.plot_partial_effects_on_outcome()to specify the covariate values (listed above) for Jack and Marie and plot their survival curves. - Show the plot.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Plot partial effects
cph.____(covariates=____,
values=____)
# Show plot
plt.show()