I have recently began using pysurvival package, for standard Cox regression. Their CoxPHModel predicts both the survival and the hazard functions, which I would naively expect to be related via $$ h(t) = -\frac{d}{dt}\log S(t) $$ However in practice I fail to establish the correspondence between the two: neither by numerically differentiating $S(t)$, nor by integrating $h(t)$. Perhaps, I miss some intricacies of this particular package or more general caveats of numerical procedures in the context of the Cox regression (e.g., those related to the finite sample size). I will appreciate the insights from those who have some experience with numerical Cox regression.

There are at least two different non-parametric estimation procedures involved here: Kaplan-Meier estimator for the survival function, and Nelso-Aalen estimator for the (cumulative) hazard function. According to this document, the two procedures are not equivalent, and this could be the source of discrepancies that I observe. Still, I would appreciate deeper insights in whether/how these are implemented in numerical packages.


1 Answer 1


With a semi-parametric Cox model, the hazard function is discontinuous/discrete. At times between events, the hazard is zero: according to the data you have on hand, there is no risk of an event during those time intervals. At each event time, the hazard is determined from the case that had the event versus all the other cases at risk at that time. That's why survival curves as a function of time in Cox models have jumps down between flat portions.

If you want to explore the theoretical mathematical relationships based on a particular set of data, it might be easier to use a continuous parametric model that is consistent with proportional hazards, like a Weibull distribution, instead.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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