cv.ernet {SALES} | R Documentation |
Cross-validation for ernet
Description
Does k-fold cross-validation for ernet, produces a plot, and returns a value
for lambda
. This function is based on the cv
function from the
glmnet
package.
Usage
cv.ernet(
x,
y,
lambda = NULL,
pred.loss = "loss",
nfolds = 5,
foldid,
tau = 0.5,
...
)
Arguments
x |
|
y |
response variable |
lambda |
optional user-supplied lambda sequence; default is |
pred.loss |
loss function used to calculate cross-validation error. The
only option now is |
nfolds |
number of folds. Default value is 5. Although |
foldid |
an optional vector of values between 1 and |
tau |
the asymmetry coefficient |
... |
other arguments that can be passed to ernet. |
Details
The function runs ernet
nfolds
+1 times; the
first to get the lambda
sequence, and the remainder to compute the
fit with each of the folds removed. The average error and standard
deviation over the folds are computed.
Value
an object of class cv.ernet
is returned, which is a
list with the ingredients of the cross-validation fit.
lambda |
the values of |
cvm |
the mean cross-validated error - a vector of length
|
cvsd |
estimate of standard error of |
cvupper |
upper curve = |
cvlower |
lower curve = |
nzero |
number of non-zero coefficients at each |
name |
a text string indicating type of measure (for plotting purposes). |
ernet.fit |
a fitted |
lambda.min |
The optimal value of |
lambda.1se |
The largest value of |
Author(s)
Yuwen Gu and Hui Zou
Maintainer: Yuwen Gu <yuwen.gu@uconn.edu>
See Also
Examples
set.seed(1)
n <- 100
p <- 400
x <- matrix(rnorm(n * p), n, p)
y <- rnorm(n)
tau <- 0.90
pf <- abs(rnorm(p))
pf2 <- abs(rnorm(p))
lambda2 <- 1
m1.cv <- cv.ernet(y = y, x = x, tau = tau, eps = 1e-8, pf = pf,
pf2 = pf2, standardize = FALSE, intercept = FALSE,
lambda2 = lambda2)