cv.l0ara {l0ara} | R Documentation |
cross-validation for l0ara
Description
Does k-fold cross-validation for l0ara, produces a plot, and returns the optimal lambda
Usage
cv.l0ara(x, y, family, lam, measure, nfolds, maxit, eps, seed)
Arguments
x |
Input matrix as in |
y |
Response variable as in |
family |
Response type as in |
lam |
A user supplied |
measure |
Loss function used for corss validation. |
nfolds |
Number of folds. Default value is 10. Smallest value is 3. |
maxit |
Maximum number of passes over the data for |
eps |
Convergence threshold. Default value is |
seed |
Seed of random number generator. |
Details
This function calls l0ara
nfolds
times, each time leaving out 1/nfolds
of the data. The cross-validation error is based on etiher mean square error (mse
) or mean absolute error (mae
).
Value
An object with S3 class "cv.l0ara" containing:
cv.error |
The mean cross validated error for given lambda sequence |
cv.std |
The estimates of standard error of |
lam.min |
The lambda gives min cv.error |
lambda |
The lambda used |
measure |
Type of measure |
family |
Model used |
x |
Design matrix |
y |
Response variable |
name |
Full name of the measure |
Author(s)
Wenchuan Guo <wguo007@ucr.edu>, Shujie Ma <shujie.ma@ucr.edu>, Zhenqiu Liu <Zhenqiu.Liu@cshs.org>
See Also
l0ara
, coef.cv.l0ara
, plot.cv.l0ara
methods.
Examples
#' # Linear regression
# Generate design matrix and response variable
n <- 100
p <- 40
x <- matrix(rnorm(n*p), n, p)
beta <- c(1,0,2,3,rep(0,p-4))
noise <- rnorm(n)
y <- x%*%beta+noise
lam <- c(0.1, 0.3, 0.5)
fit <- cv.l0ara(x, y, family="gaussian", lam, measure = "mse")