Learn R Programming

EAlasso (version 0.1.0)

Lasso.MHLS: Compute lasso estimator

Description

Computes lasso, group lasso, scaled lasso, or scaled group lasso solution. The outputs are coefficient-estimate and subgradient. If type = "slasso" or type = "sgrlasso", the output will include the sigma-estimate.

Usage

Lasso.MHLS(X, Y, type, lbd, group = 1:ncol(X), weights = rep(1, max(group)),
  verbose = FALSE, ...)

Arguments

X

predictor matrix.

Y

response vector.

type

type of penalty. Must be specified to be one of the following: "lasso", "grlasso", "slasso" or "sgrlasso".

lbd

penalty term of lasso. By letting this argument be "cv.1se" or "cv.min", users can have the cross-validated lambda that gives either minimum squared error or that is within 1 std error bound.

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.

weights

weight vector with length equal to the number of groups. Default is rep(1, max(group)).

verbose

logical. Only available for type = "slasso" or type = "sgrlasso".

...

auxiliary arguments for lbd = "cv.min", lbd = "cv.1se". See cv.lasso for details.

Value

B0

coefficient estimator.

S0

subgradient.

lbd, weights, group

same as input arguments.

Details

Computes lasso, group lasso, scaled lasso, or scaled group lasso solution. Users can specify the value of lbd or choose to run cross-validation to get optimal lambda in term of mean squared error.

Examples

Run this code
# NOT RUN {
set.seed(123)
n <- 50
p <- 10
X <- matrix(rnorm(n*p), n)
Y <- X %*% c(1, 1, rep(0, p-2)) + rnorm(n)
#
# lasso
#
Lasso.MHLS(X = X, Y = Y, type = "lasso", lbd = .5)
#
# group lasso
#
Lasso.MHLS(X = X, Y = Y, type = "grlasso", lbd = .5, weights = rep(1,2),
group = rep(1:2, each=5))
# }

Run the code above in your browser using DataLab