Changelog

This changelog is generated automatically from GitHub Releases.

v0.5.0

2026-07-29 · GitHub

Greenwood v0.5.0 adds first-class support for time-varying covariates. The new split_episodes() utility handles the data-wrangling step that has historically been a barrier to TVC analysis: it takes a subject-level baseline table and a long-format visits table and merges them into the counting-process (interval-per-row) format that Surv.counting() and CoxPH already accept.

New Features

  • Time-varying covariate support via split_episodes() — Converts repeated-measurement data into counting-process (episode-split) format. Accepts a baseline table (one row per subject with follow-up time, event indicator, and time-fixed covariates) and a visits table (one row per subject/visit with time-varying covariate values), and produces a (tstart, tstop, event, …) dataset ready to pass directly to Surv.counting() and CoxPH.fit(). Supports last-observation-carried-forward (LOCF) via carry_forward=True and returns output in Pandas, Polars, or PyArrow depending on the format= argument. (#21)

v0.4.0

2026-07-24 · GitHub

Greenwood v0.4.0 expands the existing Cox-modeling capabilities with stronger model selection, richer diagnostics, and broader support for clustered survival data. This release also introduces cross-validated penalizer selection for CoxNet, shared frailty modeling (now including lognormal frailty), and stratified survival prediction workflows. A major secondary focus was improved correctness for baseline hazard confidence intervals.

New Features

  • Cross-validated CoxNet penalizer selection (cv_coxnet()) — Added k-fold cross-validation over penalizer paths (including best and 1-SE choices) to help select regularization strength more robustly. (#13)
  • Initial shared frailty support in CoxPH — Introduced cluster-level frailty modeling to better handle within-group dependence in survival outcomes. (#14)
  • Cox residual diagnostics — Added diagnostic residual outputs (including martingale, deviance, Schoenfeld-family, and influence-style residuals) to support model checking and PH-assumption assessment. (#18)
  • Lognormal shared frailty — Added lognormal frailty as an additional shared frailty option for clustered Cox models. (#19)
  • Stratified survival predictions — Improved prediction workflows for stratified Cox models so survival predictions are aligned to per-stratum baseline hazards. (#20)

Enhancements

  • Expanded CI test coverage for AFT survival prediction confidence intervals to improve reliability. (#17)

Bug Fixes

  • Cox baseline hazard confidence interval behavior was corrected for improved accuracy and consistency. (#16)

Documentation

  • Improved docstrings across the codebase for clearer API usage and reference quality. (#15)

v0.3.0

2026-07-20 · GitHub

Greenwood v0.3.0 is a substantial release focused on model evaluation, visualization, and statistical inference. It introduces time-dependent AUC for discrimination assessment across multiple horizons, forest plots for Cox hazard ratios, cumulative incidence function (CIF) plots for competing risks, and stratified RMST comparisons with inverse-variance pooling. Univariate parametric distribution fitting and extended AFT predictions round out the modeling improvements, while stratified k-fold cross-validation ensures honest performance estimates even with imbalanced event rates.

New Features

  • Time-dependent AUC — The new time_dependent_auc() function computes the Uno IPCW-weighted cumulative/dynamic AUC at specified time horizons, providing a discrimination summary that accounts for the time-varying nature of survival predictions. (#8)

  • Forest plots — The new plot_forest() function renders hazard-ratio plots with confidence intervals from fitted CoxPH models or RMSTResult objects. Supports both the Altair and plotnine backends. (#6)

  • CIF plots — The new plot_cif() function visualizes cumulative incidence functions from fitted AalenJohansen objects, with optional risk tables and per-group stratification for competing-risks analyses. (#10)

  • Univariate parametric models — The new Parametric class fits a single parametric survival distribution (Weibull, exponential, log-normal, log-logistic) to right-censored data by maximum likelihood, without covariates. The companion compare_distributions() helper fits all four families and returns an AIC/BIC comparison table for distribution selection. (#9)

  • Stratified RMST comparisonrmst_test() and rmst_diff() now accept a strata= argument for stratified group comparisons. Per-stratum RMST estimates are combined via inverse-variance pooling, matching the survRM2 reference implementation. (#5)

Enhancements

  • AFT.predict() now supports three additional prediction types: "mean" (expected survival time), "mean_remaining" (mean residual life at a given time), and "rmst" (restricted mean survival time up to a user-supplied tau). (#7)

  • AalenJohansen now accepts a conf_type= parameter ("plain", "log", "log-log") to control the confidence interval transformation for cumulative incidence estimates, consistent with R’s survfit. (#11)

  • cross_validate() now uses stratified k-fold splitting by default (stratified=True), ensuring each fold preserves the overall event proportion. This prevents singular matrix errors and biased CV estimates on imbalanced survival data. (#12)

v0.2.0

2026-07-10 · GitHub

Greenwood v0.2 provides several expansions to statistical testing, visualization capabilities, and confidence interval support. This release introduces stratified cross-validation for model evaluation, powerful group comparison tools including linear trend tests and restricted mean survival time (RMST) comparisons, interactive publication-ready forest plots and cumulative incidence visualizations with Great Tables integration, and comprehensive confidence interval estimation for baseline hazard and survival predictions in both Cox and parametric AFT models.

New Features

  • Stratified cross-validationcross_validate() now supports stratified k-fold CV for survival data, ensuring balanced outcome distributions across folds for more reliable model evaluation. (#3)

  • Forest plot visualization — New forest_plot() function creates interactive publication-quality forest plots for displaying hazard ratios and confidence intervals across multiple strata or subgroups with aligned at-risk tables. (#3)

  • Cumulative incidence plots — New cif_plot() function visualizes competing risk cumulative incidence functions with competing event stacks, censoring indicators, and optional at-risk tables. (#3)

  • Risk table with Great Tables — Enhanced risk table visualization using Great Tables for improved styling. (#3)

  • Baseline hazard confidence intervalsCoxPH.baseline_hazard() now supports confidence intervals via the ci= and conf_level= parameters, enabling uncertainty quantification for baseline hazard estimates. (#4)

  • AFT survival prediction confidence intervalsAFT.predict() now includes ci= and conf_type= parameters for confidence intervals on survival predictions using delta-method standard error estimation. (#4)

  • Linear trend test — New trend_test() function tests for linear trends across ordered groups (e.g., disease stages or dose levels) with support for Fleming-Harrington weights and stratification, providing higher power when groups are naturally ordered.

  • RMST group comparison — New rmst_test() function performs hypothesis tests for restricted mean survival time (RMST) equality across groups, with confidence intervals for RMST differences and support for both ratio and percentage-difference estimands.

  • Pairwise RMST comparisons — New pairwise_rmst_test() function enables multiple pairwise RMST comparisons with adjustable p-value correction methods (Bonferroni, Holm, etc.).

  • RMST difference utility — New rmst_diff() function calculates RMST differences and ratios between two groups with full confidence interval and variance estimation.

Bug Fixes

  • CoxPH coefficients are now properly invariant to uniform weight scaling, fixing a numerical issue where coefficient estimates changed with different weight magnitudes. (#2)

Enhancements

  • AFT confidence interval calculations now use stabilized log-log transformations for improved numerical stability in edge cases.
  • Multiple improvements to baseline hazard CI bounds and test stability for Cox models.
  • Enhanced input validation and type checking for visualization functions.

Documentation

  • Added comprehensive guide section for baseline hazard confidence intervals in Cox models.
  • Added AFT survival CI prediction guide with examples.
  • Documented linear trend tests in the group comparisons user guide.
  • Added RMST comparison examples to group comparisons documentation.

v0.1.0

2026-07-07 · GitHub

Initial release : modern survival analysis for Python which is Narwhals-native, R-validated, and beautifully visualized.

Highlights

Greenwood brings production-ready survival analysis to the Python data ecosystem. It works with whatever dataframe library you use (Pandas, Polars, PyArrow, or any Narwhals-compatible frame), every statistic is validated to tolerance against R’s survival package, and interactive publication-quality plots come out of the box. From a single Kaplan-Meier curve to competing-risks regression and penalized Cox models, everything lives under a unified API.

Core Statistical Methods

  • Surv response object — Represents survival data in right-, left-, and interval-censored form, counting-process form, left truncation, case weights, and multi-state endpoints, with built-in validation.
  • Kaplan-Meier estimation (KaplanMeier) — Survival curves with Greenwood variance, multiple confidence interval types, median/quantile survival, restricted mean survival time (RMST), and step-function predictions at arbitrary times.
  • Nelson-Aalen estimator (NelsonAalen) — Cumulative hazard curves with the same tidy output conventions as KaplanMeier.
  • Log-rank tests (logrank_test(), pairwise_logrank_test()) — Standard log-rank and the full G-rho (Fleming-Harrington) family for two or more groups, plus pairwise comparisons with p-value adjustment.
  • Cox proportional hazards (CoxPH) — Hazard-ratio regression with stratification, robust/sandwich variance, cluster-robust standard errors, baseline hazard prediction, and full model diagnostics (Schoenfeld residuals, proportional-hazards test via cox_zph(), concordance index).
  • Penalized Cox regression (CoxNet) — Lasso, ridge, and elastic-net penalized Cox models for high-dimensional covariates.
  • Accelerated failure time models (AFT) — Parametric survival regression with Weibull, exponential, log-normal, and log-logistic distributions, validated against R’s survreg.
  • Flexible parametric models (RoystonParmar) — Royston-Parmar spline-based survival models.
  • Competing risks (AalenJohansen, FineGray) — Cumulative incidence functions via Aalen-Johansen, subdistribution hazard regression via Fine-Gray, and multi-state transition probabilities (MultiState).
  • Event table (EventTable, event_table()) — Raw risk-set and event counts at each unique time point.

Model Performance & Validation

  • Concordance index — Harrell’s C-statistic for evaluating discriminative ability.
  • Brier score & integrated Brier score — IPCW-weighted calibration metrics at arbitrary time points.
  • Calibration — Graphical and numeric calibration assessment.
  • Cross-validation (cross_validate()) — K-fold cross-validation pipeline for any Greenwood model.
  • Power analysis (logrank_power(), logrank_sample_size(), logrank_n_events()) — Prospective sample size and power calculations for log-rank tests.

Visualization

  • plot_survival() — Interactive survival curves with confidence bands, censoring tick marks, and optional aligned at-risk tables; choose between Altair and plotnine backends.
  • risk_table() — Standalone aligned at-risk table, composable with any plot.

Tidy & Reproducible Output

  • Tidy summaries (tidy(), glance(), augment()) — Broom-compatible model summaries that return tidy DataFrames with consistent column names across all estimators.
  • Built-in datasetslung, veteran, ovarian, pbc, colon, mgus2, and more, loadable in any supported backend via gw.load_dataset(name, backend=...).
  • R-parity test harness — Every statistic ships with fixtures validated against R’s survival package.

Dataframe Compatibility

Greenwood is built on Narwhals, so all methods accept and return Pandas DataFrames, Polars DataFrames, PyArrow Tables, or any other Narwhals-compatible frame. Use the format= argument on output methods to control which type of table you get back.

Requirements

  • Python >= 3.10
  • Core dependencies: narwhals>=2.0, numpy>=1.24, scipy>=1.11