The odds ratio in logistic regression is the opposite of what it should be (created 2010-11-22).

This page is moving to a new website.

I have data in the following a table that clearly shows a positive association, but when I run a logistic regression model, the odds ratio is reported as less than 1. How can this be? Here's the table:

 x y=0 y=1
 0 90% 74%
 1 10% 26%

How can this be?

There is a natural and unavoidable ambiguity with how statistical software handles dichotomous variables. When computing odds, are you computing the odds for an event occurring or the odds against the event occurring? Even worse, if the dichotomous variable is coded "A" and "B" is it "A" that represents the event or is it "B"?

If you have a treatment group versus a control group, should you put the odds for the treatment group in the numerator and the odds for the control group in the denominator or the reverse?

There are some standards. For example, the Cochrane group codes the values so that an odds ratio less than one means that the treatment group is superior to the control group. But there is no consensus among humans on this, and even if there were, computers would not be able to read our minds and interpret the codes properly.

So computers make some arbitrary choices. One choice is to put the group with the smaller value (in alphabetical order) in the denominator and the group with the larger value in the numerator. A package that makes this choice would produce an odds ratio that is the inverse of the odds ratio that you are expecting, if you always present your table with smaller value on the top row and the larger value on the bottom row.

So you have to take a simple textbook problem, enter it into the program and see what you get. It will either be the number you expect or the inverse of the number you expect. Once you understand how the program behaves for a simple example, it should be easy to remember for more complex examples.

If you calculate the odds by hand in this program, it is 9 to 1 in favor of a zero value in the first column and approximately 3 to 1 in favor of a zero in the second column. The ratio of those odds is 9/3=3. But if your program computed the odds as 9 to 1 against the value of 1 and 3 to 1 against the value of 1, then the odds ratio is (1/9)/(1/3)=1/3.