cv.l0ara: Cross-validation for l0ara

View source: R/cv.l0ara.R

cv.l0araR Documentation

Cross-validation for l0ara

Description

Perform k-fold cross-validation over a supplied sequence of penalty values and return the value selected by the chosen measure.

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

Model family as in l0ara.

lam

A user-supplied sequence of candidate penalty values. At least two values are required.

measure

Criterion used to compare folds. Use "mse" or "mae" for any supported family. Use "class" or "auc" only with family = "logit".

nfolds

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

maxit

Maximum number of iterations passed to each call to l0ara().

eps

Convergence threshold. Default value is 1e-4.

seed

Optional random seed used to generate the fold assignments.

Details

For each fold, the function fits one model per value in lam, evaluates the requested measure on the held-out data, and then averages the results across folds. For measure = "auc", the selected value is the one with the largest score; for all other measures it is the one with the smallest score.

Value

An object with S3 class "cv.l0ara" containing:

cv.error

Mean cross-validation score for each value in lambda.

cv.std

Estimated standard error of cv.error.

lam.min

The selected penalty value.

lambda

The supplied sequence of penalty values.

measure

The measure used for model selection.

family

The fitted model family.

x

The original design matrix.

y

The original response vector.

name

A printable label for measure.

fit.min

A "l0ara" object refit on the full data using lam.min.

Author(s)

Wenchuan Guo <wguo1017@gmail.com>, Shujie Ma <shujie.ma@ucr.edu>, Zhenqiu Liu <Zhenqiu.Liu@cshs.org>

See Also

l0ara, coef.cv.l0ara, plot.cv.l0ara.

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

l0ara documentation built on April 27, 2026, 9:08 a.m.