tpq / propr

[OFFICIAL] [CoDA] An R package to calculate proportionality and other measures for compositional data
69 stars 10 forks source link

Question about centered log-ratio transformation #22

Closed li000678 closed 3 years ago

li000678 commented 3 years ago

Hi Thom, I noticed that in the scripts we are using 'rowMeans' to compute log-ration transformed data. https://github.com/tpq/propr/blob/2bd7c44bf59eaac6b4d329d38afd40ac83e2089a/R/1-propr.R#L161-L162 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 3 years ago

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))

li000678 commented 3 years ago

Now I get it, thanks a lot!