# Restricting Lasso-coefficients

6 visualizaciones (últimos 30 días)
Maximilian Voigt el 10 de Sept. de 2019
Comentada: John D'Errico el 16 de Sept. de 2019
Hello all,
I am currently working on a Finance-application of Lasso. However, for my purpose I would need to restrict the coefficients obtained from the lasso(X,y)-command to be larger or equal to zero.
How can I achieve this?
My initial trial is to copy and change the existing lasso-function. In the subfunction lassoFit(), I find the command:
B(:,i) = b;
Now, before this I would simply add:
b(b<0) = 0; % restrict b to be larger/ equal to 0
B(:,i) = b;
However, I am not really sure if this is correct and any help would be highly appreciated.
Many thanks.
Best
Max
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Pravin Jagtap el 16 de Sept. de 2019
Hello Miximilian,
To fit the data, it is important to understand how different models of regression work and what is the effect of regularization term on overall error minimization function. Please refer to following documentation for detail understanding of error minimization objectives:
In order to achieve non-negative coefficients, try exploring some other methods such as ridge regression, weighted least squares, etc. because ‘lasso’ algorithm uses the square loss function which has less tendency of hitting coefficients at zero than ridge regression (Understand the geometric meaning of ‘L1’ and ‘L2’ loss functions and optimization using it). Enforcing the constraints provided by you is similar to changing the overall objective function of ‘lasso’ regression mathematically.
Kind Regards
~Pravin
##### 1 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
John D'Errico el 16 de Sept. de 2019
I would add that it is rarely a good idea to modify existing toolbox code. Unless of course, you know enough to have written the code yourself. And even then, it is a dangerous thing to do. As you might introduce bugs into the code, or someone in the future will use your function, not knowing that it was hacked to do something that is not in the documentation.
So, if you know enough to write the code yourself, then the best thing is to write it yourself anyway. Write a simple version, that does exactly what you need.

Iniciar sesión para comentar.

### Categorías

Más información sobre Support Vector Machine Regression en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by