我使用 python 生命线模块创建了一个生存曲线。生命线模块中是否有一个函数可以用来显示我的绘图的置信度以及 x 轴上的 number_at_risk。我知道confidence_interval_
输出置信区间表的函数。但我想在图表上显示 95% 的间隔值,就像在第二张图片中一样。
from lifelines import KaplanMeierFitter
durations = df['Time Years'] ## Time to event data of censored and event data
event_observed = df['Revision all cause'] ## It has the Include 15 yr (1) and censored is (0)
创建一个 kmf 对象为 km
km = KaplanMeierFitter() ## instantiate the class to create an object
## Fit the data into the model
km.fit(durations, event_observed,label='Kaplan Meier survival curve')
## Create an estimate
km.plot(ci_show=);
plt.title('Revision of Any Part for Any Cause')
plt.ylabel('Survival probability (%)')
plt.xlabel('Time (Years)');
Time_Years observation
0 14.35 1
1 11.37 1
2 7.87 1
3 8.56 1
4 12.31 1
5 7.31 1
6 12.94 1
7 14.84 1
8 12.34 1
9 13.79 1
10 9.49 1
11 12.59 1
12 12.59 1
13 9.64 1
14 9.93 1
15 9.60 1
16 8.08 1
17 13.12 1
18 15.61 1
19 10.22 1
20 0.61 1
21 6.00 1
22 0.98 1
23 6.28 1
24 1.71 1
25 1.37 1
26 3.28 1
27 4.61 1
28 0.37 1
29 2.05 1
30 0.51 1
31 5.80 1
32 0.53 1
33 3.72 1
34 1.14 1
35 14.54 1
36 13.71 1
37 2.00 1
38 0.46 1
39 1.34 1
40 5.09 1
41 1.46 1
42 15.60 1
43 0.19 1
44 5.81 1
45 2.94 1
46 1.00 1
47 2.36 1
48 2.92 1
49 3.62 1
50 0.63 1
51 9.64 1
52 6.18 1
53 1.84 1
54 1.83 1
55 11.10 1
56 13.60 1
57 12.54 1
58 1.28 1
59 16.66 0
60 14.75 0
61 15.69 0
62 16.21 0
63 16.21 0
64 16.27 0
65 14.97 0
66 14.86 0
67 14.80 0
68 14.97 0