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

View source: R/cv.nc.hdsvm.R

cv.nc.hdsvmR Documentation

Cross-validation for Selecting the Tuning Parameter of Nonconvex Penalized SVM

Description

Conducts k-fold cross-validation for the 'nc.hdsvm()' function.

Usage

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

Arguments

x

A numerical matrix with dimensions (n rows and p columns), where each row represents an observation.

y

Response variable.

lambda

Optional user-supplied sequence of lambda values.

nfolds

Number of folds in the cross-validation, default is 5.

foldid

An optional vector that assigns each observation to a specific fold. If provided, this parameter overrides nfolds.

...

Additional arguments passed to nc.hdsvm.

Details

This function estimates the average cross-validation error and its standard error across folds. It is primarily used to identify the optimal lambda value for fitting nonconvex penalized SVM models.

Value

An object of class cv.nc.hdsvm is returned, which is a list with the ingredients of the cross-validated fit.

lambda

the values of lambda used in the fits.

cvm

the mean cross-validated error - a vector of length length(lambda).

cvsd

estimate of standard error of cvm.

cvupper

upper curve = cvm+cvsd.

cvlower

lower curve = cvm-cvsd.

nzero

number of non-zero coefficients at each lambda.

name

a text string indicating type of measure (for plotting purposes).

nchdsvm.fit

a fitted nc.hdsvm object for the full data.

lambda.min

The optimal value of lambda that gives minimum cross validation error cvm.

lambda.1se

The largest value of lambda such that error is within 1 standard error of the minimum.

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
lambda <- 10^(seq(1,-4, length.out=30))
cv.nc.fit <- cv.nc.hdsvm(x=x, y=y, lambda=lambda, lam2=lam2, pen="scad")

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