# Survival analysis - Kaplan Meier curve suddently drops

I'm doing a survival analysis (where i'm a newby by the way) for churn, to try to understand how long an insurance policy stays "alive". My universe are all policies that were created between 1Jan2021 and 30Jun2023

I plotted the survival function but i cannot really understand why on the 30months the curve just drops... I understand that the total months a policy can be alive are 33 months because of my time frame but cannot really understand how to deal with the case where policies don't have the same time to survive... here's my curve:

And here is my code :

    current_date = pd.to_datetime("2023-06-30")  # Your current date

# Define a function to calculate the time to churn in months
def calculate_time_to_churn(row):
if not pd.isnull(row['DTANUL']):
return (row['DTANUL'] - row['DTEMISS']).days // 30
return (current_date - row['DTEMISS']).days // 30

# Apply the function to create the 'Time_to_Churn' column
df['Time_to_Churn'] = df.apply(calculate_time_to_churn, axis=1)

df['Censored'] = df['DTANUL'].isnull().astype(int)

# Fit a Kaplan-Meier estimator to your data using the time in months
kmf = KaplanMeierFitter()
kmf.fit(durations=df['Time_to_Churn'], event_observed=(1 - df['Censored']))

# Create the survival plot
plt.figure(figsize=(8, 6))
kmf.plot()

# Highlight specific time points
highlight_times = [12, 24, 30]  # Time points to highlight in months

for t in highlight_times:
survival_prob_at_t = kmf.predict(t)
plt.scatter([t], [survival_prob_at_t], marker='o', color='red')
plt.annotate(f"P({t}mo) = {survival_prob_at_t:.2%}", (t, survival_prob_at_t), textcoords="offset points", xytext=(0, 10), ha='center')

plt.title('Survival Function')
plt.xlabel('Time (months)')
plt.ylabel('Survival Probability')
plt.show()


I would appreciate any help with this :)

• I find it odd that your data starts from a timeframe roughly 30 months ago and that there's a steep drop off at exactly that duration. Might this be an error in how events/censored data is coded? Nov 7, 2023 at 14:34
• well maybe, that's what i'm trying to figure out.. i just created the "censored" flag in every cases that a customer didn't churn does it makes sense? because they might have churn after the last period i have (31-06-2023)... but the thing is when i look at the distribution of policies by time until churn, i only have 2 customers that have 33 months until churn... Nov 7, 2023 at 16:37
• How many data points overall, or are followed-up past 30 months? It may be a low-N issue at the later timepoints. Nov 7, 2023 at 17:13
• I have 126.558 policies of which the majority ( 10.775 ) have a time to churn of 1 month then until 22 months of time to churn the distribution is around 2k policies but at 30 months i have 739, at 31 months 49 , at 32 months 15 and then at 33 months only 2 policies Nov 8, 2023 at 10:18