http://www.nabble.com/file/p24569511/mahalanobis.txt mahalanobis.txt http://www.nabble.com/file/p24569511/concentrations.txt concentrations.txt Dear Forum members, I have a problem calculating mahalanobis distances. My data file mahalanobis.txt and categories file concentrations.txt are attached. I do the following steps: x <- as.matrix(read.table("mahalanobis.txt", header=TRUE)) y <- as.matrix(read.table("concentrations.txt", header=TRUE)) S <- var(x) mahalanobis(x,y,S) and it gives this error: Error in solve.default(cov, ...) : system is computationally singular: reciprocal condition number 1.65972e-18 What is wrong? Could you please help me?? Thank you... -- View this message in context: http://www.nabble.com/mahalanobis-distance-tp24569511p24569511.html Sent from the R help mailing list archive at Nabble.com.
On Mon, Jul 20, 2009 at 3:08 PM, ekinakoglu<ekin at ims.metu.edu.tr> wrote:> Error in solve.default(cov, ...) : > ?system is computationally singular: reciprocal condition number > 1.65972e-18Try calculating the determinant of the S matrix:> det(S)[1] 2.825397e-06 It's very close to zero, and I guess that the matrix is therefore considered non-invertible by R. Recall that S must be invertible http://en.wikipedia.org/wiki/Mahalanobis_distance to work as a covarinace matrix in the definition of the Mahalanobis distance. -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
Thank you for your help... I try other data from my sampling but the determinant is very close to zero. I also tried to generate random numbers using MATLAB and then calculate S=var(x) to no avail. Could you please help me with a pseudo matrix of 4x4 that is gonna work with mahalanobis? Thanks.. -- View this message in context: http://www.nabble.com/mahalanobis-distance-tp24569511p24576155.html Sent from the R help mailing list archive at Nabble.com.