# Difficulty understanding contingency table and logistic regression coefficient

I have the following contingency table

      D    not-D
E     980    122
not-E 2420  6439


where D may stand for disease, and E for exposure.

This leads to the odds ratio (OR) $$\frac{odds(D|E)}{odds(D|\bar{E})} = 21.4$$

[1] I hope that is correct?

[2] This ratio says the odds of having D given E is about 21 times the odds of having D given you do not have E i.e. having E greatly increases the chance of D?

[3] Therefore, in a logistic regression where D is the response and where E is included (amongst several other predictors) as a binary predictor variable, with $$\bar{E}$$ as the reference level, I would expect its model coefficient to be positive, so that if E is present the odds of D is greater than if E is not present?

[4] The problem I have is that the model coefficient for E is negative which I interpret to mean having E reduces the odds of having D, which contradicts what I understand the OR is telling me?

EDIT:

Using R, with some variable name changes,

 fit <- glm(D ~ x1 + x2 + x3 + x4 + xE, family = binomial, data = df) 

• Welcome to CV, PM.! Can you edit your question to indicate your software and command for your logistic regression? – Alexis Sep 27 '18 at 16:40

## 1 Answer

1. Yes
2. Yes
3. No, after adjustment for other variables, it's possible for the association to change direction. The above table is a crude odds ratio, so may be subject to bias of confounding.
4. To verify you haven't made a coding issue, fit the logistic model without adjustments and verify that the log odds ratio is log(21.4).
• Your succinctness and specificity are laudable. :) – Alexis Sep 27 '18 at 16:41
• @AdamO If I understood your suggestion correctly, I ran the fitting with xE as the only predictor variable, and obtained the coefficient 3.06214. Now, log(21.4)=3.063391 so they are equal ( subject to a bit of rounding i.e. 21.4 is the OR rounded to 1 d.p. ) – PM. Sep 27 '18 at 16:59
• @PM. great, it sounds like your other adjustments have a VERY strong correlation with both E and D if the crude OR is 21 and the adjusted OR is less than 1. I would just be sure to describe very carefully what you did, and how you selected those adjustments, when you report the findings. – AdamO Sep 27 '18 at 17:51
• @AdamO Many thanks, very helpful. I clearly have a few things to ponder and some further reading to do. – PM. Sep 28 '18 at 8:21