The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Class: none
Declaration: function CalcHatMatrix (Arr: TDouble2DArray; var HatMat: TDouble2DArray): integer;

The function CalcHatMatrix calculates the hat matrix of matrix Arr and stores the result in matrix HatMat (Arr is denoted as X, HatMat as H):

H := X(XTX)-1XT

The function returns the following error codes:
 0 ... everything is OK
-1 ... the source matrix Arr has zero size
-2 ... not enough memory on heap
-3 ... LU decomposition was not possible (singular covariance matrix)


Hint: Please note that the calculation of the hat matrix can consume considerable amounts of memory. The memory requirement (including the arrays Arr and HatMat) amounts to 8*((p+n)2 + pn) bytes, with p being the number of columns of the array Arr and n being the number of rows.

Last Update: 2020-Aug-23