The xgboost package enables survival modeling using parameter arguments: objective = "survival:cox" and eval_metric = "cox-nloglik".

The predict method for the resulting model only outputs risk scores (same as type = "risk" in the survival::coxph function in r).

How do I use xgboost to predict entire survival curves?


1 Answer 1


The proportional hazard model assumes hazard rates of the form: $h(t|X) = h_0(t) \cdot risk(X)$ where usually $risk(X) = exp(X\beta)$. The xgboost predict method returns $risk(X)$ only. What we can do is use the survival::basehaz function to find $h_0(t)$.

Problem is it's not "calibrated" to the actual baseline hazard rate computed in xgboost. What we can do is find some constant $C$ that minimizes the ibrier score between the sample observed death/censorship times and $h_0(t) \cdot risk(X) \cdot C$.

I've implemented this approach in a tiny R package I've written.

  • $\begingroup$ How to calculate C-index in this setting? Can your package accomplish this? Thanks! $\endgroup$
    – Tommy
    Mar 31 at 14:07
  • $\begingroup$ My package does not include that functionality. I would recommend using either the pec or riskRegression packages $\endgroup$
    – Iyar Lin
    Apr 1 at 17:34
  • $\begingroup$ How do censorship times contribute to the ibrier score? $\endgroup$
    – 42-

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.