FitR2

Description:              This function 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

Format:                      FitR2(XarrayElem, YarrayElem, N)

Parameters:             XArrayElem    { array element }  { required }  { no default: }

                                      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. Unless specified, the lowest dimension of a multidimensional array is used.

                                    YArrayElem    { array element }  { required }  { no default: }

                                      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. Unless specified, the lowest dimension of a multidimensional array is used.

                                    N    { numeric }  { required }  { no default: }

                                      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).

See Also:

FitOffset | FitSlope | Math Functions