3
$\begingroup$

I am doing an ANOVA analysis, and to correct for normality, I used a log transformation on the response variable, RATING. I am trying to display some summary statistics. When I find the means of RATING and LOG_RATING, LOG_RATING is close to what I calculate the value to be, but not exactly the same. As in log(RATING) does not equal LOG_RATING. There is no missing data, so I am very confused.

Cohort is a categorical value 1 through 6. Rating is quantitative.

Here is the relevant code, output, and what log(RATING) should equal. Thoughts?

DATA SHEET1;  
SET SHEET1;  
LOG_RATING=LOG(RATING);  
RUN;

PROC SORT  DATA=SHEET1;  
BY COHORT;  
RUN;

PROC MEANS DATA=SHEET1 N MEAN VAR MAXDEC=2 ;  
CLASS COHORT;  
BY RATING;  
RUN;

Output with Calculated Log Rating

$\endgroup$
5
  • 1
    $\begingroup$ Are you familiar with Jensen’s inequality? $\endgroup$ Aug 4 at 16:33
  • $\begingroup$ I am not. I googled it, and I don't see the connection, though. $\endgroup$
    – jrheintz91
    Aug 4 at 16:36
  • 3
    $\begingroup$ The log of the mean is greater than (or equal to) the mean of the log. The operations don’t commute. Your “should” column is the former, and your program output is the latter. $\endgroup$ Aug 4 at 16:38
  • $\begingroup$ Interesting. Thanks! $\endgroup$
    – jrheintz91
    Aug 4 at 16:41
  • $\begingroup$ Many posts on site - many dozens by now I would think - address this issue (i.e. that $E[\log(X)]\neq \log(E[X])$ or issues resulting from it, and many more posts discuss the corresponding issue with nonlinear transformations $E[g(X)]\neq g(E[X])$ more generally. $\endgroup$
    – Glen_b
    Aug 5 at 4:23
5
$\begingroup$

(Expanding my comments into an answer.)

The first hint at the explanation is that your hand-computed values are always greater than what the program gave you.

The values are different because the order in which you took the log and the mean are different. The log of the mean is greater than (or equal to) the mean of the log (Jensen’s inequality). The operations don’t commute. Your “should” column is the former, and your program output is the latter.

Visualization of Jensen’s inequality: log of mean is greater than mean of log

(In the figure, we take the mean of two points for simplicity. The function f is the log function.)

$\endgroup$

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.