clr1 {norMmix}R Documentation

Centered Log Ratio Transformation and Inverse

Description

The centered log ratio transformation is Maechler's solution to allowing unconstrained mixture weights optimization.

It has been inspired by Aitchison's centered log ratio, see also CRAN package compositions' clr(), and typically other references on modelling proportions.

Usage

clr1(w)
clr1inv(lp)

Arguments

w

numeric vector of length k, say, of mixture weights, i.e., non-negative and summing to one.

lp

numeric vector of length k-1 clr-transformed weights.

Details

Aitchison's clr transformation is slightly different, as it does not drop one coordinate, as we do. Hence the extra ‘1’ in the name of our version.

Value

a numeric vector of length k-1 or k, see above.

Author(s)

Martin Maechler

References

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

More in the CRAN package compositions vignette ‘UsingCompositions.pdf

See Also

The first implementation of these was in nor1mix, June 2019, in its par2norMix() and nM2par() functions.

Examples

## Apart from error checking and very large number cases, the R implementation is simply
..clr1 <- function (w) {
  ln <- log(w)
  ln[-1L] - mean(ln)
}

## and its inverse
..clr1inv <- function(lp) {
  p1 <- exp(c(-sum(lp), lp))
  p1/sum(p1)
}

lp <- clr1( (1:3)/6 )
clr1inv(lp)
stopifnot(all.equal(clr1inv(lp), (1:3)/6))

for(n in 1:100) {
   k <- 2 + rpois(1, 3) # #{components}
   lp <- rnorm(k-1) # arbitrary unconstrained
   ## clr1() and clr1inv() are inverses :
   stopifnot(all.equal(lp, clr1(clr1inv(lp))))
}

wM <- clr1inv(c(720,720,720))
w2 <- clr1inv(c(720,718,717))
stopifnot(is.finite(wM), all.equal(wM, c(0, 1/3, 1/3, 1/3))
        , is.finite(w2), all.equal(w2, c(0, 0.84379473, 0.1141952, 0.042010066))
         )

[Package norMmix version 0.1-1 Index]