cv.cpernet {SALES} | R 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 |
|
y |
response variable |
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 |
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 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 |
cvm |
the mean cross-validated error - a vector of length
|
cvsd |
estimate of standard error of |
cvupper |
upper curve = |
cvlower |
lower curve = |
nzero |
a list of two components, each representing the number of
non-zero coefficients at each |
name |
a text string indicating type of measure (for plotting purposes). |
cpernet.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.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)