- The backslash command
What is a reasonable lower time limit for regstats?
3 vues (au cours des 30 derniers jours)
Currently I'm working on a stats project, and it involves a lot of regressions. Since there are so many, it will take about an hour or two to run the first time. I'm using the regstats function with about 50 observations in each regression, and each function is taking about 0.002 seconds to be called.
I'm curious, is there any way to improve on this time-wise? I'm running enough separate regressions to make this take more time than I want, but I'm not really sure if this a part of the code I can optimize much further. Everything has already been preallocated, too.
Thanks for any suggestions!
Richard Willey le 8 Mai 2012
MATLAB and Statistics Toolbox provide a variety of ways to perform a regression. For example, if I am performing a simple linear regression I could use
Each of these functions requires a different amount of time to run. The primary difference in execution speed is the amount of information that each function provides.
For example, backslash runs wicked fast, but the only output is a set of regression coefficients.
At the other end of the spectrum, regstats provides all sorts of useful information as standard output. Consequently, it requires a lot more time to run.
I'd recommend determining what is the minimum set of information you need from the regressions and then determine which algorithm you should use.
If you just need regression coefficients and R^2 your best option is to use backslash and hand code a routine to calculate R^2.
Regress is the next fastest with regstats and LinearModel bringing up the rear.