Flexible parametric survival analysis with the elastic net

Version 0.60 (84.4 KB) by Statovic
Parametric survival analysis for proportional hazards regression and competing risk models.
Updated 23 Dec 2022

View License

This toolbox implements flexible parametric survival analysis for the proportional hazards regression model with optional right censoring. There are three main functions:
  1. flexph(): parametric proportional hazards regression;
  2. flexphreg(): parametric proportional hazards regression with elastic net regularization;
  3. flexphcr(): parametric proportional hazards regression for competing risk data.
We have five kinds of parametric baseline hazard functions: exponential, Weibull, natural cubic splines, log-logistic and integrated splines (or i-splines); see below for mathematical details.
Let t = (t_1, ..., t_n) denote n time-to-event data points. We model the hazard function at time t by:
h(t) = h_0(t) exp(z'*beta), t > 0, beta \in R^p
where z is a vector of covariates and h_0(t) is the baseline hazard function to be discussed below. The cumulative hazard function is
H(t) = H_0(t) exp(z'*beta)
where H_0(t) is the cumulative baseline hazard. The survival function is then
S(t) = exp(-H(t)) = exp(-H_0(t))^exp(z'*beta) = S_0(t)^exp(z'*beta)
where S_0(t)=exp(-H_0(t)) is the baseline survival function. Following Royston and Mahesh (2002), we write the log of the cumulative hazard function H(t) as:
log H(t) = log H_0(t) + z'*beta = s(t) + z'*beta
where s(t) is a parametric log cumulative baseline hazard function which may depend on other parameters. The type of s(t) is selected with the argument modeltype. Possible options are:
(1) 'exp': exponential baseline hazard [exponential regression]
Log cumulative baseline hazard: s(t) = gamma_0 + log(t)
(2) 'natural': natural cubic splines
Baseline cumulative hazard is fitted using natural cubic splines with m internal knots (k_min,k_1,...k_m,k_max). Let x = log(t). We have:
s(t) = gam0 + gam1 x + gam2 v_1(x) + ...
where the j-th basis function v_j(x) is:
v_j(x) = max(0,x-k_j)^3 - lam_j max(0,x-k_min)^3 - (1-lam_j) max(0,x-k_max)^3
lam_j = (k_max - k_) / (k_max - k_min).
The argument m>0 determines the number of knots. For more technical details, please see Royston and Mahesh (2002).
(3) 'log-logistic: log-logistic baseline hazard
(4) 'weibull': Weibull baseline hazard [Weibull regression]
Log cumulative baseline hazard: s(t) = gamma_0 + gamma_1 x
(5) 'ispline': integrated splines.
All functions allo right censoring with the argument d = (d_1, ..., d_n) where d(i)=0 implying a censored data point.
For examples of usage, please see example[1-10].m.

Cite As

Statovic (2024). Flexible parametric survival analysis with the elastic net (https://www.mathworks.com/matlabcentral/fileexchange/119998-flexible-parametric-survival-analysis-with-the-elastic-net), MATLAB Central File Exchange. Retrieved .

Royston, Patrick, and Mahesh K. B. Parmar. “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, vol. 21, no. 15, Wiley, 2002, pp. 2175–97, doi:10.1002/sim.1203.

View more styles
MATLAB Release Compatibility
Created with R2022b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

-added flexphcr() for competing risk analysis and corresponding CIF functions
-added i-splines (enables monotonic cumulative baseline estimates)
-added further examples


-added a function to compute baseline survival and hazard functions from any model on the elastic net path
-improved examples


-fix for change in behaviour of fitcox() in Matlab versions prior to 2022


-added flexphreg() for elastic net regularisation
-updated printSummary()
-added two examples to demonstrate regularisation
-improved all examples


-added the log-logistic baseline hazard function (option 'log-logistic')
-improved parameter initialization
-added example6.m which fits a log-logistic baseline hazard


-better parameter initialization
-orthogonalization of spline bases implemented using the routine mgsog() by Mo Chen (sth4nth@gmail.com)
-improved search with Hessian calculation
-added printSummary() to print regression results


-fixed an issue estimation of baseline hazard with fitcox() in Matlab 2022b


-added exponential and Weibull proportion hazard regression models
-added two more examples