constrlasso_path: The function constrlasso_path

View source: R/constrlasso.R

constrlasso_pathR Documentation

The function constrlasso_path

Description

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.

Usage

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
)

Arguments

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.

Value

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

Details

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.

References

\insertAllCited

Examples

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)


antshi/constrLasso documentation built on April 12, 2025, 9:39 a.m.