Add FlexibleParametricPHFitter: Royston-Parmar flexible parametric survival model#1690
Open
hass-nation wants to merge 1 commit into
Open
Add FlexibleParametricPHFitter: Royston-Parmar flexible parametric survival model#1690hass-nation wants to merge 1 commit into
hass-nation wants to merge 1 commit into
Conversation
Implements the Royston-Parmar flexible parametric proportional-hazards model (Statistics in Medicine, 21(15):2175-2197, 2002). Algorithm details: - Models log(H(t|x)) = s(log(t); gamma) + x'*beta where s() is a restricted natural cubic spline (RCS) in log(t). - Fit via MLE using analytical gradients and L-BFGS-B (scipy). - Default n_baseline_knots=4 placed at quantiles of log(event times). - RCS basis handles K=2 (Exponential), K=3 (Weibull-like) and K>=4 (full cubic spline) cases correctly. New files: - lifelines/fitters/royston_parmar_fitter.py -- FlexibleParametricPHFitter - tests/test_royston_parmar_fitter.py -- 17 tests, all passing Modified: - lifelines/__init__.py -- export FlexibleParametricPHFitter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
FlexibleParametricPHFitter, a flexible parametric proportional hazards model that uses restricted natural cubic splines (RCS) on log(t) to model the log cumulative hazard log(H(t)) = s(log(t); γ) + x'β.Unlike the existing Weibull/log-normal/log-logistic fitters which impose a fixed parametric shape, the Royston-Parmar model adapts the baseline hazard to the data via a spline with user-controlled knot count.
Algorithm
New file
lifelines/fitters/royston_parmar_fitter.py—FlexibleParametricPHFitterclassInterface
Tests
17 tests — shape checks, monotone survival, concordance index above chance, custom knot locations, covariate effects, AIC computation. All pass.
Reference
Royston, P. & Parmar, M. K. B. (2002). Flexible parametric proportional-hazards and proportional-odds models for censored survival data, with application to prognostic modelling and estimation of treatment effects. Statistics in Medicine, 21(15), 2175–2197.