I am trying to use LASSO for model selection, but I need my fitted values to remain non-negative. Is there a way to implement this simply in R? I've found that the penalized package allows for non negative coefficients, but not so for non negative fits.

  • 2
    $\begingroup$ You can fit a model that can't fit negative values easily enough - GLMs and nonlinear least squares each give ways to do that, but if that's the case, you almost certainly have heterskedasticity and nonlinear relationships between y and x (or else the non-negativity generally won't hold). Depending on what your response consists of (and what you understand about it), one or the other choice may be better; usually I lean toward glms first, as making it easier to model heteroskedasticity and non-negativity. I think there may be some lasso-for-GLMs in R. $\endgroup$
    – Glen_b
    Commented Oct 24, 2014 at 4:23
  • $\begingroup$ See here for an example where a gamma glm gave a positive fit for all data values (though, being linear, it was necessarily not positive everywhere outside the data). Note that it doesn't assume constant variance. $\endgroup$
    – Glen_b
    Commented Oct 24, 2014 at 4:32
  • $\begingroup$ Mathematically, it is possible and very easy because adding linear constraints to a convex optimization problem preserves convexity. We don t really have flexible, free, QP solver in R. But we have good, free, LP solvers: if LAD-LASSO can solve your problem, then add this info to your question because it is easy to do modify LAD-LASSO in R to make it do what you want. $\endgroup$
    – user603
    Commented Oct 24, 2014 at 10:19

1 Answer 1


No, that would make it another optimization problem, which the algorithm does not seem to provide. Remember the Lasso requires a numerical algorithm for computing the solution and the Ridge has a closed form. That package provides you with a numerical method to compute both types of penalties which is great, but you are asking it to solve a different type of optimization problem which is not supported.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.