PiecewiseExponentialRegressionFitter¶
- class lifelines.fitters.piecewise_exponential_regression_fitter.PiecewiseExponentialRegressionFitter(breakpoints, alpha=0.05, penalizer=0.0)¶
This implements a piecewise constant-hazard model at pre-specified break points.
\[\begin{split}h(t) = \begin{cases} 1/\lambda_0(x) & \text{if $t \le \tau_0$} \\ 1/\lambda_1(x) & \text{if $\tau_0 < t \le \tau_1$} \\ 1/\lambda_2(x) & \text{if $\tau_1 < t \le \tau_2$} \\ ... \end{cases}\end{split}\]where \(\lambda_i(x) = \exp{\beta_i x}\).
- Parameters:
breakpoints (list) – a list of times when a new exponential model is constructed.
penalizer (float) – penalize the variance of the \(\lambda_i\). See blog post below.
alpha (float, optional (default=0.05)) – the level in the confidence intervals.
Examples
See blog post here and paper replication here
- fit_intercept = True¶
- predict_cumulative_hazard(df, times=None, conditional_after=None) DataFrame ¶
Return the cumulative hazard rate of subjects in X at time points.
- Parameters:
X (numpy array or DataFrame) – a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order as the training data.
times (iterable, optional) – an iterable of increasing times to predict the cumulative hazard at. Default is the set of all durations (observed and unobserved). Uses a linear interpolation if points in time are not in the index.
- Returns:
cumulative_hazard_ – the cumulative hazard of individuals over the timeline
- Return type:
DataFrame