I need a [url removed, login to view] function (and test container, or at least instructions), that will take scatter plot data (a list of X values and Y values), and determine the best polynomial fit. Then I need it to return the coefficients of the polynomial as well as the R2 value.
There may be code on the web somewhere to do just this (seems common) but I haven't been able to find anything.
Just to reiterate, I have two input arrays: X() and Y(), and need a function to return the best polynomial fit (say up to degree 9).
All questions welcome! I'll be happy to give a bonus for speed. However, the code must work as well :)