lifelines icon indicating copy to clipboard operation
lifelines copied to clipboard

Poor results for CoxPHFitter using cubic splines.

Open droully opened this issue 4 years ago • 3 comments

I'm using the Cox model with a cubic spline as a semiparametric model and I keep getting poor results, attached is the cumulative hazard which for some reason is decreasing, I've tested using different parameters for the model and even removing all features, but still no good results. Is this a problem with using a spline fitter for the baseline? because I have another model with piecewise baseline which works alright.


naf = NelsonAalenFitter()
naf.fit(train["subscription_age"], event_observed=train["status"])

model = CoxPHFitter("spline",n_baseline_knots=4, penalizer=0.1, l1_ratio=0.2)
model.fit(train, duration_col='subscription_age', event_col='status')
model.print_summary()

ax=naf.plot_cumulative_hazard()
model.baseline_cumulative_hazard_.plot(ax=ax)

image

droully avatar Oct 19 '21 03:10 droully

Hi @droully, hm you're correct that this doesn't look right. Apriori, it's hard for me to diagnose without having your dataset available. Are you okay sharing (over email?)?

For now, can you post an image of the model.baseline_hazard_?

CamDavidsonPilon avatar Oct 19 '21 14:10 CamDavidsonPilon

Thank you for the answer, here are both the model.baseline_hazard_ and model.baseline_survival_, they look really bad. I have no problem in sending you the data.

image image

droully avatar Oct 19 '21 14:10 droully

Definetly shouldn't be negative! Great, send it to me at [email protected]

CamDavidsonPilon avatar Oct 19 '21 15:10 CamDavidsonPilon