Learn R Programming

mpath (version 0.4-2.26)

cv.irsvm: Cross-validation for irsvm

Description

Does k-fold cross-validation for irsvm

Usage

# S3 method for formula
cv.irsvm(formula, data, weights, contrasts=NULL, ...)
# S3 method for matrix
cv.irsvm(x, y, weights, ...)
# S3 method for default
cv.irsvm(x,  ...)

Value

An object contains a list of ingredients of cross-validation including optimal tuning parameters.

residmat

matrix with row values for kernel="linear" are s, cost, error, k, where k is the number of cross-validation fold. For nonlinear kernels, row values are s, gamma, cost, error, k.

cost

a value of cost that gives minimum cross-validated value in irsvm.

gamma

a value of gamma that gives minimum cross-validated value in irsvm

s

value of s for cfun that gives minimum cross-validated value in irsvm.

Arguments

formula

symbolic description of the model, see details.

data

argument controlling formula processing via model.frame.

x

x matrix as in irsvm.

y

response y as in irsvm.

weights

Observation weights; defaults to 1 per observation

contrasts

the contrasts corresponding to levels from the respective models.

...

Other arguments that can be passed to irsvm.

Author

Zhu Wang <zwang145@uthsc.edu>

Details

Does a K-fold cross-validation to determine optimal tuning parameters in SVM: cost and gamma if kernel is nonlinear. It can also choose s used in cfun.

References

Zhu Wang (2024) Unified Robust Estimation, Australian & New Zealand Journal of Statistics. 66(1):77-102.

See Also

irsvm

Examples

Run this code
if (FALSE) {
x <- matrix(rnorm(40*2), ncol=2)
y <- c(rep(-1, 20), rep(1, 20))
x[y==1,] <- x[y==1, ] + 1
irsvm.opt <- cv.irsvm(x, y, type="C-classification", s=1, kernel="linear", cfun="acave")
irsvm.opt$cost
irsvm.opt$gamma
irsvm.opt$s
}

Run the code above in your browser using DataLab