cv.lasso: Compute K-fold cross-validated mean squared error for lasso In EAlasso: Simulation Based Inference of Lasso Estimator

Description

Computes K-fold cross-validated mean squared error to propose a lambda value for lasso, group lasso, scaled lasso or scaled group lasso.

Usage

 ```1 2 3``` ```cv.lasso(X, Y, group = 1:ncol(X), weights = rep(1, max(group)), type, K = 10L, minlbd, maxlbd, num.lbdseq = 100L, parallel = FALSE, ncores = 2L, plot.it = FALSE, verbose = FALSE) ```

Arguments

 `X` predictor matrix. `Y` response vector. `group` `p` x `1` vector of consecutive integers describing the group structure. The number of groups should be the same as max(group). Default is `group = 1:p` , where `p` is number of covariates. See examples for a guideline. `weights` weight vector with length equal to the number of groups. Default is `rep(1, max(group))`. `type` type of penalty. Must be specified to be one of the following: `"lasso", "grlasso", "slasso"` or `"sgrlasso"`. `K` integer. Number of folds `minlbd` numeric. Minumum value of the lambda sequence. `maxlbd` numeric. Maximum value of the lambda sequence. `num.lbdseq` integer. Length of the lambda sequence. `parallel` logical. If `parallel = TRUE`, uses parallelization. Default is `parallel = FALSE`. `ncores` integer. The number of cores to use for parallelization. `plot.it` logical. If true, plots the squared error curve. `verbose` logical.

Value

 `lbd.min` a value of lambda which gives a minimum squared error. `lbd.1se` a largest lambda within 1 standard error from `lbd.min`. `lbd.seq` lambda sequence. `cv` mean squared error at each lambda value. `cvsd` the standard deviation of cv.

Examples

 ``` 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,p-5)) 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) ```

EAlasso documentation built on Sept. 1, 2017, 9:03 a.m.