0

I ran a Cox Proportional Hazard model using CPH.fitter from lifelines. Now I want the survival function for some individual parameters in the cohort. Using plot_covariate_groups method, I got the image of the survival function but I need to extract data which created the plot. Can anyone help me on this.

Thank you in advance!

1 Answers1

1

Referring to the source code, something like this would help (using the same args as the function call)

x_bar = cph._norm_mean.to_frame().T
X = pd.concat([x_bar] * values.shape[0])

if np.array_equal(np.eye(n_covariates), values):
    X.index = ["%s=1" % c for c in covariates]
else:
    X.index = [", ".join("%s=%g" % (c, v) for (c, v) in zip(covariates, row)) for row in values]
for covariate, value in zip(covariates, values.T):
    X[covariate] = value

cph.predict_survival_function(X)
Cam.Davidson.Pilon
  • 1,606
  • 1
  • 17
  • 31