LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GenLSFit: singular matrix error with m x n matrix

We are doing a multi-variable linear regression with GenLSFit in LabWindows/CVI 6. We have more data points than coefficients, hence the system is over-specified, and the H matrix is not square (i.e. m x n, rather then n x n).

In certain cases, we get error -20041 "Input matrix is singular" using SVD (or any other algorithm available).

Should SVD not work in this case anyway? (For on-line info, see http://online.redwoods.cc.ca.us/instruct/darnold/laproj/Fall98/JodLynn/report2.pdf or http://www.cs.unr.edu/~bebis/MathMethods/SVD/lecture.pdf)

I'm unsure if our problem is our math or a limitation in the GenLSFit function.
0 Kudos
Message 1 of 4
(3,000 Views)
Andrew,

This could actually be a limitation of computers!
There is the possibility that the values on the data points matrix are close to zero, then when this values get squared, they could be getting to close to zero and due to rounding errors they are interpreted as zero, causing the matrix to be singular and the function is not able to calculate the inverse.

Another possibility is that the determinant of the matrix is zero, due to a row or column being zero or there are some linearly dependant rows/columns.

My suggestion is to print out the original matrix when you get an error and check if the determinant of the matrix is 0.

I hope this can give you some pointers on this problem, let me know if you have any questions.

Regards,

Juan Carlos
N.
I.
0 Kudos
Message 2 of 4
(3,000 Views)
Could you help me out a bit further, please? In the case of a non-square matrix, what is the determinant?

Most methods for calculating the determinant are limited to square matrices (including the functions in the Advanced Analysis Library). I have more observations than coefficents to solve for, hence the matrix is not square.

On another front, my independent variables tend to be integer values, making it quite possible that a row could be a linear combination of some others. Do I need to check that I have at least as many linearly independent rows as coefficients?.

Finally, to your point about values being zero, it is common for some independent variables to be zero. Could that alone be the problem?

Thanks for your help!
0 Kudos
Message 3 of 4
(3,000 Views)
Regardles of the matrix size it will be squre before we calculate the invers or determinant. This happens because the the matrix will be multiplied by it's own transposed matrix, forcing it to be square. In the help for this function you'll find that the H matrix it's transposed and multiplied by H; then we get inverse of the resulting matrix.

Having some values being zero in your matrix is not a problem, the problem is when a complete row or column are zero.

Probably the best way to predict the error is to calculate the transposed matrix, multiply it times the original matrix and get the determinat; if you get a zero you'll know that the data on the matrix has a problem.

Let me know if you have other questions.

Regards,

Juan Carlos

N.I.
0 Kudos
Message 4 of 4
(3,000 Views)