Advanced Analysis Library Only
AnalysisLibErrType GenLSFitCoef (void *HMatrix, int numberOfRows, int numberOfColumns, double YArray[], double coefficientArray[], int algorithm);
Finds the set of linear fit coefficients, which describe the linear curve that best represents the input data that GenLSFitCoef uses to obtain the least squares solution technique. The general form of the k-dimension linear fit is as follows:
Let | i = 0, 1, . . ., n be your ![]() |
xij, ..., xik — 1 be k —1 observed x points | |
yi be observed y points |
Compose the HMatrix as follows:
GenLSFitCoef obtains the general LS linear fit coefficient bk by minimizing the quantity:
Input | ||
Name | Type | Description |
HMatrix | double-precision | Input matrix that represents the formula you use to fit the data set (x,y). Hij are the function values of Xi. |
numberOfRows | integer | Number of rows in HMatrix and the number of elements in YArray. |
numberOfColumns | integer | Number of columns in HMatrix and the number of elements in coefficientArray. |
YArray | double-precision array | Array that contains the y-coordinates of the (x, y) data sets to fit. |
algorithm | integer | Algorithm used to solve the multiple linear regression model. The algorithm has following possible values. 0 = Singular value decomposition (default) 1 = Givens decomposition 2 = Square root free Givens decomposition 3 = Household transformation 4 = LU decomposition 5 = Cholesky decomposition Each algorithm might offer different precision depending on the input data. Given the coefficient vector coefficientArray and HMatrix, GenLSFitCoef can calculate the fitted data zi by a simple matrix multiplication: Z = H × b and can calculate the mean squared error with the following formula: ![]() |
Output | ||
Name | Type | Description |
coefficientArray | double-precision array | The set of linear coefficients that best fit the multiple linear regression model in a least squares sense. The size of this array must be at least numberOfColumns. |
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |