cv.hdsvm: Cross-validation for Selecting the Tuning Parameter in the...

View source: R/hdsvmcv.R

cv.hdsvmR Documentation

Cross-validation for Selecting the Tuning Parameter in the Penalized SVM

Description

Performs k-fold cross-validation for hdsvm.

Usage

cv.hdsvm(x, y, lambda = NULL, nfolds = 5L, foldid, ...)

Arguments

x

A numerical matrix with n rows (observations) and p columns (variables).

y

Response variable.

lambda

Optional; a user-supplied sequence of lambda values. If NULL, hdsvm selects its own sequence.

nfolds

Number of folds for cross-validation. Defaults to 5.

foldid

Optional vector specifying the indices of observations in each fold. If provided, it overrides nfolds.

...

Additional arguments passed to hdsvm.

Details

This function computes the average cross-validation error and provides the standard error.

Value

An object with S3 class cv.hdsvm consisting of

lambda

Candidate lambda values.

cvm

Mean cross-validation error.

cvsd

Standard error of the mean cross-validation error.

cvup

Upper confidence curve: cvm + cvsd.

cvlo

Lower confidence curve: cvm - cvsd.

lambda.min

lambda achieving the minimum cross-validation error.

lambda.1se

Largest lambda within one standard error of the minimum error.

cv.min

Cross-validation error at lambda.min.

cv.1se

Cross-validation error at lambda.1se.

hdsvm.fit

a fitted hdsvm object for the full data.

nzero

Number of non-zero coefficients at each lambda.

Examples

set.seed(315)
n <- 100
p <- 400
x1 <- matrix(rnorm(n / 2 * p, -0.25, 0.1), n / 2)
x2 <- matrix(rnorm(n / 2 * p, 0.25, 0.1), n / 2)
x <- rbind(x1, x2)
beta <- 0.1 * rnorm(p)
prob <- plogis(c(x %*% beta))
y <- 2 * rbinom(n, 1, prob) - 1
lam2 <- 0.01
fit <- cv.hdsvm(x, y, lam2=lam2)

hdsvm documentation built on April 12, 2025, 1:27 a.m.