| cv.l0ara | R Documentation |
Perform k-fold cross-validation over a supplied sequence of penalty values and return the value selected by the chosen measure.
cv.l0ara(x, y, family, lam, measure, nfolds, maxit, eps, seed)
x |
Input matrix as in |
y |
Response variable as in |
family |
Model family as in |
lam |
A user-supplied sequence of candidate penalty values. At least two values are required. |
measure |
Criterion used to compare folds. Use |
nfolds |
Number of folds. Default value is 10. Smallest value is 3. |
maxit |
Maximum number of iterations passed to each call to
|
eps |
Convergence threshold. Default value is |
seed |
Optional random seed used to generate the fold assignments. |
For each fold, the function fits one model per value in
lam, evaluates the requested measure on the held-out data, and then
averages the results across folds. For measure = "auc", the selected
value is the one with the largest score; for all other measures it is the
one with the smallest score.
An object with S3 class "cv.l0ara" containing:
cv.error |
Mean cross-validation score for each value in
|
cv.std |
Estimated standard error of |
lam.min |
The selected penalty value. |
lambda |
The supplied sequence of penalty values. |
measure |
The measure used for model selection. |
family |
The fitted model family. |
x |
The original design matrix. |
y |
The original response vector. |
name |
A printable label for |
fit.min |
A |
Wenchuan Guo <wguo1017@gmail.com>, Shujie Ma <shujie.ma@ucr.edu>, Zhenqiu Liu <Zhenqiu.Liu@cshs.org>
l0ara, coef.cv.l0ara,
plot.cv.l0ara.
# Linear regression
# Generate design matrix and response variable
n <- 100
p <- 40
x <- matrix(rnorm(n*p), n, p)
beta <- c(1,0,2,3,rep(0,p-4))
noise <- rnorm(n)
y <- x%*%beta+noise
lam <- c(0.1, 0.3, 0.5)
fit <- cv.l0ara(x, y, family="gaussian", lam, measure = "mse")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.