This function overwrites dist
function to contain Aitchison distance between
compositions.
dist(x, method = "euclidean", ...)
compositions method
the distance measure to be used. This must be one of "aitchison", "euclidean", "maximum", "manhattan", "canberra", "binary" or "minkowski". Any unambiguous substring can be given.
arguments passed to dist
function
dist
returns an object of class "dist".
See functions dist
.
X = exp(matrix(rnorm(10*50), ncol=50, nrow=10))
(d <- dist(X, method = 'aitchison'))
#> 1 2 3 4 5 6 7
#> 2 10.352200
#> 3 9.364791 9.766711
#> 4 10.561386 11.251948 11.147940
#> 5 9.007597 8.557765 8.081582 9.841331
#> 6 9.566267 9.555494 10.225634 10.447485 8.782980
#> 7 10.834977 10.134564 11.021330 11.572473 11.009179 10.277939
#> 8 9.129989 9.918264 9.272367 10.202846 8.930418 9.385924 10.927016
#> 9 9.447329 9.745839 10.443461 10.524481 10.309114 8.913280 9.873726
#> 10 9.426881 8.560114 9.859558 10.102383 9.200730 8.498711 9.722677
#> 8 9
#> 2
#> 3
#> 4
#> 5
#> 6
#> 7
#> 8
#> 9 9.710159
#> 10 9.045076 9.800339
plot(hclust(d))
# In contrast to Euclidean distance
dist(rbind(c(1,1,1), c(100, 100, 100)), method = 'euc') # method = 'euclidean'
#> 1
#> 2 171.473
# using Aitchison distance, only relative information is of importance
dist(rbind(c(1,1,1), c(100, 100, 100)), method = 'ait') # method = 'aitchison'
#> 1
#> 2 8.14626e-16