All projects
research

Survival Analysis Kit

Time-to-event analysis on NumPy and SciPy

BiostatisticsPublic HealthStatistical ModelingPython
View project

Overview#

Clinical and public-health questions are often “how long until an event”, with many participants still event-free when follow-up ends. This toolkit covers the standard methods for that kind of right-censored data with only NumPy and SciPy as dependencies.

What it does#

  • Kaplan-Meier curves with Greenwood variance and confidence bands.
  • Log-rank tests for two or more groups.
  • Nelson-Aalen cumulative hazard.
  • Discrimination: Harrell’s concordance index with an explicit rule for ties, and time-dependent AUC with inverse-probability-of-censoring weights.
  • Cox proportional hazards with hazard ratios, Wald intervals, Schoenfeld and martingale residuals, and the Grambsch-Therneau test.
  • Beyond Cox: restricted mean survival time, Weibull AFT, Aalen additive models, and competing risks (cumulative incidence, Fine-Gray, Gray’s test).

Usage#

python -m survival_kit.cli generate --n 400 --censor-fraction 0.2 --group-scale-ratio 2.0 --seed 42 --out sample.csv
python -m survival_kit.cli compare --data sample.csv --group-col group
python -m survival_kit.cli cox --data sample.csv --group-col group --out cox.csv

Engineering#

MIT licensed, with tests and synthetic data generators with known answers, so each estimator can be checked against the truth.