coef.cv.hdsvm: Extract Coefficients from a 'cv.hdsvm' Object

View source: R/cv.hdsvm-methods.R

coef.cv.hdsvmR Documentation

Extract Coefficients from a 'cv.hdsvm' Object

Description

Retrieves coefficients from a cross-validated 'hdsvm()' model, using the stored '"hdsvm.fit"' object and the optimal 'lambda' value determined during cross-validation.

Usage

## S3 method for class 'cv.hdsvm'
coef(object, s = c("lambda.1se", "lambda.min"), ...)

Arguments

object

A fitted 'cv.hdsvm()' object from which coefficients are to be extracted.

s

Specifies the value(s) of the penalty parameter 'lambda' for which coefficients are desired. The default is 's = "lambda.1se"', which corresponds to the largest value of 'lambda' such that the cross-validation error estimate is within one standard error of the minimum. Alternatively, 's = "lambda.min"' can be used, corresponding to the minimum of the cross-validation error estimate. If 's' is numeric, these are taken as the actual values of 'lambda' to use.

...

Not used.

Value

Returns the coefficients at the specified 'lambda' values.

See Also

cv.hdsvm, predict.cv.hdsvm

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
cv.fit <- cv.hdsvm(x, y, lam2 = 0.01)
coef(cv.fit, s = c(0.02, 0.03))

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