Exponential AFT Fitter
See original GitHub issueI used the WeibullAFTFitter
to produce an ExpAFTFitter.
The code I’ve changed:
def __init__(self, alpha=0.05, penalizer=0.0, l1_ratio=0.0, fit_intercept=True, model_ancillary=False):
self._ancillary_parameter_name = "rho_"
self._primary_parameter_name = "lambda_"
super(ExpAFTFitter, self).__init__(alpha, penalizer, l1_ratio, fit_intercept, model_ancillary)
def _cumulative_hazard(self, params, T, Xs):
lambda_params = params["lambda_"]
log_lambda_ = Xs["lambda_"] @ lambda_params
return safe_exp(np.log(np.clip(T, 1e-25, np.inf)) + log_lambda_)
def _log_hazard(self, params, T, Xs):
lambda_params = params["lambda_"]
log_lambda_ = Xs["lambda_"] @ lambda_params
return log_lambda_
This produces numerically correct estimates, with wrong signs though.
However, it also produces some warnings and when printing the summary it spits out an error too. Obviously because of the rho
.
I tried to exclude rho
, but then it started to whine about some _ancillary_parameter_name
.
So, my suggestion is to include an ExpAFTFitter()
.
And why wouldn’t there be a single AFT function which would take the distribution as an argument?
For instance:
from lifelines import AFTFitter
aft = AFTFitter()
aft.fit(rossi_dataset, duration_col='week', event_col='arrest', distribution='Weibull')
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
WeibullAFTFitter — lifelines 0.27.4 documentation
Bases: lifelines.fitters.ParametericAFTRegressionFitter , lifelines.fitters.mixins.ProportionalHazardMixin. This class implements a Weibull AFT model.
Read more >Accelerated Failure Time Models
Meaning of AFT models ... discuss estimation and model fitting, and go through an ... For a random time-to-event T, an accelerated failure...
Read more >Accelerated failure time model
In the statistical area of survival analysis, an accelerated failure time model (AFT model) is a parametric model that provides an alternative to...
Read more >Chapter 16 Survival Analysis
For Weibull and Exponential regression, instead of fitting a PH model, R and SAS fit an accelerated failure time model log(Yi) = α+βT....
Read more >Parametric survival models
3 Proportional hazards or AFT model? ... eha and the function survreg in the package survival that perform the task of fitting AFT...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To do the Exponential AFT model, try something like: https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Custom Regression Models.html
That is the preferred way to extend AFT models.
The latter model,
AFTFitter
might be included in a future release (it’s something I’ve thought about), but it bucks the trend of models being equal to classes.Yes, coefficients are identical in all 3.