Several regress() without looping.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
John D'Errico
il 23 Mar 2016
Modificato: John D'Errico
il 23 Mar 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 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!