FitR2

(Engine-Level Function)

Description: Returns the coefficient of determination (i.e. r2) for a linear curve fit. This number gives a measure of how accurate the curve fit is.
Returns: Numeric
Usage: Script or steady state.
Function Groups: Generic Math
Related to: FitOffset | FitSlope
Format: FitR2(XarrayElem, YarrayElem, N)
Parameters:  
XArrayElem
Required. Any array element giving the starting point in the array of X coordinates of the input data set. The subscript for the array may be any numeric expression.

If processing a multidimensional array, the usual rules apply to decide which dimension should be used.
YArrayElem
Required. Any array element giving the starting point in the array of Y coordinates of the input data set. The subscript for the array may be any numeric expression.

If processing a multidimensional, the usual rules apply to decide which dimension should be used.
N
Required. Any numeric expression giving the number of data points to use from the arrays given by the first two parameters.
If N extends past the upper bound of the lowest array dimension, this computation will "wrap-around" and resume at element 0, until N elements have been processed.
Comments: This function returns a number indicating how close a fit the data are to a line. If an element of either array is invalid, then that X-Y pair is not included in the computation. If the result is 0, there is no linear relationship at all between the array of X values and the array of Y values. If the result is 1, the fit is perfect. The result may be any value in the range of 0 to 1.
This function can be used in conjunction with the other linear regression functions.

Example:

Assume that 2 arrays exist such that X = {0, 1, 2, 3} and Y = {1, 3, 5, 7 }, and both arrays' subscripts start at 0

  Determination = FitR2(X[0] { Starting X element },
                        Y[0] { Starting Y element }, 
                        4 { Number of elements to process }); 

The value of determination will be set to 1 (a perfect fit).