constrlasso_path | R Documentation |
This function performs a Constrained Lasso Solution Path
as in \insertCitegaines2018algorithms;textualconstrlasso.
It computes the solution path for the constrained lasso problem, using a predictor matrix X and a response y.
The constrained lasso solves the standard lasso \insertCitetibshirani1996regression;textualconstrlasso
subject to the linear equality constraints Aeq \beta = beq
and linear inequality constraints A \beta \le b
.
The result lambda_path contains the values of the tuning parameter along the solution path and beta_path -
the estimated regression coefficients for each value of lambda_path.
The function corresponds to lsq_classopath of the SparseReg MATLAB-toolbox of by Zhou and Gaines,
see the project page.
For more information, see \insertCitegaines2018algorithms;textualconstrlasso.
constrlasso_path(
X,
y,
Aeq = NULL,
beq = NULL,
A = NULL,
b = NULL,
penidx = NULL,
init_method = "QP",
epsilon = 1e-04,
stop_lambda_tol = 1e-07,
ceiling_tol = 1e-10,
zeros_tol = 1e-20,
verbose = FALSE
)
X |
an nxp matrix with p regressors with n observations. |
y |
an nx1 response vector with n observations. |
Aeq |
a cxp equality constraint matrix, containing c constraints for p regressors. Default value is Aeq=NULL, no equality constraints. |
beq |
a cx1 equality constraint vector. Default value is beq=NULL, no equality constraints. |
A |
a cxp inequality constraint matrix, containing c constraints for p regressors. Default value is A=NULL, no inequality constraints. |
b |
a cx1 inequality constraint vector. Default value is b=NULL, no inequality constraints. |
penidx |
a logical px1 vector, indicating which coefficients are to be penalized. Default value is penidx=NULL and allows all p coefficients to be penalized. |
init_method |
a character string, the initializing method to be used. Possible values are "QP" (default) for Quadratic Programming and "LP" for Linear Programming. "LP" is recommended only when it's reasonable to assume that all coefficient estimates initialize at zero. |
epsilon |
a tuning parameter for ridge penalty in case of high-dimensional (n>p) regressors matrix X. Default value is 1e-4. |
stop_lambda_tol |
a tolerance value for the tuning lasso parameter. The algorithm stops when hitting this tolerance. Default value is 1e-7. |
ceiling_tol |
a tolerance value for the change in subgradients. Default value is 1e-10. |
zeros_tol |
a tolerance value for the zero equality of coefficients. Default value is 1e-20. |
verbose |
a logical parameter. TRUE prints along the constraint lasso solution path. Default value is FALSE. |
lambda_path a vector of the tuning parameter values along the solution path.
beta_path a matrix with estimated regression coefficients for each value of lambda_path
df_path a vector with degrees of freedom along the solution path
objval_path a vector with values of the objective function for each value of lambda_path
The Constrained Lasso as in \insertCitegaines2018algorithms;textualconstrlasso minimizes
0.5||y - X \beta ||^2_2 + \lambda||\beta||_1,
subject to Aeq \beta = beq
and A \beta\le b
.
set.seed(1234)
n <- 200 # number of observations
p <- 150 # number of regressors
real_p <- 50 # number of true predictors
Xmat <- matrix(rnorm(n * p), nrow = n, ncol = p)
yvec <- apply(Xmat[, 1:real_p], 1, sum) + rnorm(n)
results_path <- constrlasso_path(Xmat, yvec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.