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 l0ara.

y

Response variable as in l0ara.

family

Response type as in l0ara.

lam

A user supplied lambda sequence in descending or asecending order. This function does not fit models. To fit a model with given lam value, use l0ara.

measure

Loss function used for corss validation. measurer="mse" or "mae" for all models. "measure"="class" or "measure"="auc" only for logsitic regression.

nfolds

Number of folds. Default value is 10. Smallest value is 3.

maxit

Maximum number of passes over the data for lambda. Default value is 1e3.

eps

Convergence threshold. Default value is 1e-4.

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 cv.error

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")

[Package l0ara version 0.1.6 Index]