Update example code for parametric models :wrench:
@@ -111,9 +111,11 @@ Instead of the Kaplan-Meier estimator, you may be interested in a parametric mod
.. code:: python
+ import matplotlib.pyplot as plt
+ import numpy as np
from lifelines import *
- fig, axes = plt.subplots(2, 3, figsize=(9, 5))
+ fig, axes = plt.subplots(3, 3, figsize=(13.5, 7.5))
kmf = KaplanMeierFitter().fit(T, E, label='KaplanMeierFitter')
wbf = WeibullFitter().fit(T, E, label='WeibullFitter')
@@ -122,6 +124,7 @@ Instead of the Kaplan-Meier estimator, you may be interested in a parametric mod
llf = LogLogisticFitter().fit(T, E, label='LogLogisticFitter')
pwf = PiecewiseExponentialFitter([40, 60]).fit(T, E, label='PiecewiseExponentialFitter')
ggf = GeneralizedGammaFitter().fit(T, E, label='GeneralizedGammaFitter')
+ sf = SplineFitter(np.percentile(T.loc[E.astype(bool)], [0, 50, 100])).fit(T, E, label='SplineFitter')
wbf.plot_survival_function(ax=axes[0][0])
exf.plot_survival_function(ax=axes[0][1])
@@ -129,7 +132,8 @@ Instead of the Kaplan-Meier estimator, you may be interested in a parametric mod
kmf.plot_survival_function(ax=axes[1][0])
llf.plot_survival_function(ax=axes[1][1])
pwf.plot_survival_function(ax=axes[1][2])
- ggf.plot_survival_function(ax=axes[1][2])
+ ggf.plot_survival_function(ax=axes[2][0])
+ sf.plot_survival_function(ax=axes[2][1])
.. image:: images/waltons_survival_function.png
