MultiLinReg

Declaration: MultiLinReg(InLayers: TIntArray; llx, lly, urx, ury, TSlot: integer; TargetMatrix: TDouble2DArray; var coeffs, deltacoeffs: TDoubleArray): integer;
Calculates the best approximated solution for an overdetermined equation system (more equations than variables). The open array Inlayers contains the list of layers to be used as independent variables xi, the open array TargetMatrix contains the values of the dependent variable y. The parameters llx, lly, urx and ury (lower left to upper right) define the range of pixels which are used for the regression model, the parameter TSlot specifies the corresponding time slot.

The function returns a zero value if the result is valid. In this case the coefficients a0 to an of the solution are contained in the open array coeffs.

The open array deltacoeffs reflects the uncertainties of the estimated parameters returned in coeffs. In order to get the standard deviation of the parameters, deltacoeffs has to be multiplied by the standard error of the residuals. The standard error can be calculated by

STDERR.gif

with n = number of pixels uses for the model, k = number of selected input layers, Yi = target data, and Yi-hat being the estimated target data.

The equation system to be solved can be denoted as follows (the coefficients ai correspond to the parameter coeffs, the values ymn are stored in TargetMatrix, and the values xmnp are taken from the layers defined by InLayers. The indices m and n refer to the x- and y-coordinates of the images, the index p denotes the layer index:

EQUSYST.gif

The function returns the following error codes:

 0 ... everything is OK
-1 ... regression was impossible to compute, results are invalid
-2 ... the data is near singular, do not use the results (numerical instabilities)
-3 ... the TargetMatrix does match the data cube
-4 ... the range [llx,lly]..[urx,ury] is out of range
-5 ... time slot out of range