4

So it is a mathematical fact that if the determinant of a matrix is equal to zero, then the matrix must be singular (not invertible). Now, the problem I am running into is that when I calculate the determinant of my matrix it is equal to zero, however, when I calculate the inverse it exist. I think it has to do with the way R calculates determinants that the two are not agreeing. Here is the code that I am trying (I wont print the results of solve because the matrix is 100 x 100).

> Rinv = solve(R)
> 
> det(R)
[1] 0
> 
> #Using a Cholesky Factorization
> L = chol(R)
> Q = t(L)
> 
> det(L)*det(Q)
[1] 0
  • 2
    Probably a floating point issue (not printing to full decimal value.). Try `det(R) == 0L` – IRTFM Aug 08 '13 at 03:29

1 Answers1

8

For large matrices the determinant can be too large or too small and overflow the double precision. The determinant is the product of the eigenvalues: for instance, if they are all .0001, your matrix is invertible, but the determinant is 1e-400, which is too small, and can only be represented as 0.

You can look at the logarithm of the determinant instead,

determinant(R, logarithm=TRUE)

or, directly, the eigenvalues

eigen(R, only.values=TRUE)
Vincent Zoonekynd
  • 31,893
  • 5
  • 69
  • 78