Greenacre 2023 - Logratios ALR CLR ILR and Log-Contrasts
Summary
Pairwise logratios (LR), additive logratios (ALR, fixed reference part) and centred logratios (CLR, divide by geometric mean) all have dimension d=D−1 and are linear in logx. CLR is exactly isometric to the full logratio geometry but not coherent; ALR is coherent but only approximately isometric; ILR is both but needs ratios of geometric means that are hard to interpret.
LR(j,k)=log(xj/xk)=logxj−logxk, j=k. There are 21D(D−1) unique LRs (Tellus: 21⋅52⋅51=1326), linearly interrelated with rank d=D−1. LRs map Sd to Rd.
Additive logratio, ALR (Eq. 3)
ALR(j∣ref)=log(xj/xref), j=ref: d logratios with a common denominator (the reference). There are D possible ALRs. If logxref has very low variance, ALRs are practically logxj up to a near-constant. Wide data sets often contain such a near-constant reference.
Centred logratio, CLR (Eq. 4)
CLR(j)=logg(x)xj=logxj−D1∑klogxk with geometric mean g(x)=(x1⋯xD)1/D. CLR(j)=D1∑kLR(j,k). The D CLRs sum to zero so have rank d; they live in Td={y∈RD:∑yj=0} (Eq. 5). Euclidean distances on CLRs equal those on all 21D(D−1) LRs, so the CLR transformation is isometric.
Log-contrast
∑jajlogxj with ∑jaj=0 (ensures scale invariance). LR and ALR have coefficients +1,−1 on two parts; a CLR has 1−D1 on part j and −D1 on the others. If compositions are predictors or responses, all logratio transformations generate the same log-contrasts, so the choice among them is driven by interpretability, with LR/ALR being the most attractive.
Isometry and ILR
Logratio geometry: the set of distances between cases based on all LRs. A set of transformed variables is isometric if it reproduces this geometry exactly up to scale. ILRs use d orthogonal log-contrasts. Example with parts A,B,C,D,E: h1=21(logA+logB)−31(logC+logD+logE)=log(CDE)1/3(AB)1/2 (coefficients [21,21,−31,−31,−31], sum 0); h2=21-type contrast of A vs B, etc. (Eq. 6 matrix: rows [2121−31−31−31], [1−1000], [001−21−21], [0001−1] up to normalisation) giving a dendrogram of balances. h1 equals the average of the six LRs between {A,B} and {C,D,E}.
Dispersion in compositions (Aitchison)
The variation matrix T=[τjk], τjk=Varlog(xj/xk), and covariances of LRs follow from it: Cov(LR(j,k),LR(u,v))=21(τjk+τuv−τju−τkv). Total logratio variability =D1∑j<kτjk=∑jVar(CLR(j)).
Greenacre’s version, TotVar, divides by D again (weights 1/D2); weights on parts can be unequal. Distances are defined as averages rather than sums so they are comparable across numbers of parts (Sec. 3.9).
Transform
# variables
Coherent?
Isometric?
Needs
LR (all pairs)
21D(D−1)
yes
yes (by definition)
selection of subset
ALR (reference)
D−1
yes
approx. (quasi)
choice of reference
CLR
D (rank D−1)
no (uses all parts)
yes
singular covariance
ILR / pivot
D−1
no
yes
orthonormal basis; ratios of geometric means
SLR (amalgamation)
any
with respect to additions
not a log-contrast
subject-matter amalgams
Examples
Python: ALR, CLR and ILR in numpy
import numpy as npx = np.array([[0.5, 0.3, 0.2], [0.2, 0.3, 0.5]]) # compositions (rows sum to 1)alr = np.log(x[:, :-1] / x[:, [-1]]) # reference = last partclr = np.log(x) - np.log(x).mean(axis=1, keepdims=True)# one ILR basis: balance {1,2 | 3} and {1 | 2}V = np.array([[1/np.sqrt(6), 1/np.sqrt(6), -2/np.sqrt(6)], [1/np.sqrt(2), -1/np.sqrt(2), 0]])ilr = clr @ V.T# CLR distances equal the "all-LR" distances (isometry)d_clr = np.linalg.norm(clr[0] - clr[1])