# Exponentiated logistic regression coefficient different than odds ratio

As I understand it, the exponentiated beta value from a logistic regression is the odds ratio of that variable for the dependent variable of interest. However, the value does not match the manually calculated odds ratio. My model is predicting stunting (a measure of malnutrition) using, amongst other indicators, insurance.

// Odds ratio from LR, being done in stata
logit stunting insurance age ... etc.
or_insurance = exp(beta_value_insurance)

// Odds ratio, manually calculated
odds_stunted_insured = num_stunted_ins/num_not_stunted_ins
odds_stunted_unins = num_stunted_unins/num_not_stunted_unins
odds_ratio = odds_stunted_ins/odds_stunted_unins


What is the conceptual reason for these values being different? Controlling for other factors in the regression? Just want to be able to explain the discrepancy.

• Are you putting additional predictors into the logistic regression model? The manually calculated odds ratio will only match the odds ratio you get out of logistic regression if you include no other predictors. – Macro Aug 24 '12 at 14:54
• That's what I figured, but wanted confirmation. That is because the result from the regression is accounting for variation in other predictors? – mike Aug 24 '12 at 15:11
• Yes, @mike. Assuming the model is correctly specified, you can interpret it as the odds ratio when the other predictors are all fixed. – Macro Aug 24 '12 at 15:13
• @Macro: would you mind restating your comment as an answer? – jrennie Aug 24 '12 at 15:39

## 2 Answers

If you're only putting that lone predictor into the model, then the odds ratio between the predictor and the response will be exactly equal to the exponentiated regression coefficient. I don't think a derivation of this result in present on the site, so I will take this opportunity to provide it.

Consider a binary outcome $Y$ and single binary predictor $X$:

$$\begin{array}{c|cc} \phantom{} & Y = 1 & Y = 0 \\ \hline X=1 & p_{11} & p_{10} \\ X=0 & p_{01} & p_{00} \\ \end{array}$$

$${\rm OR} = \frac{ p_{11} p_{00} }{p_{01} p_{10}}$$

By definition of conditional probability, $p_{ij} = P(Y = i | X = j) \cdot P(X = j)$. In the ratio, he marginal probabilities involving the $X$ cancel out and you can rewrite the odds ratio in terms of the conditional probabilities of $Y|X$:

$${\rm OR} = \frac{ P(Y = 1| X = 1) }{P(Y = 0 | X = 1)} \cdot \frac{ P(Y = 0 | X = 0) }{ P(Y = 1 | X = 0)}$$

In logistic regression, you model these probabilities directly:

$$\log \left( \frac{ P(Y_i = 1|X_i) }{ P(Y_i = 0|X_i) } \right) = \beta_0 + \beta_1 X_i$$

So we can calculate these conditional probabilities directly from the model. The first ratio in the expression for ${\rm OR}$ above is:

$$\frac{ P(Y_i = 1| X_i = 1) }{P(Y_i = 0 | X_i = 1)} = \frac{ \left( \frac{1}{1 + e^{-(\beta_0+\beta_1)}} \right) } {\left( \frac{e^{-(\beta_0+\beta_1)}}{1 + e^{-(\beta_0+\beta_1)}}\right)} = \frac{1}{e^{-(\beta_0+\beta_1)}} = e^{(\beta_0+\beta_1)}$$

and the second is:

$$\frac{ P(Y_i = 0| X_i = 0) }{P(Y_i = 1 | X_i = 0)} = \frac{ \left( \frac{e^{-\beta_0}}{1 + e^{-\beta_0}} \right) } { \left( \frac{1}{1 + e^{-\beta_0}} \right) } = e^{-\beta_0}$$

plugging this back into the formula, we have ${\rm OR} = e^{(\beta_0+\beta_1)} \cdot e^{-\beta_0} = e^{\beta_1}$, which is the result.

Note: When you have other predictors, call them $Z_1, ..., Z_p$, in the model, the exponentiated regression coefficient (using a similar derivation) is actually

$$\frac{ P(Y = 1| X = 1, Z_1, ..., Z_p) }{P(Y = 0 | X = 1, Z_1, ..., Z_p)} \cdot \frac{ P(Y = 0 | X = 0, Z_1, ..., Z_p) }{ P(Y = 1 | X = 0, Z_1, ..., Z_p)}$$

so it is the odds ratio conditional on the values of the other predictors in the model and, in general, in not equal to

$$\frac{ P(Y = 1| X = 1) }{P(Y = 0 | X = 1)} \cdot \frac{ P(Y = 0 | X = 0) }{ P(Y = 1 | X = 0)}$$

So, it is no surprise that you're observing a discrepancy between the exponentiated coefficient and the observed odds ratio.

Note 2: I derived a relationship between the true $\beta$ and the true odds ratio but note that the same relationship holds for the sample quantities since the fitted logistic regression with a single binary predictor will exactly reproduce the entries of a two-by-two table. That is, the fitted means exactly match the sample means, as with any GLM. So, all of the logic used above applies with the true values replaced by sample quantities.

• Wow, thanks for taking the time to write out such a complete explanation. – mike Aug 24 '12 at 16:35
• @Macro I found that "p-value being less than 0.05" and "95% CI does not include 1" are not consistent in logistic regression (I used SAS). Is this phenomenon related to your explanation? – user67275 Oct 25 '16 at 12:47

You have a really nice answer from @Macro (+1), who has pointed out that the simple (marginal) odds ratio calculated without reference to a model and the odds ratio taken from a multiple logistic regression model ($\exp(\beta)$) are in general not equal. I wonder if I can still contribute a little bit of related information here, in particular explaining when they will and will not be equal.

Beta values in logistic regression, like in OLS regression, specify the ceteris paribus change in the parameter governing the response distribution associated with a 1-unit change in the covariate. (For logistic regression, this is a change in the logit of the probability of 'success', whereas for OLS regression it is the mean, $\mu$.) That is, it is the change all else being equal. Exponentiated betas are similarly ceteris paribus odds ratios. Thus, the first issue is to be sure that it is possible for this to be meaningful. Specifically, the covariate in question should not exist in other terms (e.g., in an interaction, or a polynomial term) elsewhere in the model. (Note that here I am referring to terms that are included in your model, but there are also problems if the true relationship varies across levels of another covariate but an interaction term was not included, for example.) Once we've established that it's meaningful to calculate an odds ratio by exponentiating a beta from a logistic regression model, we can ask the questions of when will the model-based and marginal odds ratios differ, and which should you prefer when they do?

The reason that these ORs will differ is because the other covariates included in your model are not orthogonal to the one in question. For example, you can check by running a simple correlation between your covariates (it doesn't matter what the p-values are, or if your covariates are $0/1$ instead of continuous, the point is simply that $r\ne0$). On the other hand, when all of your other covariates are orthogonal to the one in question, $\exp(\beta)$ will equal the marginal OR.

If the marginal OR and the model-based OR differ, you should use / interpret the model-based version. The reason is that the marginal OR does not account for the confounding amongst your covariates, whereas the model does. This phenomenon is related to Simpson's Paradox, which you may want to read about (SEP also has a good entry, there is a discussion on CV here: Basic-simpson's-paradox, and you can search on CV's tag). For the sake of simplicity and practicality, you may want to just only use the model based OR, since it will be either clearly preferable or the same.