cv.enet: Computes K-fold cross-validated error curve for elastic net

Description Usage Arguments Value Author(s) References Examples

View source: R/enet_funcs.R

Description

Computes the K-fold cross-validated mean squared prediction error for elastic net.

Usage

1
cv.enet(x, y, K = 10, lambda, s, mode,trace = FALSE, plot.it = TRUE, se = TRUE, ...)

Arguments

x

Input to lars

y

Input to lars

K

Number of folds

lambda

Quadratic penalty parameter

s

Abscissa values at which CV curve should be computed. A value, or vector of values, indexing the path. Its values depends on the mode= argument

mode

Mode="step" means the s= argument indexes the LARS-EN step number. If mode="fraction", then s should be a number between 0 and 1, and it refers to the ratio of the L1 norm of the coefficient vector, relative to the norm at the full LS solution. Mode="norm" means s refers to the L1 norm of the coefficient vector. Abbreviations allowed. If mode="norm", then s should be the L1 norm of the coefficient vector. If mode="penalty", then s should be the 1-norm penalty parameter.

trace

Show computations?

plot.it

Plot it?

se

Include standard error bands?

...

Additional arguments to enet

Value

Invisibly returns a list with components (which can be plotted using plotCVLars)

fraction

Values of s

cv

The CV curve at each value of fraction

cv.error

The standard error of the CV curve

Author(s)

Hui Zou and Trevor Hastie

References

Zou and Hastie (2005) "Regularization and Variable Selection via the Elastic Net" Journal of the Royal Statistical Society, Series B,76,301-320.

Examples

1
2
3
4
5
6
7
data(diabetes)
attach(diabetes)
## use the L1 fraction norm as the tuning parameter
cv.enet(x2,y,lambda=0.05,s=seq(0,1,length=100),mode="fraction",trace=TRUE,max.steps=80)
## use the number of steps as the tuning parameter
cv.enet(x2,y,lambda=0.05,s=1:50,mode="step")
detach(diabetes)

Example output

Loading required package: lars
Loaded lars 1.2


 CV Fold 1 


 CV Fold 2 


 CV Fold 3 


 CV Fold 4 


 CV Fold 5 


 CV Fold 6 


 CV Fold 7 


 CV Fold 8 


 CV Fold 9 


 CV Fold 10 

elasticnet documentation built on July 1, 2020, 11:48 p.m.