Non negative lasso implementation in R

I am looking for some open source or an existing library I can use. As far as I tell the glmnet package isn’t very easily extensible to cover the non negative case. I may be wrong, Any one with any ideas much appreciated.

By non-negative I mean that all coefficients are constrained to be positive (> 0).


In glmnet there is the option


that you can use and that would be the appropriate way to enforce positivity constraints on the fitted coefficients and if you set parameter alpha to 1 you will be fitting LASSO. In combination with the argument upper.limits you can also specify box constraints. The glmnet package is also much faster than the penalized package, suggested in another answer here.

An Rcpp version of glmnet that can fit the lasso & elastic net with support for positivity and box constraints is also in preparation, and is available for testing at

Source : Link , Question Author : gbh. , Answer Author : Tom Wenseleers

Leave a Comment