lasso sparse regression on Y matrix
Afficher commentaires plus anciens
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
1 commentaire
Matt J
le 20 Déc 2012
I assume you mean
B = inv(X'*X)*X'*Y;
Réponses (1)
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.
Catégories
En savoir plus sur Linear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!