View source: R/cv.hdsvm-methods.R
coef.cv.hdsvm | R Documentation |
Retrieves coefficients from a cross-validated 'hdsvm()' model, using the stored '"hdsvm.fit"' object and the optimal 'lambda' value determined during cross-validation.
## S3 method for class 'cv.hdsvm'
coef(object, s = c("lambda.1se", "lambda.min"), ...)
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. |
Returns the coefficients at the specified 'lambda' values.
cv.hdsvm
, predict.cv.hdsvm
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.