What is a reasonable lower time limit for regstats?

2 次查看(过去 30 天)
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!

回答(1 个)

Richard Willey
Richard Willey 2012-5-8
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
  1. The backslash command
  2. regress
  3. regstats
  4. LinearModel
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.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by