Learn R Programming

kerndwd (version 2.0.3)

tunedwd: fast tune procedure for DWD

Description

A fast implementaiton of cross-validation for kerndwd to find the optimal values of the tuning parameter lambda.

Usage

tunedwd(x, y, kern, lambda, qvals=1, eps=1e-5, maxit=1e+5, nfolds=5, foldid=NULL)

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 two levels.

kern

A kernel function.

lambda

A user specified lambda candidate sequence for cross-validation.

qvals

A vector containing the index of the generalized DWD. Default value is 1.

eps

The algorithm stops when (i.e. \(\sum_j(\beta_j^{new}-\beta_j^{old})^2\) is less than eps, where \(j=0,\ldots, p\). Default value is 1e-5.

maxit

The maximum of iterations allowed. Default is 1e5.

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.

Value

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

lam.tune

The optimal lambda value.

q.tune

The optimal q value.

Details

This function returns the best tuning parameters q and lambda by cross-validation. An efficient tune method is employed to accelerate the algorithm.

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.

Examples

Run this code
# NOT RUN {
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))
ret = tunedwd(BUPA$X, BUPA$y, kern, qvals=c(1,2,10), lambda=lambda, eps=1e-5, maxit=1e5)
ret
# }

Run the code above in your browser using DataLab