Learn R Programming

fastcox (version 1.1.1)

cv.cocktail: Cross-validation for cocktail

Description

Does k-fold cross-validation for cocktail, produces a plot, and returns a value for lambda. This function is modified based on the cv function from the glmnet package.

Usage

cv.cocktail(x,y,d,lambda=NULL,nfolds=5,foldid,...)

Arguments

x
matrix of predictors, of dimension $N*p$; each row is an observation vector.
y
a survival time for Cox models. Currently tied failure times are not supported.
d
censor status with 1 if died and 0 if right censored.
lambda
optional user-supplied lambda sequence; default is NULL, and cocktail chooses its own sequence.
nfolds
number of folds - default is 5. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3.
foldid
an optional vector of values between 1 and nfold identifying what fold each observation is in. If supplied, nfold can be missing.
...
other arguments that can be passed to cocktail.

Value

cv.cocktail is returned, which is a list with the ingredients of the cross-validation fit.
lambda
the values of lambda used in the fits.
cvm
the mean cross-validated error - a vector of length length(lambda).
cvsd
estimate of standard error of cvm.
cvup
upper curve = cvm+cvsd.
cvlo
lower curve = cvm-cvsd.
nzero
number of non-zero coefficients at each lambda.
name
a text string indicating partial likelihood (for plotting purposes).
cocktail.fit
a fitted cocktail object for the full data.
lambda.min
The optimal value of lambda that gives minimum cross validation error cvm.
lambda.1se
The largest value of lambda such that error is within 1 standard error of the minimum.

Details

The function runs cocktail nfolds+1 times; the first to get the lambda sequence, and then the remainder to compute the fit with each of the folds omitted. The average error and standard deviation over the folds are computed.

References

Yang, Y. and Zou, H. (2012), "A Cocktail Algorithm for Solving The Elastic Net Penalized Cox's Regression in High Dimensions", Statistics and Its Interface. http://code.google.com/p/fastcox/

Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized linear models via coordinate descent," Journal of Statistical Software, 33, 1. http://www.jstatsoft.org/v33/i01/

See Also

cocktail, plot.cv.cocktail.

Examples

Run this code
data(FHT)
cv1<-cv.cocktail(x=FHT$x[,1:10],y=FHT$y,d=FHT$status,alpha=0.5,nfolds=3)
cv1
plot(cv1)

Run the code above in your browser using DataLab