我想计算从一组点到这些点的质心的多元距离。Mahalanobis 距离似乎适合于此。但是,我收到一个错误(见下文)。
谁能告诉我为什么会收到此错误,以及是否有解决方法?
require(maptools)
occ <- readShapeSpatial('occurrences.shp')
load('envDat.Rdata')
#standardize the data to scale the variables
dat <- as.matrix(scale(dat))
centroid <- dat[1547,] #let's assume this is the centroid in this case
#Calculate multivariate distance from all points to centroid
mahalanobis(dat,center=centroid,cov=cov(dat))
Error in solve.default(cov, ...) :
system is computationally singular: reciprocal condition number = 9.50116e-19