Build an ilr_basis
using a sequential binary partition or
a generic coordinate system based on balances.
sbp_basis(sbp, data = NULL, fill = FALSE, silent = FALSE)
parts to consider in the numerator and the denominator. Can be defined either using a list of formulas setting parts (see examples) or using a matrix where each column define a balance. Positive values are parts in the numerator, negative values are parts in the denominator, zeros are parts not used to build the balance.
composition from where name parts are extracted
should the balances be completed to become an orthonormal basis? if the given balances are not orthonormal, the function will complete the balance to become a basis.
inform about orthogonality
matrix
X = data.frame(a=1:2, b=2:3, c=4:5, d=5:6, e=10:11, f=100:101, g=1:2)
sbp_basis(list(b1 = a~b+c+d+e+f+g,
b2 = b~c+d+e+f+g,
b3 = c~d+e+f+g,
b4 = d~e+f+g,
b5 = e~f+g,
b6 = f~g), data = X)
#> b1 b2 b3 b4 b5 b6
#> a 0.9258201 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> b -0.1543033 0.9128709 0.0000000 0.0000000 0.0000000 0.0000000
#> c -0.1543033 -0.1825742 0.8944272 0.0000000 0.0000000 0.0000000
#> d -0.1543033 -0.1825742 -0.2236068 0.8660254 0.0000000 0.0000000
#> e -0.1543033 -0.1825742 -0.2236068 -0.2886751 0.8164966 0.0000000
#> f -0.1543033 -0.1825742 -0.2236068 -0.2886751 -0.4082483 0.7071068
#> g -0.1543033 -0.1825742 -0.2236068 -0.2886751 -0.4082483 -0.7071068
sbp_basis(list(b1 = a~b,
b2 = b1~c,
b3 = b2~d,
b4 = b3~e,
b5 = b4~f,
b6 = b5~g), data = X)
#> b1 b2 b3 b4 b5 b6
#> a 0.7071068 0.4082483 0.2886751 0.2236068 0.1825742 0.1543033
#> b -0.7071068 0.4082483 0.2886751 0.2236068 0.1825742 0.1543033
#> c 0.0000000 -0.8164966 0.2886751 0.2236068 0.1825742 0.1543033
#> d 0.0000000 0.0000000 -0.8660254 0.2236068 0.1825742 0.1543033
#> e 0.0000000 0.0000000 0.0000000 -0.8944272 0.1825742 0.1543033
#> f 0.0000000 0.0000000 0.0000000 0.0000000 -0.9128709 0.1543033
#> g 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 -0.9258201
# A non-orthogonal basis can also be calculated.
sbp_basis(list(b1 = a+b+c~e+f+g,
b2 = d~a+b+c,
b3 = d~e+g,
b4 = a~e+b,
b5 = b~f,
b6 = c~g), data = X)
#> Warning: Given basis is not orthogonal
#> b1 b2 b3 b4 b5 b6
#> a 0.4082483 -0.2886751 0.0000000 0.8164966 0.0000000 0.0000000
#> b 0.4082483 -0.2886751 0.0000000 -0.4082483 0.7071068 0.0000000
#> c 0.4082483 -0.2886751 0.0000000 0.0000000 0.0000000 0.7071068
#> d 0.0000000 0.8660254 0.8164966 0.0000000 0.0000000 0.0000000
#> e -0.4082483 0.0000000 -0.4082483 -0.4082483 0.0000000 0.0000000
#> f -0.4082483 0.0000000 0.0000000 0.0000000 -0.7071068 0.0000000
#> g -0.4082483 0.0000000 -0.4082483 0.0000000 0.0000000 -0.7071068