Survival estimators - CyrilB1531/lodestar GitHub Wiki
Development build. This page describes
main, not a released package. The latest published Lodestar.Survival is 0.1.0 — read its documentation.
Survival estimators — Lodestar.Survival
A duration and whether it ended in the event. That pair, one per subject, is what every estimator here takes, and it is the whole of what survival analysis needs to say something a mean cannot.
The problem censoring creates
A subject who leaves the study at month 20 without the event has not survived 20 months — they have survived at least 20 months. Averaging durations throws that away, and dropping the subject throws away more. Right censoring is a subject whose duration is a lower bound, and the three estimators below are the ones that use it rather than discard it.
The Cox proportional hazards model adds covariates: by how much each changes the hazard. Left truncation, interval censoring and the accelerated-failure-time models are each their own lot; nothing here does them.
Which estimator?
flowchart TD
A["What do you want to read off?"] --> B["the probability of surviving past t"]
A --> C["the accumulated risk by t"]
A --> D["whether two groups differ"]
A --> H["how much a covariate moves the hazard"]
B --> E["KaplanMeier"]
C --> F["NelsonAalen"]
D --> G["LogRank"]
H --> I["CoxProportionalHazards"]
KaplanMeier and NelsonAalen are two readings of one table, and they share a timeline by
construction — the same SurvivalStep[], built once. Where they part is at the end of a sample
whose last duration is observed: survival reaches zero and can fall no further, while the hazard
keeps the size of that last step.
What all three share
- The pair, as spans.
durationsandeventObserved, the same length, durations non-negative. Anything else is refused withArgumentException. - Ties are the point, not an edge case. A time carrying three events is not three times
carrying one, and the two estimators differ on exactly that — see
NelsonAalen.Estimate. - Time zero is a step, with everyone at risk and nothing having happened. It is the shape lifelines' own event table has, and it makes a curve plottable without a special first point.
- Each is a static class with no state, so all three are safe to call from any number of threads at once.
- Each is checked against
lifelines0.30.3, and the corpora are intests/oracles.
Types
| Type | What it is |
|---|---|
CoxOptions |
The interval level and the iteration budget a Cox fit takes. |
CoxProportionalHazards |
The Cox model, on Efron's partial likelihood. |
CoxSummary |
What it returns: the coefficient table, the likelihood-ratio test and the concordance. |
KaplanMeier |
The survival function, with Greenwood variance and log-log bounds. |
KaplanMeierCurve |
What it returns: the estimate, its bounds and its steps. |
LogRank |
The two-sample test comparing two survival curves. |
LogRankResult |
What it returns: a statistic, a p-value and the degrees of freedom. |
NelsonAalen |
The cumulative hazard function. |
NelsonAalenCurve |
What it returns: the accumulated hazard and its steps. |
SurvivalStep |
One step of either curve: a time, a risk set, and what happened at it. |
See also
- Survival analysis — the guide, with a worked trial.
- Python → C# equivalence — the
lifelinescall each of these replaces.