1
$\begingroup$

I have to calculate log2 ratio for odds and don't know how to do it.

 Group A      Group B
 0.031571     0.0170071

There are occurrences of event in GroupA and Group B - I want to calculate how much Group A has this specific event compared to Group B, hence I need log2 for odds ratio.

I was thinking that such ratio should be calculated like this:

log2(GroupA/GroupB) = log2(0.031571/0.0170071) = 0.892463

However in this stackoverflow answer they calculate it like this:

(GroupA/GroupB)/log(2) = (0.031571/0.0170071)/log(2) = 2.67814

My question is - how to calculate log2 ratio; and what is the difference between these two approaches?

$\endgroup$
  • 2
    $\begingroup$ Remember that the log of a ratio is equal to the difference of the logs: $\operatorname{log}_{k}(a/b)=\operatorname{log}_{k}(a)-\operatorname{log}_{k}(b)$, where $k$ is the base ($k=2$ in your case). Maybe that helps you figuring out if this is what you want to calculate. $\endgroup$ – COOLSerdash Jun 16 '13 at 12:38
  • 1
    $\begingroup$ Apparently, in the link I gave they tried to calculate log of a ratio in awk and awk can't calculate log2(A/B) and one has to log(A/B)/log(2). $\endgroup$ – PoGibas Jun 16 '13 at 12:54
  • 1
    $\begingroup$ I added a comment to that SO answer pointing out the mistake. I think it's just a typo, but because it resulted in hugely erroneous example output, I have also downvoted that answer pending a correction. $\endgroup$ – whuber Jun 16 '13 at 14:15
7
$\begingroup$

The log odds ratio is the log of the odds ratio, not the odds ratio divided by a log. I don't know what problem the link you gave was trying to solve, but it wasn't this one. You take the log of the OR because the OR is bounded by 0 and infinity and is multiplicatively symmetric around 1; while the log(OR) is unbounded and additively symmetric around 0.

$\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.