pythonstatisticssurvival-analysissurvivallifelines

Show Cancer Specific Survival at exact time (Kaplan Meier in Lifelines)


kmf.survival_function_ (LifeLines Package)

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?


Solution

  • The survival_function_at_times() method will get you that value. Here is an example with a sample dataset:

    from lifelines import KaplanMeierFitter
    
    from lifelines.datasets import load_waltons
    data = load_waltons()
    
    T = data['T']
    E = data['E']
    
    kmf = KaplanMeierFitter().fit(T, E, label='KaplanMeierFitter')
    
    timeline = [10, 12, 14]  # insert 120 and/or any other values here
    
    # directly compute the survival function, returning a pandas Series
    kmf.survival_function_at_times(timeline)
    
    # 10    0.96921
    # 12    0.96921
    # 14    0.95069
    # Name: KaplanMeierFitter, dtype: float64