5
$\begingroup$

I have an environmental dataset, where observations do not sum up to 1. I suspect that data are a subcomposition, meaning that not all elements have been measured and that is why observations do not sum up to a constant.

I would like to apply isometric logratio transformation ilr() from a package "compositions". By applying ilr() I move from D to D-1 dimensions, meaning that I "sacrifice" one element within the data. However, when I apply ilr() function, I get a new data frame, where column names are replaced by V1 ... Vn and I loose the original names of variables. I do not understand why it happens. I suspect that I "sacrifice" the very last variable in my data frame when I apply ilr(). Should I just rename my columns manually? Does it mean that I "loose" the very last variable from my dataset?

Here is a reproducible example:

# loading library
library(compositons)

# Generate data
dataset <- data.frame(
x = runif(50, min = 0.2, max = 0.65), 
y = runif(50, min = 0.2, max = 0.4),   
z = runif(50, min = 0.1, max = 0.7))  

#Make data compositional
dataset.compositional = acomp(dataset)

# apply ILR transformation
dataset.ilr = ilr(dataset.compositional) #V1 ... Vn problem
as.data.frame(dataset.ilr)
$\endgroup$
4
$\begingroup$

If your data is compositional, it means that the only relevant information available in your data is the relative information you have between parts. Therefore, you are interested in studying the relations between parts relatively. The log-ratio methodology studies this relative relations using the quotient between parts, to be more precise, using the logarithm between ratios of parts.

You can see that all the possible ratios between a $k$-part composition, $(x_1,\dots,x_k)$, are completely caracterized by considering only $k-1$ certain (independant) log-ratios. A common approach is to consider all the ratios against the last component, $(\log\frac{x_1}{x_k}, \dots, \log\frac{x_{k-1}}{x_k}))$, this approach is known as the additive log-ratio transformation (alr). It is possible to interpret the alr tranformation as the coordinates with respect a certain basis.

  • A first problem you have with the alr tranformation is that the basis used to obtain the trnaformed values is not orthogonal but oblique and
  • a second problem is that the simplex does not seems to have an standard basis.

Although, you can define orthonormal basis in the simplex and with this basis you can define a transformation. This tranformation is commonly known as ilr transformation (ilr) and the function implemented inside the package compositions is to obtain the ilr coordinates with respect to an orthonormal basis.

With your example (I've reduced the number of composition),

set.seed(1)
# loading library
library(compositions)

# Generate data
dataset <- data.frame(
x = runif(5, min = 0.2, max = 0.65), 
y = runif(5, min = 0.2, max = 0.4),   
z = runif(5, min = 0.1, max = 0.7))  

# Make data compositional
dataset.compositional = acomp(dataset)

you have that the coordinates of your sample

(X <- dataset.compositional/rowSums(dataset.compositional))
#         x         y         z        
# [1,] 0.3462279 0.4114672 0.2423048
# [2,] 0.3818417 0.4041619 0.2139964
# [3,] 0.3515582 0.2550841 0.3933578
# [4,] 0.4811888 0.2575718 0.2612394
# [5,] 0.2730063 0.1993929 0.5276008

are

(dataset.ilr <- ilr(dataset.compositional))
#            [,1]       [,2]
# [1,]  0.12206935 -0.3618850
# [2,]  0.04017035 -0.4959822
# [3,] -0.22682715  0.2226876
# [4,] -0.44191428 -0.2435951
# [5,] -0.22218525  0.6662235

By default, the ilr function uses the basis (in columns)

(B <- exp(ilrBase(D=3))
# 1 0.4930687 0.6648138
# 2 2.0281150 0.6648138
# 3 1.0000000 2.2625592

which means that your original sample can be obtained from the orthnormal basis B and the ilr coordinates.

X1 = t(apply(dataset.ilr, 1, function(x){
  B[,1]^x[1] * B[,2]^x[2]
}))
X1 / rowSums(X1)
#            1         2         3
# [1,] 0.3462279 0.4114672 0.2423048
# [2,] 0.3818417 0.4041619 0.2139964
# [3,] 0.3515582 0.2550841 0.3933578
# [4,] 0.4811888 0.2575718 0.2612394
# [5,] 0.2730063 0.1993929 0.5276008

In this case, taking into an account the basis B, we see that (except for a constant term) the first column of the ilr coordinates is comparing the first component against the second component

1/sqrt(2) * log(X[,2]/X[,1]) # Compare with first column of dataset.ilr
# [1]  0.12206935  0.04017035 -0.22682715 -0.44191428 -0.22218525

the second column is comparing (expect for a constant term) the thir component against the other components (in fact, against the geometric mean of first and second component)

sqrt(2)/sqrt(3) * log(X[,3] / (X[,1]*X[,2])^(1/2))
# [1] -0.3618850 -0.4959822  0.2226876 -0.2435951  0.6662235

Finally, I think that a good place to find more information about the subject: articles, books, ... is http://www.compositionaldata.com/material.php

$\endgroup$
1
  • 1
    $\begingroup$ Thank you, Marc! Now I understand how ilr() transformed values are calculated. As I would like to apply PCA and FA on my environmental data to find out groupings of elements on the biplots, the ilr() transformation is useless and I should use clr() instead. $\endgroup$ – marianess Nov 6 '16 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.