I want to test if a matrix is singular or not in R. I tried a function, which is
is.non.singular.matrix()
in matrixcalc
package.
However, sometimes, in my case there is a 60*60 matrix generated, the function returns FALSE
, which means the matrix is singular. But I can still use solve()
to get the invert of the matrix. Which one should I trust? Is there any other better way to do?
Or, for a singular matrix, solve()
will return a error message. Is there a way to write a statement, that if solve()
returns an error, then do something else (for example, add some variations to the diagonal elements). But I don't know how to get the return value of the error message.