This function overwrites dist function to contain Aitchison distance between compositions.

dist(x, method = "euclidean", ...)

Arguments

x

compositions method

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

Value

dist returns an object of class "dist".

See also

See functions dist.

Examples

X = exp(matrix(rnorm(10*50), ncol=50, nrow=10))

(d <- dist(X, method = 'aitchison'))
#>            1         2         3         4         5         6         7
#> 2  10.263844                                                            
#> 3   9.826723 11.473692                                                  
#> 4  10.221365  9.341374 10.281202                                        
#> 5   9.888913  9.150463  9.316709 10.466560                              
#> 6  10.403790 10.996713  9.004728  9.546223 10.462006                    
#> 7   9.826632  9.818426  9.579589 10.589757  9.449609  9.987269          
#> 8  11.086749 11.174443  9.764290 10.631690 11.477126 10.120957  9.537210
#> 9   9.344910  9.727568 10.861675  9.413649  8.422617  9.436001 10.101627
#> 10  9.645413  9.282252 10.002995 10.591904 10.588188  9.616371  8.409518
#>            8         9
#> 2                     
#> 3                     
#> 4                     
#> 5                     
#> 6                     
#> 7                     
#> 8                     
#> 9  10.219116          
#> 10  9.869331  9.946359
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 6.28037e-16