Skip to contents

Formula: d_a(x, y)^2 = (1/D) sum_{i<j} ( log(x_i/x_j) - log(y_i/y_j) )^2

Usage

Compdist(x, y)

Arguments

x

Composition with strictly positive parts.

y

Second composition, same length as x, strictly positive.

Value

List with distance, distance2, D.

References

Aitchison, J. (1986), The Statistical Analysis of Compositional Data, Chapman and Hall, is the primary source; the definitions below are as printed in Mateu-Figueras, G., Pawlowsky-Glahn, V. and Egozcue, J. J., The normal distribution in some constrained sample spaces, arXiv:0802.2643 (published as SORT 37(1):29-56, 2013), Sect. 4.1, which prints them with equation numbers and attributes them to Aitchison (1982, 1986). The squared distance printed immediately after equation (10). It is relative: it is unchanged by perturbing both arguments by the same composition, and scales by |a| under powering.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Compdist(V, V)
#> $distance
#> [1] 0
#> 
#> $distance2
#> [1] 0
#> 
#> $D
#> [1] 8
#> 
#> $method
#> [1] "Aitchison distance"
#> 
#> attr(,"class")
#> [1] "morie_rich_result" "list"