You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I’m encountering a problem implementing and visualizing restricted cubic splines (RCS) with the lifelines library in Python. My goal is to reproduce the RCS visualization provided by the R package rms, but I haven’t been able to get a correct RCS plot.
I’ve included my current lifelines code below. When you have time, could you review it and suggest what I might be missing or how to improve it?
Thank you in advance!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I’m encountering a problem implementing and visualizing restricted cubic splines (RCS) with the lifelines library in Python. My goal is to reproduce the RCS visualization provided by the R package rms, but I haven’t been able to get a correct RCS plot.
I’ve included my current lifelines code below. When you have time, could you review it and suggest what I might be missing or how to improve it?
Thank you in advance!
cancer.csv
temp2 = pd.read_csv("./cancer.csv")
---------- 0) Package load ----------
---------- 1) RCS basis function (as is) ----------
---------- 2) Build RCS ----------
---------- 3) Prepare covariates (★ key added part) ----------
---------- 4) Build training df_model ----------
---------- 5) Fit ----------
---------- 6) Build prediction matrix for visualization (★ also key) ----------
---------- 7) Predict partial hazard & normalize by reference HR (readability) ----------
---------- 8) Plot ----------
Beta Was this translation helpful? Give feedback.
All reactions