polyfit - Computes best-fit polynomial between two variables

SYNOPSIS

polyfit  [ parameter=value ... ]  [ inputfile    outputfile ]
polyfit  [ parameter=value ... ]  [ inputfile ... directory ]

Parameters are: x_var, y_vars, order, points, printout

DESCRIPTION

The function polyfit computes the best-fit polynomial between pairs of x-y variables, e.g. y = a0 + a1 * x ... an * x^n, where n is given by the parameter order. x_var is a single variable representing x in the above relationship, and y_vars can be specified to be one or more sets of y values. Both the x and y variables specified must be in the same TeraScan dataset and must have the same type and dimensions.

The output data set contains selected values of the x_var variable and the associated, estimated values of the y_var variables. points is the number of x_var points to use in computing the estimated functions. The points are evenly disributed between the maximum and minimum x_var values. This output dataset is useful for the purposes of plotting the estimated relationship over the raw input data. The output dataset also contains, as attributes, the coefficients of the polynomial and the correlation between the input values and the values estimated by the polynomial.

NOTE: the algorithm assumes that errors exist only in the y variable and therefore minimizes the vertical distance from each point to the regression line (see REFERENCES and linfit).

For each x-y pair, polyfit outputs the following information:

Mean         Mean values of y and the estimated y
Stand Dev    Standard deviations of y and the estimated y
Correlation  Correlation between y and the estimated y
Bias         Mean difference between y and the esimated y
RMS          RMS difference between y and the estimated y
Count        Number of data points in the y variables
Good         Number of good points in common between x and y
Polynomial Coefficients in the form: a0 + a1*x ... an*x^n

PARAMETERS

x_var

Specifies the x variable.

There is no default.

y_vars

Specifies the y variables to use in determining the best-fit polynomials against x. A polynomial relation and its corresponding output is produced for each y variable specified. If the list is preceded by a minus sign, then all variables, except those listed, are included. Wildcards * and ? are allowed. If the y_var list happens to include the x variable, this variable is filtered out by the processing and no corresponding output is printed for this x,y (i.e. x,x) pair.

The default is to include all variables.

order

Specifies the order of the polynomial to fit to each x-y pair.

The default is 1.

points

Number of points to compute the estimated relationship with based on evenly distributed values between the minimum and maximum x_var values.

The default is 100.

printout

Whether or not to send the printout to the standard printer. Valid responses are [yes, no].

The default is no.

EXAMPLES

This example uses a dataset with four variables representing temperature and specific humidity at the sea surface and low-level atmosphere. These variables are denoted: Ts, Qs, Ta, Qa. A second-order polynomial is computed for Qs, Qa, Ta against Ts.

% polyfit bndlayer.tdf bndout.tdf
x_var          : char( 31) ? Ts
y_vars         : char(255) ? []
order          : int       ? [1] 2
points         : int       ? [100]
printout       : char(  3) ? [no]
Polynomial Fit  Page 1

bndlayer.tdf    Qa              Estimate
Mean            18.123          18.1233
Stand. Dev.     2.07929         0.978818
Bias/RMS        0.0003          1.954
Good/Total      241             360
Correlation     0.689827
0.0527713      +        0.710641 * x^1 -      0.00196545 * x^2

bndlayer.tdf    Qs              Estimate
Mean            23.0371         23.037
Stand. Dev.     4.80658         4.33331
Bias/RMS        0.0001          0.154
Good/Total      241             360
Correlation     0.948868
0.0279024      +        0.376072 * x^1 +       0.0166357 * x^2

bndlayer.tdf    Ta              Estimate
Mean            27.1467         27.1459
Stand. Dev.     2.34562         1.51162
Bias/RMS        0.0008          1.052
Good/Total      245             360
Correlation     0.793531
0.090875       +         1.22431 * x^1 -      0.00876313 * x^2

SEE ALSO

spectral, dimcorr, binavg, xcorrel, linfit, correlate, regress, stats.

REFERENCES

dpolft - SLATEC math library.

Last Update: $Date: 1998/05/29 20:16:46 $