Several regress() without looping.
4 ビュー (過去 30 日間)
古いコメントを表示
Basically, im doing regress(X,Y) on several different X, while Y remain unchanged. So far, im looping on each X but I have thousands so it's taking forever. Any ideas on how to avoid the loop? Thanks!
0 件のコメント
回答 (1 件)
John D'Errico
2016 年 3 月 23 日
編集済み: John D'Errico
2016 年 3 月 23 日
While it is possible to do so for a fixed X, with changing Y where you would see a speed gain, the opposite is not possible.
Yes, there are some tricks where you can create sparse block diagonal matrices, but you would not gain too much over a simple loop, and you would no longer have access to the many pieces of information that regress returns beyond the basic regression coefficients. That you could get as easily from a loop around use of the backslash operator applied to your sequence of problems.
The point is, much of the time required for regress lies in the computation of those extra stars, R^2, p values for the parameters, etc. Skip them, and all you need to do is use backslash. It will be faster, but then you don't get that information.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!