Learn R Programming

kerndwd (version 1.0.1)

cv.kerndwd: cross-validation for DWD

Description

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

Usage

cv.kerndwd(x, y, kern, lambda, qval=1, 
  pred.loss=c("misclass", "loss"), nfolds=5, foldid, ...)

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.
kern
A kernel function.
lambda
A user specified lambda candidate sequence for cross-validation.
qval
The index of the generalized DWD. Default value is 1.
pred.loss
If the value is "loss", the DWD loss is used as the cross-validation criterion; if the value is "misclass" or else, mis-classification rate is the criterion.
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 folder indices for each observation. If supplied, nfold can be missing.
...
Other arguments being passed to kerndwd.

Value

  • A cv.kerndwd object including the cross-validation results is return..
  • lambdaThe lambda sequence used in kerndwd.
  • cvmA vector of length length(lambda): mean cross-validated error.
  • cvsdA vector of length length(lambda): estimates of standard error of cvm.
  • cvupperThe upper curve: cvm + cvsd.
  • cvlowerThe lower curve: cvm - cvsd.
  • name``mis-classification error" or "DWD loss", depending on pred.loss, for plotting purposes.
  • lambda.minThe lambda incurring the minimum cross validation error cvm.
  • lambda.1seThe largest value of lambda such that error is within one standard error of the minimum.
  • cvm.minThe cross-validation error corresponding to lambda.min, i.e., the least error.
  • cvm.1seThe cross-validation error corresponding to lambda.1se.

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.

References

Wang, B. and Zou, H. (2015) ``Another Look at DWD: Thrifty Algorithm and Bayes Risk Consistency in RKHS". http://arxiv.org/abs/1508.05913v1.pdf 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 http://www.jstatsoft.org/v33/i01/paper

See Also

kerndwd and plot.cv.kerndwd

Examples

Run this code
set.seed(1)
data(Haberman)
Haberman$X = scale(Haberman$X, center=TRUE, scale=TRUE)
lambda = 10^(seq(-3, 3, length.out=10))
kern = rbfdot(sigma=1)
m.cv = cv.kerndwd(Haberman$X, Haberman$y, kern, qval=1, 
  lambda=lambda, eps=1e-5, maxit=1e5)
m.cv$lambda.min

Run the code above in your browser using DataLab