[R] Mahalanobis Distance
jorgeA
thetroopermail at gmail.com
Mon Sep 26 21:05:06 CEST 2011
Hello R helpers,
I'm trying to use Mahalanobis distance to calculate distance of two time
series, to make some comparations with euclidean distance, DTW, etc, but I'm
having some dificults.
I have, for example, two objects:
s.1 <- c( 5.6324702, 1.3994353, -3.2572327, -3.8311846, -1.2248719,
0.9894694, -2.2835332, -5.1969285, -5.2823988, -3.1499400, -1.7307950,
2.8221209, 0.7005370, 4.9601216, 9.4527303)
s.2 <- c(-1.000489e-03, -8.577807e-04, -7.150633e-04, -5.716564e-04,
-4.280622e-04, -2.860101e-04, -1.451796e-04, -2.202688e-06, 1.441569e-04,
2.891237e-04, 4.280430e-04, 5.652797e-04, 7.100960e-04, 8.619236e-04,
1.007821e-03)
when I try to calculate distance with *dist *function and *proxy *package
like this:
library(proxy)
dist(rbind(s.1, s.2), method="mahalanobis")
I have the following error:
system is computationally singular: reciprocal condition number =
3.84863e-020
if I try with de* mahalanobis() *function I have the same problem
test <- rbind(s.1, s.2)
mahalanobis(test, center=colMeans(test), cov=var(test))
And trying with diferent series I have the following error:
"Lapack routine dgesv: system is exactly singular"
I found some similar errors on the mailing list, but couldn't find some
useful help for my case.
Am I doing something wrong? Isn't it possible to use mahalanobis distance
with that kind of data?
Thank you very much for your help.
--
View this message in context: http://r.789695.n4.nabble.com/Mahalanobis-Distance-tp3844960p3844960.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list