lasso sparse regression on Y matrix

2 views (last 30 days)
Linda
Linda on 20 Dec 2012
Hello,
I have a data matrix Y (N x M) on which I want to fit a GLM specified by the design matrix X (N x P). An easy way of estimating the beta matrix would be employing an OLS estimator:
B = (inv(X'*X)\X')*Y;
However, in the scenario I face, a sparse regression approach might be a more sensible choice. My first pick would be an L1 regularization approach (lasso regression), but for the life of me I cannot find a useful matlab implementation. That is because /all/ MatLab implementations of lasso I have come across so far (built-in and custom-written ones) do require Y to be a vector of observations, but cant handle matrices as input. Consequently, this only gets me a B vector (P X 1) as output, whereas B is supposed to be a P x M matrix.
Any suggestions on how to fix this are highly appreciated.
Regards

Answers (1)

Matt J
Matt J on 20 Dec 2012
Edited: Matt J on 20 Dec 2012
Can't you just use a loop over the columns of Y, fitting one column at a time?
Or, you could reformulate as a block diagonal system
XX=kron(speye(M), X);
YY=Y(:);
and solve the equivalent single-vector system
XX*beta=YY;
I expect the loop would be better/faster, because it reduces the problem to simpler, lower-dimensional problems.

Community Treasure Hunt

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

Start Hunting!