Odds ratios using Python statsmodels

Viewed 356

I'm running logistic regressions using statsmodels logit and, downstream, am calculating odds ratios for each independent variable (i.e., exp(B)).

I know that, conventionally, an odds ratio is interpreted per "one unit" increase in the value of the variable. I think my ultimate question is how can I know what "one unit" really is here, and if it depends upon the precision of the data for the relevant column.

One parameter, respiratory_rate, has values in integers (22, 26, 30, 12, etc.). So I can assume a one unit increase in respiratory_rate would be one whole number.

However, a second parameter, temperature, has values with decimal points to the tenths place (97.8, 98.4, 99.5, 100.3, etc.). Here, for the odds ratio for temperature, is the "one unit increase" an increase in tenths, i.e., an increase of 0.1?

(I thought this could potentially be specific to the regression engine, i.e. statsmodels, hence why I posted here vs. stats.stackexchange)

1 Answers

Simple answer is 1 unit corresponds to 1 degree change in temperature. Whole number unit changes still apply as they would in respiratory_rate, you just happen to have additional precision with your temperature variable. An OR = 2.75 implies that for a 1 unit increase in temperature (1 degree), the odds of your outcome increases by a factor of 2.75.

Now, maybe it's important for your audience to actually understand temperature changes in one-tenth degree variations (i.e. 0.1 increase from 100.1 to 100.2). They may need that level of precision because even slight changes in temperature are particularly meaningful, I don't know.

But to accommodate the new context, you need to transform the log odds directly. The log odds is just the log of the odds ratio.

To do this out, make sure you have numpy imported as np. Now let's say our OR = 2.75. np.log(2.75) = 1.014. To interpret in one-tenth the normal unit (i.e. degree changes of 0.1), we would then take 1.014 * 0.1 = 0.1014 (your new log odds). Then transform this back to your odds ratio: np.exp(0.1014) = new OR = 1.1067.

So you can say 1 of 2 things here:

  • For a 1 unit increase in temperature (1 degree), the odds of your outcome increases by a factor of 2.75.
  • For a 0.1 unit increase in temperature (0.1 degree), the odds of your outcome increases by a factor of 1.11.

Check out this article about halfway down for more information: https://online.stat.psu.edu/stat462/node/207/

Related