R/basis.R
ilr_basis.Rd
Builds an isometric log-ratio (ilr) basis for a composition with k+1
parts, also called orthonormal log-ratio (olr) basis.
ilr_basis(dim, type = "default")
olr_basis(dim, type = "default")
An integer indicating the number of components. If a dataframe or matrix is provided, the number of components is inferred from the number of columns. If a character vector specifying the names of the parts is provided the number of component is its length.
Character string specifying the type of basis to generate.
Options are "pivot"
, "cdp"
. Any other option will return the Helmert basis defined by Egozcue et al., 2013..
A matrix representing the orthonormal basis.
The basis vectors are constructed as: $$h_i = \sqrt{\frac{i}{i+1}} \log\frac{\sqrt[i]{\prod_{j=1}^i x_j}}{x_{i+1}}$$ for \(i = 1, \ldots, k\).
Setting the type
parameter to "pivot"
(pivot balances) or "cdp"
(codapack balances) allows generating alternative ilr/olr bases.
Egozcue, J.J., Pawlowsky-Glahn, V., Mateu-Figueras, G., & Barceló-Vidal, C. (2003). Isometric logratio transformations for compositional data analysis. Mathematical Geology, 35(3), 279–300.
ilr_basis(5)
#> ilr1 ilr2 ilr3 ilr4
#> c1 0.7071068 0.4082483 0.2886751 0.2236068
#> c2 -0.7071068 0.4082483 0.2886751 0.2236068
#> c3 0.0000000 -0.8164966 0.2886751 0.2236068
#> c4 0.0000000 0.0000000 -0.8660254 0.2236068
#> c5 0.0000000 0.0000000 0.0000000 -0.8944272
ilr_basis(alimentation[,1:9])
#> ilr1 ilr2 ilr3 ilr4 ilr5 ilr6 ilr7
#> RM 0.7071068 0.4082483 0.2886751 0.2236068 0.1825742 0.1543033 0.1336306
#> WM -0.7071068 0.4082483 0.2886751 0.2236068 0.1825742 0.1543033 0.1336306
#> E 0.0000000 -0.8164966 0.2886751 0.2236068 0.1825742 0.1543033 0.1336306
#> M 0.0000000 0.0000000 -0.8660254 0.2236068 0.1825742 0.1543033 0.1336306
#> F 0.0000000 0.0000000 0.0000000 -0.8944272 0.1825742 0.1543033 0.1336306
#> C 0.0000000 0.0000000 0.0000000 0.0000000 -0.9128709 0.1543033 0.1336306
#> S 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 -0.9258201 0.1336306
#> N 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 -0.9354143
#> FV 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> ilr8
#> RM 0.1178511
#> WM 0.1178511
#> E 0.1178511
#> M 0.1178511
#> F 0.1178511
#> C 0.1178511
#> S 0.1178511
#> N 0.1178511
#> FV -0.9428090