lambda
. This function is modified based on the cv
function from the glmnet
package.cv.cocktail(x,y,d,lambda=NULL,nfolds=5,foldid,...)
NULL
, and cocktail
chooses its own sequence.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
.nfold
identifying what fold each observation is in. If supplied,
nfold
can be missing.cv.cocktail
is returned, which is a
list with the ingredients of the cross-validation fit.
lambda
used in the fits.length(lambda)
.cvm
.cvm+cvsd
.cvm-cvsd
.lambda
.cocktail
object for the full data.lambda
that gives minimum
cross validation error cvm
.lambda
such that error is
within 1 standard error of the minimum.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.
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/
cocktail
, plot.cv.cocktail
.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