Repository navigation
Description
(I don't see an issue, but I thought it was mentioned before.)
Stata has accelerated failure time and proportional hazard parametric survival models. Implementing those is a GSOC idea that doesn't require a heavy statistics background, similar to last years count models.
parking some references:
the two books seem to have enough math, but I didn't read much of them
Kalbfleisch, John D., and Ross L. Prentice. 2002. The Statistical Analysis of Failure Time Data. Wiley Series in Probability and Statistics. Hoboken, NJ, USA: John Wiley & Sons, Inc. https://doi.org/10.1002/9781118032985.
chapter two has the intro to exponential, weibull and other parametric models, including log-linear AFT.
Lee, Elisa T., and John Wenyu Wang. 2003. Statistical Methods for Survival Data Analysis Wiley Series in Probability and Statistics. Hoboken, NJ, USA: John Wiley & Sons, Inc. https://doi.org/10.1002/0471458546.
the parts are a bit spread out, chapter 6 distributions, chapter 7 parametric models without covariates, chapter 11 with covariates.
my guess
- starting with exponential and weibull in continuous time should be easy
- use those two to get general setup like class structure, main methods, Pattern should follow Poisson and similar with log-link/exponential mean function
- add required extra methods to parametric distribution, hazard, ...
- data handling and supporting exploratory graphical support for surviaval/failure times
- numerical details for derivatives, score, hessian, predict AFAPossible
- (extras for later) diagnostics, goodness-of-fit, gof, comparing nested or non-nested models
One of the extensions asked for in scipy is estimation just of distribution parameters (no covariates) for general censored models.
related parts: discrete time, grouped or interval censored data, see also #1764 #2763 #2764
(semi-parametric survival with Poisson or GLM)
Activity
josef-pkt commentedon Feb 19, 2018
a notebook with some Weibull AFT experiments mainly to get an idea about the distributional and link structure
https://gist.github.com/josef-pkt/10caecb77f0bf6e11826ac0b01cbf27f
Related: transformed endog #3560 (compositional), #2373, #1449 for prediction, and similar, e.g. Box-Cox
Note here we are in a full MLE setting, not in a QMLE/LEF setting. Also in AFT the emphasis is not on
meanparameters, the model is in terms of scale or some parameters. We are more interested in quantiles than in expected outcome or mean. Similar transforming a lognormal captures the median and not mean. We can recover the mean (expected value) under the assumption that the likelihood is correctly specified. Median or other statistics might be non- or semi-parametrically identified.josef-pkt commentedon Feb 20, 2018
another reference
Collett, D. 2003. Modelling Survival Data in Medical Research. 2nd ed. Chapman & Hall/CRC Texts in Statistical Science Series. Boca Raton, Fla: Chapman & Hall/CRC.
chapter 6 and 7 on AFT and diagnostic are a good read.
Chapter 6 is not very explicit on the maximum likelihood estimation, but has a good summary and derivation of the distributional properties and results statistics, i.e. of different parameterization, survival, hazard, cumulative hazard, predicted quantiles, for Weibull, log-logistic and log-normal models.
a relatively simple derivation of MLE including derivatives is in
Hosmer, David W., Stanley Lemeshow, and Susanne May. 2008. Applied Survival Analysis: Regression Modeling of Time-to-Event Data. 2nd ed. Wiley Series in Probability and Statistics. Hoboken, N.J: Wiley-Interscience.
josef-pkt commentedon Feb 20, 2018
another issue:
marginsfor parametric survival modelI haven't seen it mentioned yet, but this should apply in the same way as in discrete_margins.
Similar to the new count models with want to have various predicted functions. But we still need a general get_prediction version for those, i.e. with standard errors and confidence intervals.
Also, we need the eform of parameters or linear predictor because of the exponential function in the AFT models. Collett has a clear description of the predicted results depending multiplicatively on exp(linpred) in AFT models, e.g. multiplier in predicted median survival time.
However, AFT and PH have different "invariant" or "equivariant" predictions, so we need something more generic to compare across model types (e.g. similar as in risk ratio versus odds ratio in log-binomial versus logit)
aside terminology: maybe we should use more "duration", failure, survival, life time are all interpretation of the same thing depending on the application.
josef-pkt commentedon Feb 20, 2018
and another possible model class
Collett 2003 section 6.7 parameterization as proportional odds model which essentially ends up as logit-linear model. Maybe we can generalize by using arbitrary link functions. (but not enough details or information distributional assumptions. not a priority target for now)
log-logistic is the only model that is an AFT model and a proportional odds model
similarly
Weibull is the only model that is an AFT model and a proportional hazard model.
josef-pkt commentedon Feb 20, 2020
stackoverflow question asking for Weibul
https://stackoverflow.com/questions/60326227/r-equivalent-of-parametric-survial-model-in-python-by-fitting-a-weibull-regressi
josef-pkt commentedon Mar 13, 2021
parking a reference, I'm not sure it's interesting enough
Etezadi-Amoli, Jamshid, and Antonio Ciampi. 1987. “Extended Hazard Regression for Censored Survival Data with Covariates: A Spline Approximation for the Baseline Hazard Function.” Biometrics 43 (1): 181–92. https://doi.org/10.2307/2531958.
They use a quadratic truncated power spline with shape constraints to model baseline hazard, requires optimization under inequality constraints. Likelihood function includes cumulative hazard, so integral of baseline hazard, spline is also needed.
general theme for this and similar articles:
non- or semi-non- parametric estimation of hazard function
combining or selecting between proportional hazard and accelerated failure time models
josef-pkt commentedon Jun 16, 2021
I'm not sure I realized this before:
In the model for time (not log time), the linear prediction part is in the scale with log link, i.e. exponential scale function.
I'm not sure if scale = exp( X b) or exp(- X b) in standard AFT form.
It is also a multiplicative model log(t) = x b + e => t = exp(xb) * exp(e)
eis random variable (additive error) forlog(t)exp(e)is random variable (multiplicative error) fortmultiplicative factor of a random variable just means changing the scale.
This means that we get AFT just by modeling a distribution on R+ with an exp scale function.
context: This also applies to discrete count variables created by discretization where we have a scale variable of the underlying continuous distributions #7488 and #7479
The basic structure with 1 link would have fixed loc, exp scale function and constant shape parameters. This case would easily fit within current structure of e.g. count models like negbin and gpp.
in terms of parameterization of transformed distributions #7246 #7241, we have the choice between
Only our interest is reversed, we are interested in the R+ distribution, and not the one we could get if we, e.g. log, transform the data, i.e. we want Weibull with exp scale function, and not an extreme value distribution for the log with
locandscale.(The reason to go "backwards" is computational and not theoretical or as a matter of interest, same problem as in GLM with inverse mean function.)
josef-pkt commentedon Jun 23, 2021
another thought
For some things we might want to use the scale normalized random variable or distribution, e.g. for gof or minimum distance
If we can reduce it to an iid variable similar to an additive residual in a linear model, then we don't need to have observation specific gof statistic.
Example if we need to approximate an integral or expectation, then in some cases we might be able to use the "multiplicative residual" (scale corrected observations) in a similar way as an additive residual.
josef-pkt commentedon Aug 23, 2021
AFT models precision = 1 / scale.
I cleaned up my weibull class from the notebook, using a link for scale. This will have negative params compared to AFT version.
For exp function (log-link) we can use negative linear predictor, but that doesn't work for other link functions.
Using scipy distributions directly requires
scale, using precision we will need to divide by scale twice, instead of multiplying by precision.We should have AFT comparable to other pacckages and parameterized in the same way.
But AFT is just a special case for log-link
Aside: Stata allows also the auxiliary/shape parameter to depend on some exog.
Useful for example for models with strata, where both parameters depend on a (categorical) stratification variable.
josef-pkt commentedon Aug 23, 2021
reliability uses scale parameterization for distribution, no exog
https://www.reliawiki.com/index.php/Appendix:_Log-Likelihood_Equations
includes likelihood function and derivatives, left, right and interval censored similar to Tobit, see #7638
Their
logmodels, log-normal and log-logistic, use parameterization from log-transformed distribution, not shape-scale as in scipy.josef-pkt commentedon Aug 23, 2021
aside to discrete, discretized duration observations
In the example in my old notebook (now used for PR #7666) taken from lifetimes, the observations are discrete and not very large. Data is for duration of regimes in years.
As alternative to using continuous lifetime distributions, we could use DiscretizedCount distribution. We would need to add additional censoring, or treat counts as general interval censored data.
General interval censoring loses the numeric integer information (discretized count uses a fixed censoring grid).