nc.hdsvm: Solve the Penalized SVM with Nonconvex Penalties

View source: R/nc.hdsvm.R

nc.hdsvmR Documentation

Solve the Penalized SVM with Nonconvex Penalties

Description

This function fits the penalized SVM using nonconvex penalties such as SCAD or MCP. It allows for flexible control over the regularization parameters and offers advanced options for initializing and optimizing the fit.

Usage

nc.hdsvm(
  x,
  y,
  lambda,
  pen = "scad",
  aval = NULL,
  lam2 = 1,
  ini_beta = NULL,
  lla_step = 3,
  ...
)

Arguments

x

Matrix of predictors, with dimensions (nobs * nvars); each row represents an observation.

y

Response variable, with length n.

lambda

Optional user-supplied sequence of lambda values. If unspecified, the program calculates its own sequence based on nlambda and lambda.factor. Supplying a decreasing sequence of lambda values is advisable to leverage the warm-start optimization.

pen

Specifies the type of nonconvex penalty: "SCAD" or "MCP".

aval

The parameter value for the SCAD or MCP penalty. Default is 3.7 for SCAD and 2 for MCP.

lam2

Regularization parameter lambda2 for the quadratic penalty on the coefficients. Only one value of lambda2 is used per fit.

ini_beta

Optional initial coefficients to start the fitting process.

lla_step

Number of Local Linear Approximation (LLA) steps. Default is 3.

...

Additional arguments passed to hdsvm.

Value

An object with S3 class nc.hdsvm consisting of

call

the call that produced this object

b0

intercept sequence of length length(lambda)

beta

a p*length(lambda) matrix of coefficients, stored as a sparse matrix (dgCMatrix class, the standard class for sparse numeric matrices in the Matrix package.). To convert it into normal type matrix, use as.matrix().

lambda

the actual sequence of lambda values used

df

the number of nonzero coefficients for each value of lambda.

npasses

the number of iterations for every lambda value

jerr

error flag, for warnings and errors, 0 if no error.

#'

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)) 
nc.fit <- nc.hdsvm(x = x, y = y, lambda = lambda, lam2 = lam2, pen = "scad")

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