cv.ernet: Cross-validation for ernet

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/cv.ernet.R

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

1
2
cv.ernet(x, y, lambda = NULL, pred.loss = "loss", 
         nfolds = 5, foldid, tau = 0.5, ...)

Arguments

x

x matrix as in ernet.

y

response variable y as in ernet.

lambda

optional user-supplied lambda sequence; default is NULL, and ernet chooses its own sequence.

nfolds

number of folds. Default value is 5. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowed is 3.

foldid

an optional vector of values between 1 and nfolds, identifying what fold each observation is in. If supplied, nfolds will be supressed.

pred.loss

loss function used to calculate cross-validation error. The only option now is "loss", which is the asymmetric squared error loss (ASEL).

tau

the asymmetry coefficient τ used in the asymmetric squared error loss.

...

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 lambda used in the fits.

cvm

the mean cross-validated error - a vector of length length(lambda).

cvsd

estimate of standard error of cvm.

cvupper

upper curve = cvm+cvsd.

cvlower

lower curve = cvm-cvsd.

nzero

number of non-zero coefficients at each lambda.

name

a text string indicating type of measure (for plotting purposes).

ernet.fit

a fitted ernet object for the full data.

lambda.min

The optimal value of lambda that gives minimum cross validation error cvm.

lambda.1se

The largest value of lambda such that error is within 1 standard error of the minimum.

Author(s)

Yuwen Gu and Hui Zou
Maintainer: Yuwen Gu <guxxx192@umn.edu>

See Also

ernet

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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)

Example output

Loading required package: Matrix

SALES documentation built on May 2, 2019, 5:08 a.m.

Related to cv.ernet in SALES...