cv.hdsvm | R Documentation |
Performs k-fold cross-validation for hdsvm
.
cv.hdsvm(x, y, lambda = NULL, nfolds = 5L, foldid, ...)
x |
A numerical matrix with |
y |
Response variable. |
lambda |
Optional; a user-supplied sequence of |
nfolds |
Number of folds for cross-validation. Defaults to 5. |
foldid |
Optional vector specifying the indices of observations in each fold.
If provided, it overrides |
... |
Additional arguments passed to |
This function computes the average cross-validation error and provides the standard error.
An object with S3 class cv.hdsvm
consisting of
lambda |
Candidate |
cvm |
Mean cross-validation error. |
cvsd |
Standard error of the mean cross-validation error. |
cvup |
Upper confidence curve: |
cvlo |
Lower confidence curve: |
lambda.min |
|
lambda.1se |
Largest |
cv.min |
Cross-validation error at |
cv.1se |
Cross-validation error at |
hdsvm.fit |
a fitted |
nzero |
Number of non-zero coefficients at each |
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 <- cv.hdsvm(x, y, lam2=lam2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.