Skip to content

v0.6.0

Choose a tag to compare

@rich-iannone rich-iannone released this 13 Aug 03:58
· 157 commits to main since this release

Greenwood v0.6.0 is a major release focused on model diagnostics, flexible parametric modeling, and robust inference. It rounds out the Cox-diagnostics toolkit with leverage/hat-matrix influence measures, outlier visualization, spline-smoothed hazard-ratio curves, and time-stratified proportional-hazards tests. New RoystonParmar spline models and generalized gamma AFT regression add flexible alternatives to Weibull-based parametric fitting, while sandwich and clustered variance for Kaplan-Meier and a general-purpose bootstrap() utility extend confidence-interval support to previously unsupported quantities. Model evaluation also gains multi-metric cross-validation, an IPCW concordance index, AIC/BIC for CoxNet, and Gray's test for comparing competing-risks CIFs.

New Features

  • Expected RMST predictionspredict_expectation() computes restricted mean survival time as the area under each subject's predicted survival curve, available on CoxPH, AFT, and RoystonParmar, with ci=True support via integrated survival confidence bands. (#23)
  • Multi-metric cross-validationcross_validate() now accepts a metrics= list (e.g. ["concordance", "brier", "auc"]) to score several metrics per fold from a single model fit instead of refitting separately for each one. (#24)
  • Time transformations for cox_zphCoxPH.cox_zph() gains a transform= argument ("identity", "log", "km", "rank") controlling how event times are rescaled before testing for proportional-hazards violations, matching R's survival::cox.zph(). (#25)
  • AIC and BIC for CoxNet — New CoxNet.aic() and CoxNet.bic() methods, built on an effective_df() estimate of penalized model complexity, allow comparing regularized Cox fits without cross-validation. (#26)
  • Sandwich variance for Kaplan-MeierKaplanMeier(robust=True) replaces the classic Greenwood variance with an infinitesimal-jackknife (sandwich) estimator, recommended whenever fitting with non-integer (IPW/survey) weights. (#27)
  • Clustered robust variance for Kaplan-Meier — Passing cluster= to KaplanMeier().fit() sums per-subject influence contributions within each cluster before computing standard errors, correctly widening CIs for correlated observations (e.g. multiple records per site or patient). (#28)
  • Bootstrap confidence intervals — New bootstrap() function provides percentile, normal, and BCa confidence intervals for quantities without closed-form standard errors, including medians, RMST, survival probabilities, and between-group differences. (#29)
  • Predictive intervals for conditional and trajectory predictionsCoxPH.predict(..., ci=True) now supports confidence intervals for landmark conditional survival (conditional_after=) and time-varying-covariate trajectory (trajectory=) predictions, closing a previous NotImplementedError gap. (#30)
  • Leverage and hat-matrix diagnostics — New CoxPH.residuals("leverage") and CoxPH.influence_diagnostics() combine leverage, martingale/deviance residuals, dfbeta(s), and likelihood displacement into a single influence-diagnostics table. (#31)
  • Influence/outlier visualization — New plot_influence() renders side-by-side diagnostic panels (deviance, leverage, likelihood displacement) against the linear predictor, automatically labeling the most influential observations. (#32)
  • Time-stratified proportional-hazards testsCoxPH.cox_zph(breaks=[...]) splits follow-up into time windows and runs the Schoenfeld-residual PH test within each, revealing whether PH violations concentrate in specific periods. (#34)
  • Smooth hazard-ratio curves — New CoxPH.smooth_hr() and plot_smooth_hr() fit a spline basis for a continuous covariate to reveal non-linear log-hazard-ratio shapes, with confidence bands. (#35)
  • Flexible parametric survival models — New RoystonParmar class fits restricted cubic splines on the log cumulative hazard scale, matching flexsurv::flexsurvspline()/Stata's stpm2, for smooth non-Weibull hazard shapes while retaining proportional hazards. (#36)
  • Generalized gamma regressionAFT("gengamma") adds a shape parameter that nests Weibull, lognormal, and gamma as special cases; AFT.test_distributions() runs a likelihood-ratio test to check whether the added flexibility is warranted. (#37)
  • Gray's test for comparing CIFs — New grays_test() is the competing-risks analogue of the log-rank test, comparing cumulative incidence functions across groups using the same IPCW weighting as the Fine-Gray model. (#38)
  • IPCW concordance index — New concordance_index_ipcw() implements the Uno et al. (2011) estimator, a consistent concordance measure under censoring via inverse-probability-of-censoring weighting, with an optional tau= horizon. (#39)

Enhancements

  • Cox partial-likelihood risk-set computation was rewritten to use cumulative sums over subjects sorted by exit time instead of a per-event boolean scan, substantially speeding up model fitting on large datasets and datasets with many unique event times. (#33)