cv_tfCox {tfCox} | R Documentation |
Fit Trend Filtering Cox model and Choose Tuning Parameter via K-Fold Cross-Validation
Description
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.
Usage
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)
Arguments
dat |
A list that contains |
ord |
The polynomial order of the trend filtering fit; a non-negative interger ( |
alpha |
The trade-off between trend filtering penalty and group lasso penalty. It must be in [0,1]. |
discrete |
A vector of covariate/feature indice that are discrete. Discrete covariates are not penalized in the model. Default |
lambda.seq |
The sequence of positive lambda values to consider. The default is |
lambda.min.ratio |
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. |
n.lambda |
The number of lambda values to consider. Default is 30. |
n.fold |
The number of folds for cross-validation of |
seed |
An optional number used with |
tol |
Convergence criterion for estimates. |
niter |
Maximum number of iterations. |
stepSize |
Iniitial step size. Default is 25. |
backtracking |
Whether backtracking should be used 1 (TRUE) or 0 (FALSE). Default is 0 (FALSE). |
Details
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.
Value
An object with S3 class "cv_tfCox".
best.lambda |
Optional lambda value chosen by cross-dalidation. |
lambda.seq |
lambda sequence considered. |
mean.cv.error |
vector of average cross validation error with the same length as |
Author(s)
Jiacheng Wu
References
Jiacheng Wu & Daniela Witten (2019) Flexible and Interpretable Models for Survival Data, Journal of Computational and Graphical Statistics, DOI: 10.1080/10618600.2019.1592758
See Also
summary.cv_tfCox
, plot.cv_tfCox
, tfCox
Examples
#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)