JavaScript
x
2
1
kmf.survival_function_ (LifeLines Package)
2
shows me Cancer Specific Survival (CSS) of my cohort at different times (0, 4, 6…128 month). How can CSS be shown at exactly 120 month?
Advertisement
Answer
The survival_function_at_times()
method will get you that value. Here is an example with a sample dataset:
JavaScript
1
20
20
1
from lifelines import KaplanMeierFitter
2
3
from lifelines.datasets import load_waltons
4
data = load_waltons()
5
6
T = data['T']
7
E = data['E']
8
9
kmf = KaplanMeierFitter().fit(T, E, label='KaplanMeierFitter')
10
11
timeline = [10, 12, 14] # insert 120 and/or any other values here
12
13
# directly compute the survival function, returning a pandas Series
14
kmf.survival_function_at_times(timeline)
15
16
# 10 0.96921
17
# 12 0.96921
18
# 14 0.95069
19
# Name: KaplanMeierFitter, dtype: float64
20