cv.kerndwd {kerndwd}R Documentation

cross-validation

Description

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

Usage

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

Arguments

x

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

y

A vector of binary class labels, i.e., the y used in kerndwd. 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.

wt

A vector of length n for weight factors. When wt is missing or wt=NULL, an unweighted DWD is fitted.

...

Other arguments being passed to kerndwd.

Details

This function computes the mean cross-validation error and the standard error by fitting kerndwd with every fold excluded alternatively. This function is modified based on the cv function from the glmnet package.

Value

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

lambda

The lambda sequence used in kerndwd.

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(s)

Boxiang Wang and Hui Zou
Maintainer: Boxiang Wang boxiang-wang@uiowa.edu

References

Wang, B. and Zou, H. (2018) “Another Look at Distance Weighted Discrimination," Journal of Royal Statistical Society, Series B, 80(1), 177–198.
https://rss.onlinelibrary.wiley.com/doi/10.1111/rssb.12244
Friedman, J., Hastie, T., and Tibshirani, R. (2010), "Regularization paths for generalized linear models via coordinate descent," Journal of Statistical Software, 33(1), 1–22.
https://www.jstatsoft.org/v33/i01/paper

See Also

kerndwd and plot.cv.kerndwd

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.kerndwd(BUPA$X, BUPA$y, kern, qval=1, lambda=lambda, eps=1e-5, maxit=1e5)
m.cv$lambda.min

[Package kerndwd version 2.0.3 Index]