Calculate the coordinates of a composition with respect a given basis
coordinates(X, basis = "ilr", basis_return = TRUE)
coord(..., basis = "ilr")
alr_c(X)
clr_c(X)
ilr_c(X)
olr_c(X)
compositional dataset. Either a matrix, a data.frame or a vector
basis used to calculate the coordinates. basis
can be either a string or a matrix.
Accepted values for strings are: 'ilr' (default), 'clr', 'alr', 'pw', 'pc', 'pb' and 'cdp'. If basis
is a matrix, it is expected
to have log-ratio basis given in columns.
Should the basis be returned as attribute? (default: TRUE
)
components of the compositional data
Coordinates of composition X
with respect the given basis
.
coordinates
function calculates the coordinates of a compositiona w.r.t. a given basis. `basis` parameter is
used to set the basis, it can be either a matrix defining the log-contrasts in columns or a string defining some well-known
log-contrast: 'alr' 'clr', 'ilr', 'pw', 'pc', 'pb' and 'cdp', for the additive log-ratio, centered log-ratio, isometric log-ratio,
pairwise log-ratio, clr principal components, clr principal balances or default's CoDaPack balances respectively.
See functions ilr_basis
, alr_basis
,
clr_basis
, sbp_basis
to define different compositional basis.
See function composition
to obtain details on how to calculate
a compositions from given coordinates.
coordinates(c(1,2,3,4,5))
#> ilr1 ilr2 ilr3 ilr4
#> -0.4901291 -0.6140370 -0.6833297 -0.7288906
h = coordinates(c(1,2,3,4,5))
basis(h)
#> 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
# basis is shown if 'coda.base.basis' option is set to TRUE
options('coda.base.basis' = TRUE)
coordinates(c(1,2,3,4,5))
#> ilr1 ilr2 ilr3 ilr4
#> -0.4901291 -0.6140370 -0.6833297 -0.7288906
#> attr(,"basis")
#> 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
#> Basis:
#> 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
# Default transformation can improve performance.
N = 100
K = 1000
X = matrix(exp(rnorm(N*K)), nrow=N, ncol=K)
system.time(coordinates(X, alr_basis(K)))
#> user system elapsed
#> 0.014 0.011 0.026
system.time(coordinates(X, 'alr'))
#> user system elapsed
#> 0.016 0.004 0.020