lasso sparse regression on Y matrix
이전 댓글 표시
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
Matt J
2012년 12월 20일
I assume you mean
B = inv(X'*X)*X'*Y;
답변 (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.
카테고리
도움말 센터 및 File Exchange에서 Linear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!