[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fast and accurate Linear Regression



PureBytes Links

Trading Reference Links

Perhaps the first worry to be addressed might be,
"is Tradestation using less precision to do these
calculations than my computer's hardware provides,
and is this part of my problem?"  I would suggest
implementing the same algorithm in a compiled
language that gives you access to full 64-bit
floats (such as C, C++, et al) and running that
code side-by-side with your Tradestation code, on
the identical same data.  Comparing the results
will give an unambiguous yes-or-no answer to this
worry.  Why rely on the opinions and vague memories
(which may be inaccurate) of strangers, when you
can easily perform a decisive experiment yourself?

Next, I would consider rewriting the algorithm
as two passes.  The current one-pass design is
the traditional implementation (as found in Excel
and many other programs), and it trades speed
for accuracy.  In a two pass design you could
calculate mean-X and mean-Y in a first loop,
then in a second loop you can compute deltas-
from-mean and use those to compute the slope,
intercept, goodness of fit, and so forth.

You'll need to find a textbook that discusses the
IDEA of linear regression, rather than just the
one-pass calculation formulae as for example
Excel's Help LINEST barfs out.  Something like
Statistics Unplugged by Caldwell, for example.