cv.cpernet: Cross-validation for cpernet

View source: R/cv.cpernet.R

cv.cpernetR Documentation

Cross-validation for cpernet

Description

Does k-fold cross-validation for cpernet, produces a plot, and returns a value for lambda. This function is based on the cv function from the glmnet package.

Usage

cv.cpernet(
  x,
  y,
  w = 1,
  lambda = NULL,
  pred.loss = "loss",
  nfolds = 5,
  foldid,
  tau = 0.8,
  ...
)

Arguments

x

x matrix as in cpernet.

y

response variable y as in cpernet.

w

weight applied to the asymmetric squared error loss of the mean part. Default is 1.0.

lambda

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

pred.loss

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

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.

tau

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

...

other arguments that can be passed to cpernet.

Details

The function runs cpernet nfolds+1 times. The first gets the lambda sequence, and the remainder fits the model with each of the folds removed. The average error and standard deviation over the folds are computed.

Value

an object of class cv.cpernet 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

a list of two components, each representing the number of non-zero coefficients at each lambda in the mean and scale part.

name

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

cpernet.fit

a fitted cpernet 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 <yuwen.gu@uconn.edu>

See Also

cpernet

Examples


set.seed(1)
n <- 100
p <- 400
x <- matrix(rnorm(n * p), n, p)
y <- rnorm(n)
tau <- 0.30
pf <- abs(rnorm(p))
pf2 <- abs(rnorm(p))
w <- 2.0
lambda2 <- 1
m2.cv <- cv.cpernet(y = y, x = x, w = w, tau = tau, eps = 1e-8,
                    pf.mean = pf, pf.scale = pf2,
                    standardize = FALSE, lambda2 = lambda2)


SALES documentation built on Aug. 16, 2022, 1:05 a.m.

Related to cv.cpernet in SALES...