v0.6.0
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 predictions —
predict_expectation()computes restricted mean survival time as the area under each subject's predicted survival curve, available onCoxPH,AFT, andRoystonParmar, withci=Truesupport via integrated survival confidence bands. (#23) - Multi-metric cross-validation —
cross_validate()now accepts ametrics=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_zph—CoxPH.cox_zph()gains atransform=argument ("identity","log","km","rank") controlling how event times are rescaled before testing for proportional-hazards violations, matching R'ssurvival::cox.zph(). (#25) - AIC and BIC for
CoxNet— NewCoxNet.aic()andCoxNet.bic()methods, built on aneffective_df()estimate of penalized model complexity, allow comparing regularized Cox fits without cross-validation. (#26) - Sandwich variance for Kaplan-Meier —
KaplanMeier(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=toKaplanMeier().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 predictions —
CoxPH.predict(..., ci=True)now supports confidence intervals for landmark conditional survival (conditional_after=) and time-varying-covariate trajectory (trajectory=) predictions, closing a previousNotImplementedErrorgap. (#30) - Leverage and hat-matrix diagnostics — New
CoxPH.residuals("leverage")andCoxPH.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 tests —
CoxPH.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()andplot_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
RoystonParmarclass fits restricted cubic splines on the log cumulative hazard scale, matchingflexsurv::flexsurvspline()/Stata'sstpm2, for smooth non-Weibull hazard shapes while retaining proportional hazards. (#36) - Generalized gamma regression —
AFT("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 optionaltau=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)