Skip to contents

Carry out a cross-validation for lhsc to find optimal values of the tuning parameter lambda.

Usage

cv.lhsc(x, y, kern, lambda, nfolds=5, foldid, ...)

Arguments

x

A matrix of predictors, i.e., the matrix x used in lhsc.

y

A vector of binary class labels, i.e., the y used in lhsc. y has to be two levels.

kern

A kernel function.

lambda

A user specified lambda candidate sequence for cross-validation.

nfolds

The number of folds. Default value is 5. The allowable range is from 3 to the sample size.

foldid

An optional vector with values between 1 and nfold, representing the fold indices for each observation. If supplied, nfold can be missing.

...

Other arguments being passed to lhsc.

Details

This function computes the mean cross-validation error and the standard error by fitting lhsc with every fold excluded alternatively.

Value

A cv.lhsc object including the cross-validation results is return.

lambda

The lambda sequence used in lhsc.

cvm

A vector of length length(lambda): mean cross-validated error.

cvsd

A vector of length length(lambda): estimates of standard error of cvm.

cvupper

The upper curve: cvm + cvsd.

cvlower

The lower curve: cvm - cvsd.

lambda.min

The lambda incurring the minimum cross validation error cvm.

lambda.1se

The largest value of lambda such that error is within one standard error of the minimum.

cvm.min

The cross-validation error corresponding to lambda.min, i.e., the least error.

cvm.1se

The cross-validation error corresponding to lambda.1se.

Author

Oh-Ran Kwon and Hui Zou
Maintainer: Oh-ran Kwon kwon0085@umn.edu

References

Kwon, O. and Zou, H. (2023+) “Leaky Hockey Stick Loss: The First Negatively Divergent Margin-based Loss Function for Classification"

See also

Examples

set.seed(1)
data(BUPA)
BUPA$X = scale(BUPA$X, center=TRUE, scale=TRUE)
lambda = 10^(seq(3, -3, length.out=10))
kern = rbfdot(sigma=sigest(BUPA$X))
m.cv = cv.lhsc(BUPA$X, BUPA$y, kern, lambda=lambda, eps=1e-5, maxit=1e5)
m.cv$lambda.min
#> [1] 0.001