hdsvm | R Documentation |
Fits a penalized support vector machine (SVM) model using a range of lambda
values,
allowing for detailed control over regularization parameters and model complexity.
hdsvm(
x,
y,
nlambda = 100,
lambda.factor = ifelse(nobs < nvars, 0.01, 1e-04),
lambda = NULL,
lam2 = 0,
hval = 1,
pf = rep(1, nvars),
pf2 = rep(1, nvars),
exclude,
dfmax = nvars + 1,
pmax = min(dfmax * 1.2, nvars),
standardize = TRUE,
eps = 1e-08,
maxit = 1e+06,
sigma = 0.9,
is_exact = FALSE
)
x |
Matrix of predictors, with dimensions ( |
y |
Response variable vector of length |
nlambda |
Number of |
lambda.factor |
The factor for getting the minimal value
in the |
lambda |
A user-supplied |
lam2 |
Regularization parameter |
hval |
Smoothing parameter for the smoothed hinge loss, default is 1. |
pf |
L1 penalty factor of length |
pf2 |
L2 penalty factor of length |
exclude |
Indices of variables to be excluded from the model. Default is none. Equivalent to an infinite penalty factor. |
dfmax |
The maximum number of variables allowed in the model.
Useful for very large |
pmax |
Maximum count of non-zero coefficients across the solution path. |
standardize |
Logical flag for variable standardization,
prior to fitting the model sequence. The coefficients are
always returned to the original scale. Default is |
eps |
Convergence criterion for stopping the algorithm. |
maxit |
Maximum number of iterations permitted. |
sigma |
Penalty parameter in the quadratic term of the augmented Lagrangian. |
is_exact |
If |
The function utilizes the hinge loss function combined with elastic net penalization:
1'[\max\{1 - y_i (\beta_0 + X_i^\top \beta), 0\}]/N + \lambda_1 \cdot |pf_1 \circ \beta|_1 +
0.5 \cdot \lambda_2 \cdot (\sqrt{pf_2} \circ \beta)^2,
where \circ
denotes the Hadamard product.
For faster computation, if the algorithm is not converging or
running slow, consider increasing eps
, increasing
sigma
, decreasing nlambda
, or increasing
lambda.factor
before increasing maxit
.
An object with S3 class hdsvm
consisting of
call |
the call that produced this object |
b0 |
intercept sequence of length |
beta |
a |
lambda |
the actual sequence of |
df |
the number of nonzero coefficients for each value
of |
npasses |
the number of iterations for every lambda value |
jerr |
error flag, for warnings and errors, 0 if no error. |
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 <- hdsvm(x, y, lam2=lam2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.