# Goodness of Fit (G Dataflow)

Calculates three statistical parameters that describe how well a fitted model matches the original data set.  ## y

Array of dependent values of the original data set. The number of elements in y must be greater than degree of freedom. ## best fit

Array of dependent values of the fitted model. best fit must be the same size as y. ## weight

Weights for the observations.

weight must be the same size as y. If you do not wire an input to weight, this node sets all elements of weight to 1. If an element in weight is less than 0, this node uses the absolute value of the element. ## degree of freedom

Length of the array of dependent values of the original data set minus the number of coefficients in the fitted model. If degree of freedom is less than or equal to 0, this node sets degree of freedom to the length of y minus 2.

Default: -1 ## error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error  If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error ## SSE

Summation of square error. The smaller the SSE, the better the fit. ## R-square

A normalized parameter to measure the goodness of fit. The closer to 1 the R-square, the better the fit. ## RMSE

Root mean square error. The smaller the RMSE, the better the fit. ## error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error  If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

## Algorithm for Calculating the Statistical Parameters

The statistical parameters SSE, R-square, and RMSE are defined by the following equations:

$\mathrm{SSE}=\underset{i=0}{\overset{n-1}{\sum }}{w}_{i}{\left({y}_{i}-{f}_{i}\right)}^{2}$
$R-\mathrm{square}=1-\frac{SSE}{SST}$
$RMSE=\sqrt{\frac{SSE}{DOF}}$

where

• wi is the ith element of weight
• yi is the ith element of y
• fi is the ith element of best fit
• $SST=\underset{i=0}{\overset{n-1}{\sum }}{w}_{i}{\left({y}_{i}-\stackrel{¯}{y}\right)}^{2}$
• $\stackrel{¯}{y}$ is the mean value of y
• DOF is the degree of freedom

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Not supported in VIs that run in a web application