Skip to contents

Maps closed compositions off the simplex into real space via \(\mathrm{clr}(x) = \log x - \overline{\log x}\) (row-wise). Removes the closure so downstream Gaussian/causal models are not fed singular covariance. CLR is rank-deficient (columns sum to zero); for regression/DML inputs prefer morie_taphonomy_ilr.

Usage

morie_taphonomy_clr(x, pseudocount = 1e-06)

Arguments

x

Numeric matrix/data.frame of compositions (rows = samples).

pseudocount

Small value added before the log to guard zeros (default 1e-6).

Value

A numeric matrix (same shape) of CLR coordinates.

References

Aitchison J (1986). The Statistical Analysis of Compositional Data. Chapman & Hall.

Examples

morie_taphonomy_clr(morie_taphonomy_simulate_pxrf(3, seed = 1)[, 1:6])
#>            Ca        P        Fe        Sr         Pb        Zn
#> [1,] 3.711784 3.226372 2.2711521 -1.911188 -0.6282677 -6.669853
#> [2,] 3.503778 2.110763 1.6470240 -1.961472 -0.2345679 -5.065525
#> [3,] 2.744213 1.936511 0.4929704 -2.030117 -1.7946877 -1.348890