Skip to contents

\(\sqrt{rs/(r+s)}\,\log(g(x_{num})/g(x_{den}))\): the normalised log-ratio of the geometric means of two disjoint groups of parts.

Usage

morie_aitchison_balance(x, numerator, denominator)

Arguments

x

composition matrix, strictly positive; rows are observations.

numerator, denominator

0-based column indices of the two disjoint groups, as in the Python module.

Value

list with balance, normalizer, geometric_mean_num, geometric_mean_den.

Details

A composition carries only RELATIVE information – doubling every part changes nothing – so any statistic computed on the raw proportions is measuring the constraint rather than the data. Log ratios are the coordinates that respect that, and the \(\sqrt{rs/(r+s)}\) factor makes balances from different group sizes comparable.

Zeros are fatal, not inconvenient: the logarithm is undefined, and the function refuses rather than adding an arbitrary constant that would silently determine the answer. Replace them deliberately first.

References

Egozcue, J. J. and Pawlowsky-Glahn, V. (2005). Groups of parts and their balances in compositional data analysis. Mathematical Geology, 37(7), 795-828.

Examples

x <- matrix(c(0.2, 0.3, 0.5, 0.1, 0.6, 0.3), ncol = 3, byrow = TRUE)
round(morie_aitchison_balance(x, 0, c(1, 2))$balance, 4)
#> [1] -0.5396 -1.1800