GeneralizedGammaFitter¶
- class lifelines.fitters.generalized_gamma_fitter.GeneralizedGammaFitter(*args, **kwargs)¶
This class implements a Generalized Gamma model for univariate data. The model has parameterized form:
The survival function is:
\[\begin{split}S(t)=\left\{ \begin{array}{} 1-\Gamma_{RL}\left( \frac{1}{{{\lambda }^{2}}};\frac{{e}^{\lambda \left( \frac{\log(t)-\mu }{\sigma} \right)}}{\lambda ^{2}} \right) \textit{ if } \lambda> 0 \\ \Gamma_{RL}\left( \frac{1}{{{\lambda }^{2}}};\frac{{e}^{\lambda \left( \frac{\log(t)-\mu }{\sigma} \right)}}{\lambda ^{2}} \right) \textit{ if } \lambda \le 0 \\ \end{array} \right.\,\!\end{split}\]where \(\Gamma_{RL}\) is the regularized lower incomplete Gamma function.
This model has the Exponential, Weibull, Gamma and Log-Normal as sub-models, and thus can be used as a way to test which model to use:
When \(\lambda = 1\) and \(\sigma = 1\), then the data is Exponential.
When \(\lambda = 1\) then the data is Weibull.
When \(\sigma = \lambda\) then the data is Gamma.
When \(\lambda = 0\) then the data is Log-Normal.
When \(\lambda = -1\) then the data is Inverse-Weibull.
When \(\sigma = -\lambda\) then the data is Inverse-Gamma.
After calling the
.fit
method, you have access to properties like:cumulative_hazard_
,survival_function_
, A summary of the fit is available with the methodprint_summary()
.Important
The parameterization implemented has \(\log\sigma\), thus there is a ln_sigma_ in the output. Exponentiate this parameter to recover \(\sigma\).
Important
This model is experimental. It’s API may change in the future. Also, it’s convergence is not very stable.
- Parameters:
alpha (float, optional (default=0.05)) – the level in the confidence intervals.
Examples
from lifelines import GeneralizedGammaFitter from lifelines.datasets import load_waltons waltons = load_waltons() ggf = GeneralizedGammaFitter() ggf.fit(waltons['T'], waltons['E']) ggf.plot() ggf.summary
- cumulative_hazard_¶
The estimated cumulative hazard (with custom timeline if provided)
- Type:
DataFrame
- hazard_¶
The estimated hazard (with custom timeline if provided)
- Type:
DataFrame
- survival_function_¶
The estimated survival function (with custom timeline if provided)
- Type:
DataFrame
- cumulative_density_¶
The estimated cumulative density function (with custom timeline if provided)
- Type:
DataFrame
- density_¶
The estimated density function (PDF) (with custom timeline if provided)
- Type:
DataFrame
- variance_matrix_¶
The variance matrix of the coefficients
- Type:
DataFrame
- median_survival_time_¶
The median time to event
- Type:
float
- lambda_¶
The fitted parameter in the model
- Type:
float
- rho_¶
The fitted parameter in the model
- Type:
float
- alpha_¶
The fitted parameter in the model
- Type:
float
- durations¶
The durations provided
- Type:
array
- event_observed¶
The event_observed variable provided
- Type:
array
- timeline¶
The time line to use for plotting and indexing
- Type:
array
- entry¶
The entry array provided, or None
- Type:
array or None
- percentile(p)¶
Return the unique time point, t, such that S(t) = p.
- Parameters:
p (float)