Dear Colleagues
I hope all is well.
I am doing penalised cox regression in python
I have managed to get the coefficients.
However, I am struggling to get the confidence interval.
I would really appreciate your help
The full code is in this link ( from line code 10 till line code 13)
https://scikit-survival.readthedocs.io/en/stable/user_guide/coxnet.html
The codes are:
best_model = gcv.best_estimator_.named_steps["coxnetsurvivalanalysis"]
best_coefs = pd.DataFrame(
best_model.coef_,
index=Xt.columns,
columns=["coefficient"]
)
non_zero = np.sum(best_coefs.iloc[:, 0] != 0)
print("Number of non-zero coefficients: {}".format(non_zero))
non_zero_coefs = best_coefs.query("coefficient != 0")
coef_order = non_zero_coefs.abs().sort_values("coefficient").index
_, ax = plt.subplots(figsize=(6, 8))
non_zero_coefs.loc[coef_order].plot.barh(ax=ax, legend=False)
ax.set_xlabel("coefficient")
ax.grid(True)