Learn R Programming

elasticnet (version 1.3)

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

Description

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

Usage

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

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

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab