Several regress() without looping.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
John D'Errico
am 23 Mär. 2016
Bearbeitet: John D'Errico
am 23 Mär. 2016
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 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!