tpq/propr

Question about centered log-ratio transformation

Closed this issue · 2 comments

Hi Thom,
I noticed that in the scripts we are using 'rowMeans' to compute log-ration transformed data.

propr/R/1-propr.R

Lines 161 to 162 in 2bd7c44

ref <- rowMeans(logSet)
lr <- sweep(logX, 1, ref, "-")

This 'rowMeans' seems to me that it is calculating the algorithmic means instead of the geometric means mentioned in the article. Is this actually the case or I am misinterpreting it?

tpq commented

You are correct that we use rowMeans, but they are the rowMeans of log data.
The arithmetic mean of the logs is the log of the geometric means!

Consider the mean between two variables,

(log(a) + log(b)) / 2
= log(ab)/2
= log(sqrt(ab))

Now I get it, thanks a lot!