Error in Solve.default(var(x)) - R

Asked

Viewed 403 times

2

I’ve been trying to build a distribution map for certain species using distance methods. I’m having difficulty getting results via Mahalanobis Distance. The package that has this function is the dismo, which is expressed as mahal. When entering the data the console returns me that:

Error in solve.default(var(x)) : 
sistema é computacionalmente singular: condição recíproca número = 3.14572e-20

Searching, I found information that the error occurs when the matrix cannot be reversed, and/or when the covariance value is close to zero. However, I cannot find a way to solve this problem. I tried to understand the problem, and I wonder if there are mathematical manipulations to circumvent the error?

Thanks for the help.

Follow a sample of the data.

head na matrix:
alt bio1 bio5 bio6 bio7 bio9 bio10 bio12 bio18 bio19 footprint luzworld
1  51  275  395  178  217  284   326    40     4     2  14.00000        0
2  15  277  396  181  215  285   327    42     4     2  14.00000        0
3 136  270  390  172  218  280   321    39     5     2  12.04751        0
4  94  273  393  175  218  282   324    40     5     2  14.06253        0
5  52  275  395  178  217  284   326    40     3     2  14.00000        0
6 245  265  385  165  220  275   316    39     6     2   7.00000        0
  • has any variable that is constant? type this luzworld?

  • can add the result of det(cov(seu_banco)) in the question? A matrix is invertible if and only if this determinant is != 0. As this problem is very specific to your data, it is difficult to help without having the complete data set.

  • No constant variable, although luzworld has many zeros. I tried to calculate the Mahalanobis distance by removing the variables Footprint and luzworld, the error remains. The determinant of the matrix is very close to zero, is that the problem? det(cov(native)) [1] -6.938182e+20

  • In fact det(cov(nativo)), -6.938182e+20 is very negative in its case, which is strange since the determinant of the covariance matrix should always be positive. (see here http://math.stackexchange.com/questions/889425/what-does-determinant-of-covariance-matrix-give). The problem is out there...

  • Can post covariance matrix?

  • 1

    Have you done data imputation? Sometimes this can lead to a negative determinant.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.