Input/Output
Compute the log-rank P-value and survival curves based on kaplan meier.
- param time_event
Numpy array with survival-time in years/months/days (not a datetime!)
- type time_event
Float.
- param censoring
numpy array with censoring (1=event, 0=ongoing). At the time you want to make inferences about durations, it is possible, likely true, that not all the death events have occured yet. In case of patients, you would like to put 1=death as an event.
- type censoring
array-like
- param labx
Class labels. Each class label is seperately plotted.
- type labx
array-like of type string or int
- param verbose
Verbosity messages.
- type verbose
int, (default: 3)
- returns
logrank_P (float) : P-value
logrank_Z (float) : Z-score
logrank (float) : fitted logrank_test model
labx (list) : Class labels
uilabx (list) : Unique Class labels
time_event (float) : Time to event
censoring (bool) : Censored or not
- rtype
dict()
Examples
>>> # Import library
>>> import kaplanmeier as km
>>>
>>> # Example data
>>> df = km.example_data()
>>>
>>> # Fit
>>> results = km.fit(df['time'], df['Died'], df['group'])
>>>
>>> # Plot
>>> km.plot(results)
>>>
>>> km.plot(results, cmap='Set1', cii_lines=True, cii_alpha=0.05)
>>> km.plot(results, cmap=[(1, 0, 0),(0, 0, 1)])
>>> km.plot(results, cmap='Set1', methodtype='custom')
>>>
>>> results['logrank_P']
>>> results['logrank_Z']