API Reference
The response
The Surv object, the spine of every analysis.
- Surv
-
A validated time-to-event response for survival analysis.
- CensoringType
-
The censoring flavor of a
Survresponse.
Non-parametric estimators
Kaplan-Meier survival and Nelson-Aalen cumulative hazard.
- KaplanMeier
-
Kaplan-Meier product-limit estimator of the survival function.
- NelsonAalen
-
Nelson-Aalen estimator of the cumulative hazard.
Regression
Cox proportional hazards and parametric AFT models.
- CoxPH
-
Cox proportional hazards model.
- CoxNet
-
Elastic-net penalized Cox proportional hazards model.
- ZPHResult
-
Proportional-hazards test results (Grambsch-Therneau).
- AFT
-
Parametric accelerated failure time model.
- RoystonParmar
-
Royston-Parmar flexible parametric survival model (proportional hazards scale).
Competing risks & multi-state
Cumulative incidence, the Fine-Gray model, and multi-state transition probabilities.
- AalenJohansen
-
Aalen-Johansen estimator of cumulative incidence functions for competing risks.
- FineGray
-
Fine-Gray subdistribution hazard model for a competing-risks endpoint.
- MultiState
-
Aalen-Johansen estimator of multi-state transition and occupancy probabilities.
Group comparisons
The log-rank test, trend tests for ordered groups, the G-rho (Fleming-Harrington) family, and restricted mean survival time (RMST) comparisons.
- logrank_test()
-
Compare survival across groups using the weighted log-rank (G-rho) test.
- trend_test()
-
Test for linear trend across ordered groups using the log-rank test family.
- pairwise_logrank_test()
-
Pairwise log-rank tests for all group pairs with multiple-comparison correction.
- TestResult
-
The outcome of a log-rank group comparison test.
- rmst_test()
-
Test for equality of RMST across two or more groups.
- rmst_diff()
-
Compute RMST difference between two groups with confidence interval.
- pairwise_rmst_test()
-
Pairwise RMST tests for all group pairs with multiple-comparison correction.
- RMSTResult
-
Results of an RMST comparison test or difference calculation.
- logrank_n_events()
-
Number of events needed for the log-rank test to reach a target power.
- logrank_power()
-
Power of the log-rank test given the number of observed events.
- logrank_sample_size()
-
Total sample size needed for the log-rank test to reach a target power.
Prediction performance
Concordance and the IPCW Brier score.
- concordance_index()
-
Harrell’s concordance index: discrimination of risk scores against observed survival.
- brier_score()
-
IPCW (Graf) Brier score of predicted survival probabilities at specified times.
- integrated_brier_score()
-
Integrated (time-averaged) Brier score across multiple time points.
- cross_validate()
-
Evaluate a survival model’s out-of-sample performance using k-fold cross-validation.
Visualization
plotnine survival curves and aligned numbers-at-risk tables.
- plot_survival()
-
Plot Kaplan-Meier survival curve(s) with Altair.
- risk_table()
-
Return the numbers-at-risk table as a standalone Altair chart.
Core kernel
The risk-set / event-table tabulation shared by KM, log-rank, and Cox.
- EventTable
-
Per-time risk-set tabulation (optionally within strata).
- event_table()
-
Tabulate the event history: risk sets and events at each observed time.