`coda.base` features' enumeration

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(coda.base)

Main functions

nP = 6
nO = 8
set.seed(1)
X = matrix(rlnorm(nP * nO), ncol = nP, nrow = nO)
colnames(X) = paste0('P', 1:nP)
rownames(X) = paste0('O', 1:nO)
X

Descriptive statistics

center(X)
variation_array(X)

Aitchison distances between compositions

stats::dist() is rewritten to include the Aitchison distance between compositions:

dist(X, method = 'aitchison')

Log-ratio coordinates. coordinates()

coordinates(X)

By default, coda.base uses the isometric log-ratio coordinates defined in Egozcue et al. 2003.

To reduce typing, alr_c(), clr_c(), ilr_c() and olr_c() are functions that call coordinates() function with the option given by their name.

coordinates(X, B) accepts a log-contrast matrix $B$ to build the log-ratio coordinates. Different log-contrast matrices $B$ can be constructed (following section).

Functions to build log-contrast matrices

ilr_basis(nP)
all.equal(as.numeric(coordinates(X, 'ilr')),
          as.numeric(log(X) %*% ilr_basis(nP)))

Log-ratio matrix transformations:



Try the coda.base package in your browser

Any scripts or data that you put into this service are public.

coda.base documentation built on Nov. 26, 2023, 1:07 a.m.