[R] log transformation and mean question

(Ted Harding) ted.harding at wlandres.net
Thu May 12 18:37:48 CEST 2011


On 12-May-11 15:15:00, 1Rnwb wrote:
> I have question about log2 transformation and performing mean
> on log2 data. I am doing analysis for ELISA data. the OD values
> and the concentration values for the standards were log2
> transformed before performing the lm. the OD values for samples
> were log2 transformed and coefficients of lm were applied to get
> the log2 concentration values. I then backtransformed these
> log2 concentrations and the trouble started. when i take the
> mean of log2 concentrations the value is different than the
> backtransformed concentrations.
> 
>> 100+1000/2
> [1] 600
> 
>> 2^( ( log2(100)+log2(1000) )/2 )
> [1] 316.2278
> 
> What I am doing wrong to get the different values

Apart from the fact that I think your first line should be

  (100+1000)/2
  # [1] 550

you are doing nothing whatever wrong! The difference is an
inevitable result of the fact that, for any set of positive
numbers X = c(x1,x2,...,xn), not all equal,

  mean(log(X)) < log(mean(X))

This is because the curve of y = log(x) lies below the
tangent to the curve at any given point. If that point is
mean(X), and the tangent is y = a + b*x, then

  mean(log(X)) < mean(a + b*X) = a + b*mean(X) = log(mean(X))

since y = a + b*x is tangent to y = log(x) at x = mean(X).
This is a special case of a general result called Jensen's
Inequality.

Your second line is

  2^mean(log2(X)) < 2^log2(mean(X)) = mean(X).

where X = c(100,1000).

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 12-May-11                                       Time: 17:37:45
------------------------------ XFMail ------------------------------



More information about the R-help mailing list