Computes the K-fold cross-validated mean squared prediction error for lars, lasso, or forward stagewise.
cv.lars(x, y, K = 10, index, trace = FALSE, plot.it = TRUE, se = TRUE,
type = c("lasso", "lar", "forward.stagewise", "stepwise"),
mode=c("fraction", "step"), ...)
Input to lars
Input to lars
Number of folds
Abscissa values at which CV curve should be computed.
If mode="fraction"
this is the fraction of the saturated
|beta|. The default value in this case is index=seq(from = 0, to =
1, length =100)
.
If mode="step"
, this is the number of steps in lars
procedure. The default is complex in this case, and depends on
whether N>p
or not. In principal it is index=1:p
.
Users can supply their own values of index (with care).
Show computations?
Plot it?
Include standard error bands?
type of lars
fit, with default "lasso"
This refers to the index that is used for
cross-validation. The default is "fraction"
for
type="lasso"
or type="forward.stagewise"
. For
type="lar"
or type="stepwise"
the default is "step"
Additional arguments to lars
Invisibly returns a list with components (which can be plotted using plotCVlars
)
As above
The CV curve at each value of index
The standard error of the CV curve
As above
Efron, Hastie, Johnstone and Tibshirani (2003) "Least Angle Regression" (with discussion) Annals of Statistics; see also https://hastie.su.domains/Papers/LARS/LeastAngle_2002.pdf.
# NOT RUN {
data(diabetes)
attach(diabetes)
cv.lars(x2,y,trace=TRUE,max.steps=80)
detach(diabetes)
# }
Run the code above in your browser using DataLab