Formula: clr(x) = log x - mean(log x); eigendecompose the clr covariance; proportion retained = (s_1^2+...+s_r^2)/sum s^2
References
Aitchison, A Concise Guide to Compositional Data Analysis, Chapter 2. Verified against the text: the centre estimate is xi-hat = C(g_1, ..., g_D) with g_i the geometric mean of the ith component, and totvar(x) = trace(Gamma) = (1/D) sum_{i<j} var{log(x_i/x_j)}.
Examples
M <- matrix(c(1, 2, 3, 4, 5, 6), nrow = 2)
Clrpca(M)
#> $values
#> [1] 7.274094e-02 5.551115e-17 2.888313e-18
#>
#> $loadings
#> [,1] [,2]
#> [1,] 0.8007696 0.5989724
#> [2,] -0.2622690 0.3506289
#> [3,] -0.5385007 0.7199246
#>
#> $scores
#> [,1] [,2]
#> [1,] -0.1907104 -8.283400e-17
#> [2,] 0.1907104 2.732285e-17
#>
#> $prop_var
#> [1] 1.00000e+00 7.63135e-16
#>
#> $cum_prop
#> [1] 1 1
#>
#> $k
#> [1] 2
#>
#> $n
#> [1] 2
#>
#> $D
#> [1] 3
#>
#> $method
#> [1] "Compositional (clr) principal components"
#>
#> attr(,"class")
#> [1] "morie_rich_result" "list"
