pwlr: Pairwise log ratio transform

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/compositions.R


Compute the pairwise log ratio transform of a (dataset of) composition(s), and its inverse.


      pwlr( x, as.rmult=FALSE,!as.rmult, ...)
      pwlrInv( z, orig=gsi.orig(z))



a composition, not necessarily closed


the pwlr-transform of a composition, thus a [D(D-1)/2]-dimensional real vector, or a matrix with such many columns


logical; should the output be produced as an rmult object?

logical; should be as a data.frame? if both are false, rmult will be taken


currently unused


the original composition, to check consistency and recover component names


The pwlr-transform maps a composition in the $D$-part Aitchison-simplex isometrically to a $D(D-1)/2$ dimensonal euclidian vector, computing each possible logratio (accounting for the fact that $log(A/B)=-log(B/A)$, and therefore only one of them is necessary). The data can then be analysed in this transformation by multivariate analysis tools not relying on the invertibility of the covariance function. The interpretation of the results is relatively simple, since each component captures the behaviour of the simple ratio between two party. However redundance between them is extremely high, and any of alr, clr or ilr transformations may be preferred in most applications.

The pairwise logratio transform is given by

pwlr(x)_{ij} := \ln(x_i/x_j)


The inverse requires some explanation, because of the redundance between pwlr scores. Note that for any three components $A,B,C$ it holds that $log(A/C)=log(A/B)+log(B/C)$. So, any vector of $D(D-1)/2$ coefficients will not be necessarily a valid pwlr-transformed composition: if these coefficients do not satisfy that kind of relations, the vector is, strictly speaking, not a pwlr and should not be inverted. Nevertheless, the function gives a least-squares inversion, as proposed by Tolosana-Delgado and von Eynatten (2009).


pwlr gives the pairwise log ratio transform; accepts a compositional dataset pwlrInv gives a closed composition with the given wplr-transform; accepts a dataset


R. Tolosana-Delgado


Aitchison, J. (1986) The Statistical Analysis of Compositional Data Monographs on Statistics and Applied Probability. Chapman & Hall Ltd., London (UK). 416p.

Tolosana-Delgado, R. and H. von Eynatten (2009); Grain-size control on petrographic composition of sediments: compositional regression and rounded zeroes. Mathematical Geosciences: 41(8): 869-886. doi: 10.1007/s11004-009-9216-6.

See Also



(tmp <- pwlr(c(1,2,3)))

Example output

Welcome to compositions, a package for compositional data analysis.
Find an intro with "? compositions"

Attaching package:compositionsThe following objects are masked frompackage:stats:

    cor, cov, dist, var

The following objects are masked frompackage:base:

    %*%, norm, scale, scale.default

        2.1      3.1       3.2
1 0.6931472 1.098612 0.4054651
     [,1]      [,2]      [,3]
[1,] 0.1666667 0.3333333  0.5
[1] acomp

compositions documentation built on Jan. 5, 2022, 5:09 p.m.