Description Usage Arguments Value Examples
Computes Kfold crossvalidated mean squared error to propose a lambda value for lasso, group lasso, scaled lasso or scaled group lasso.
1 2 3 
X 
predictor matrix. 
Y 
response vector. 
group 

weights 
weight vector with length equal to the number of groups. Default is

type 
type of penalty. Must be specified to be one of the following:

K 
integer. Number of folds 
minlbd 
numeric. Minimum value of the lambda sequence. 
maxlbd 
numeric. Maximum value of the lambda sequence. 
num.lbdseq 
integer. Length of the lambda sequence. 
parallel 
logical. If 
ncores 
integer. The number of cores to use for parallelization. 
plot.it 
logical. If true, plots the squared error curve. 
verbose 
logical. 
lbd.min 
a value of lambda which gives a minimum squared error. 
lbd.1se 
a largest lambda within 1 standard error from 
lbd.seq 
lambda sequence. 
cv 
mean squared error at each lambda value. 
cvsd 
the standard deviation of cv. 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15  set.seed(123)
n < 30
p < 50
group < rep(1:(p/10),each=10)
weights < rep(1, max(group))
X < matrix(rnorm(n*p),n)
truebeta < c(rep(1,5),rep(0,p5))
Y < X%*%truebeta + rnorm(n)
# To accelerate the computational time, we set K=2 and num.lbdseq=2.
# However, in practice, Allowing K=10 and num.lbdseq > 100 is recommended.
cv.lasso(X = X, Y = Y, group = group, weights = weights, K = 2,
type = "grlasso", num.lbdseq = 2, plot.it = FALSE)
cv.lasso(X = X, Y = Y, group = group, weights = weights, K = 2,
type = "sgrlasso", num.lbdseq = 2, plot.it = FALSE)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.