Fits a linear model to potentially high-dimensional data using the square-root Lasso, also known as the scaled Lasso. The Lasso path is computed using the glmnet package.
sqrt_lasso(x, y, lam0 = NULL, exclude = integer(0), output_all = FALSE, ...)Input matrix of dimension nobs by nvars; each row is an observation vector.
Response variable; shoud be a numeric vector.
Tuning parameter for the square-root / scaled Lasso. If left blank (recommended) this is chosen using the method of Sun & Zhang (2013) implemented in the scalreg package.
Indices of variables to be excluded from the model; default is none.
In addition to the vector of coefficients, if TRUE,
also outputs the intercept, an estimate of the noise standard deviation,
and the output of glmnet.
Additional arguments to be passed to glmnet.
Either an estimated vector of regression coefficients with nvars
components or, if output_all is true, a list with components
betathe vector of regression coefficents
a0an intercept term
sigma_hatan estimate of the noise standard deviation; this is calculated as square-root of the average residual sums of squares
glmnet_objthe fitted glmnet object, an S3 class ``glmnet"
lamda_indexthe index of the lambda vector in the glmnet object
corresponding to the square-root Lasso solution
First the Lasso path is computed using glmnet from
glmnet. Next the particular point on the path corresponding to the
square-root Lasso solution is found. As the path is only computed on a grid
of points, the square-root Lasso solution is approximate.
A. Belloni, V. Chernozhukov, and L. Wang. (2011) Square-root lasso: pivotal recovery of sparse signals via conic programming. Biometrika, 98(4):791-806.
T. Sun and C.-H. Zhang. (2012) Scaled sparse linear regression. Biometrika, 99(4):879-898.
T. Sun and C.-H. Zhang. (2013) Sparse matrix inversion with scaled lasso. The Journal of Machine Learning Research, 14(1):3385-3418.
# NOT RUN {
x <- matrix(rnorm(100*250), 100, 250)
y <- x[, 1] + x[, 2] + rnorm(100)
out <- sqrt_lasso(x, y)
# }
Run the code above in your browser using DataLab