Fit additive trend filtering Cox model where each component function is estimated to be piecewise constant or polynomial. Tuning parameter is selected via k-fold cross-validation.
cv_tfCox(dat, ord=0, alpha=1, discrete=NULL, lambda.seq=NULL,
lambda.min.ratio=0.01, n.lambda=30, n.fold=5, seed=NULL, tol=1e-6,
niter=1000, stepSize=25, backtracking=0)A list that contains time, status and X. time is failure or censoring time, status is censoring indicator, and X is n x p matrix and may have p > n.
The polynomial order of the trend filtering fit; a non-negative interger (ord>= 3 is not recommended). For instance, ord=0 will produce piewise constant fit, ord=1 will produce piewise linear fit, and ord=2 will produce piewise quadratic fit.
The trade-off between trend filtering penalty and group lasso penalty. It must be in [0,1]. alpha=1 corresponds to the case with only trend filtering penalty to produce piecewise polynomial, and alpha=0 corresponds to the case with only group lasso penalty to produce sparsity of the functions. alpha between 0 and 1 is the tradeoff between the strength of these two penalties. For p < n, we suggest using 1.
A vector of covariate/feature indice that are discrete. Discrete covariates are not penalized in the model. Default NULL means that none of the covariates are discrete thus all covariates will be penalized in the model.
The sequence of positive lambda values to consider. The default is NULL, which calculates lambda.seq using lambda.min.ratio and n.lambda. If lambda.seq is provided, it will override the default. lambda.seq should be a decreasing positive sequence of values since cv_tfCox replies on warm starts to speed up the computation.
Smallest value for lambda.seq, as a fraction of the maximum lambda value, which is the smallest value such that the penalty term is zero. The default is 0.01.
The number of lambda values to consider. Default is 30.
The number of folds for cross-validation of lambda. The default is 5.
An optional number used with set.seed().
Convergence criterion for estimates.
Maximum number of iterations.
Iniitial step size. Default is 25.
Whether backtracking should be used 1 (TRUE) or 0 (FALSE). Default is 0 (FALSE).
An object with S3 class "cv_tfCox".
Optional lambda value chosen by cross-dalidation.
lambda sequence considered.
vector of average cross validation error with the same length as lambda.seq
Note that cv_tfCox does not cross-validate over alpha, and alpha should be provided. However, if the user would like to cross-validate over alpha, then cv_tfCox should be called multiple times for different values of alpha and the same seed. This ensures that the cross-validation folds (fold) remain the same for the different values of alpha. See the example below for details.
Jiacheng Wu & Daniela Witten (2019) Flexible and Interpretable Models for Survival Data, Journal of Computational and Graphical Statistics, DOI: 10.1080/10618600.2019.1592758
# NOT RUN {
#generate data
set.seed(123)
dat = sim_dat(n=100, zerof=0, scenario=1)
#fit piecewise constant functions
#cross-validation to choose the tuning parameter lambda with fixed alpha=1
cv = cv_tfCox(dat, ord=0, alpha=1, n.fold=2, seed=123)
plot(cv, showSE=TRUE)
# }
Run the code above in your browser using DataLab