0
|
1 ## Lifelines tool starting.
|
|
2 Using data header = Index(['Unnamed: 0', 'week', 'arrest', 'fin', 'age', 'race', 'wexp', 'mar',
|
|
3 'paro', 'prio'],
|
|
4 dtype='object') time column = week status column = arrest
|
|
5 Logrank test for race - 0 vs 1
|
|
6
|
|
7 <lifelines.StatisticalResult: logrank_test>
|
|
8 t_0 = -1
|
|
9 null_distribution = chi squared
|
|
10 degrees_of_freedom = 1
|
|
11 alpha = 0.99
|
|
12 test_name = logrank_test
|
|
13
|
|
14 ---
|
|
15 test_statistic p -log2(p)
|
|
16 0.58 0.45 1.16
|
|
17 ### Lifelines test of Proportional Hazards results with prio, age, race, paro, mar, fin as covariates on KM and CPH in lifelines test
|
|
18 <lifelines.CoxPHFitter: fitted with 432 total observations, 318 right-censored observations>
|
|
19 duration col = 'week'
|
|
20 event col = 'arrest'
|
|
21 baseline estimation = breslow
|
|
22 number of observations = 432
|
|
23 number of events observed = 114
|
|
24 partial log-likelihood = -659.00
|
|
25 time fit was run = 2023-08-09 07:43:37 UTC
|
|
26
|
|
27 ---
|
|
28 coef exp(coef) se(coef) coef lower 95% coef upper 95% exp(coef) lower 95% exp(coef) upper 95%
|
|
29 covariate
|
|
30 prio 0.10 1.10 0.03 0.04 0.15 1.04 1.16
|
|
31 age -0.06 0.94 0.02 -0.10 -0.02 0.90 0.98
|
|
32 race 0.32 1.38 0.31 -0.28 0.92 0.75 2.52
|
|
33 paro -0.09 0.91 0.20 -0.47 0.29 0.62 1.34
|
|
34 mar -0.48 0.62 0.38 -1.22 0.25 0.30 1.29
|
|
35 fin -0.38 0.68 0.19 -0.75 -0.00 0.47 1.00
|
|
36
|
|
37 cmp to z p -log2(p)
|
|
38 covariate
|
|
39 prio 0.00 3.53 <0.005 11.26
|
|
40 age 0.00 -2.95 <0.005 8.28
|
|
41 race 0.00 1.04 0.30 1.75
|
|
42 paro 0.00 -0.46 0.65 0.63
|
|
43 mar 0.00 -1.28 0.20 2.32
|
|
44 fin 0.00 -1.98 0.05 4.40
|
|
45 ---
|
|
46 Concordance = 0.63
|
|
47 Partial AIC = 1330.00
|
|
48 log-likelihood ratio test = 32.77 on 6 df
|
|
49 -log2(p) of ll-ratio test = 16.39
|
|
50
|
|
51
|
|
52 Bootstrapping lowess lines. May take a moment...
|
|
53
|
|
54
|
|
55 Bootstrapping lowess lines. May take a moment...
|
|
56
|
|
57 The ``p_value_threshold`` is set at 0.01. Even under the null hypothesis of no violations, some
|
|
58 covariates will be below the threshold by chance. This is compounded when there are many covariates.
|
|
59 Similarly, when there are lots of observations, even minor deviances from the proportional hazard
|
|
60 assumption will be flagged.
|
|
61
|
|
62 With that in mind, it's best to use a combination of statistical tests and visual tests to determine
|
|
63 the most serious violations. Produce visual plots using ``check_assumptions(..., show_plots=True)``
|
|
64 and looking for non-constant lines. See link [A] below for a full example.
|
|
65
|
|
66 <lifelines.StatisticalResult: proportional_hazard_test>
|
|
67 null_distribution = chi squared
|
|
68 degrees_of_freedom = 1
|
|
69 model = <lifelines.CoxPHFitter: fitted with 432 total observations, 318 right-censored observations>
|
|
70 test_name = proportional_hazard_test
|
|
71
|
|
72 ---
|
|
73 test_statistic p -log2(p)
|
|
74 age km 6.99 0.01 6.93
|
|
75 rank 7.40 0.01 7.26
|
|
76 fin km 0.02 0.90 0.15
|
|
77 rank 0.01 0.91 0.13
|
|
78 mar km 1.64 0.20 2.32
|
|
79 rank 1.80 0.18 2.48
|
|
80 paro km 0.06 0.81 0.31
|
|
81 rank 0.07 0.79 0.34
|
|
82 prio km 0.92 0.34 1.57
|
|
83 rank 0.88 0.35 1.52
|
|
84 race km 1.70 0.19 2.38
|
|
85 rank 1.68 0.19 2.36
|
|
86
|
|
87
|
|
88 1. Variable 'age' failed the non-proportional test: p-value is 0.0065.
|
|
89
|
|
90 Advice 1: the functional form of the variable 'age' might be incorrect. That is, there may be
|
|
91 non-linear terms missing. The proportional hazard test used is very sensitive to incorrect
|
|
92 functional forms. See documentation in link [D] below on how to specify a functional form.
|
|
93
|
|
94 Advice 2: try binning the variable 'age' using pd.cut, and then specify it in `strata=['age',
|
|
95 ...]` in the call in `.fit`. See documentation in link [B] below.
|
|
96
|
|
97 Advice 3: try adding an interaction term with your time variable. See documentation in link [C]
|
|
98 below.
|
|
99
|
|
100
|
|
101 Bootstrapping lowess lines. May take a moment...
|
|
102
|
|
103
|
|
104 Bootstrapping lowess lines. May take a moment...
|
|
105
|
|
106
|
|
107 Bootstrapping lowess lines. May take a moment...
|
|
108
|
|
109
|
|
110 Bootstrapping lowess lines. May take a moment...
|
|
111
|
|
112
|
|
113 ---
|
|
114 [A] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html
|
|
115 [B] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Bin-variable-and-stratify-on-it
|
|
116 [C] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Introduce-time-varying-covariates
|
|
117 [D] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Modify-the-functional-form
|
|
118 [E] https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html#Stratification
|
|
119
|