# API Reference


## The response


The Surv object, the spine of every analysis.


[Surv](Surv.md#greenwood.Surv)  
A validated time-to-event response for survival analysis.

[CensoringType](CensoringType.md#greenwood.CensoringType)  
The censoring flavor of a `Surv` response.


## Non-parametric estimators


Kaplan-Meier survival and Nelson-Aalen cumulative hazard.


[KaplanMeier](KaplanMeier.md#greenwood.KaplanMeier)  
Kaplan-Meier product-limit estimator of the survival function.

[NelsonAalen](NelsonAalen.md#greenwood.NelsonAalen)  
Nelson-Aalen estimator of the cumulative hazard.


## Regression


Cox proportional hazards and parametric AFT models.


[CoxPH](CoxPH.md#greenwood.CoxPH)  
Cox proportional hazards model.

[CoxNet](CoxNet.md#greenwood.CoxNet)  
Elastic-net penalized Cox proportional hazards model.

[ZPHResult](ZPHResult.md#greenwood.ZPHResult)  
Proportional-hazards test results (Grambsch-Therneau).

[AFT](AFT.md#greenwood.AFT)  
Parametric accelerated failure time model.

[RoystonParmar](RoystonParmar.md#greenwood.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](AalenJohansen.md#greenwood.AalenJohansen)  
Aalen-Johansen estimator of cumulative incidence functions for competing risks.

[FineGray](FineGray.md#greenwood.FineGray)  
Fine-Gray subdistribution hazard model for a competing-risks endpoint.

[MultiState](MultiState.md#greenwood.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()](logrank_test.md#greenwood.logrank_test)  
Compare survival across groups using the weighted log-rank (G-rho) test.

[trend_test()](trend_test.md#greenwood.trend_test)  
Test for linear trend across ordered groups using the log-rank test family.

[pairwise_logrank_test()](pairwise_logrank_test.md#greenwood.pairwise_logrank_test)  
Pairwise log-rank tests for all group pairs with multiple-comparison correction.

[TestResult](TestResult.md#greenwood.TestResult)  
The outcome of a log-rank group comparison test.

[rmst_test()](rmst_test.md#greenwood.rmst_test)  
Test for equality of RMST across two or more groups.

[rmst_diff()](rmst_diff.md#greenwood.rmst_diff)  
Compute RMST difference between two groups with confidence interval.

[pairwise_rmst_test()](pairwise_rmst_test.md#greenwood.pairwise_rmst_test)  
Pairwise RMST tests for all group pairs with multiple-comparison correction.

[RMSTResult](RMSTResult.md#greenwood.RMSTResult)  
Results of an RMST comparison test or difference calculation.

[logrank_n_events()](logrank_n_events.md#greenwood.logrank_n_events)  
Number of events needed for the log-rank test to reach a target power.

[logrank_power()](logrank_power.md#greenwood.logrank_power)  
Power of the log-rank test given the number of observed events.

[logrank_sample_size()](logrank_sample_size.md#greenwood.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()](concordance_index.md#greenwood.concordance_index)  
Harrell's concordance index: discrimination of risk scores against observed survival.

[brier_score()](brier_score.md#greenwood.brier_score)  
IPCW (Graf) Brier score of predicted survival probabilities at specified times.

[integrated_brier_score()](integrated_brier_score.md#greenwood.integrated_brier_score)  
Integrated (time-averaged) Brier score across multiple time points.

[cross_validate()](cross_validate.md#greenwood.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_survival.md#greenwood.plot_survival)  
Plot Kaplan-Meier survival curve(s) with Altair.

[risk_table()](risk_table.md#greenwood.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](EventTable.md#greenwood.EventTable)  
Per-time risk-set tabulation (optionally within strata).

[event_table()](event_table.md#greenwood.event_table)  
Tabulate the event history: risk sets and events at each observed time.
