# Calculate the confidence interval of log odds using a linear combination?

I'm performing occupancy modeling (wildlife science) to determine the difference between a change in control vs. treatment sites over time (before vs. after). I first calculated the occupancy odds from the Beta value, then calculate the odds ratio from this occupancy odds (control site after treatment/control site before treatment, and treatment site after treatment/treatment site before treatment). I want to report the confidence interval as well (and standard error would also be great). I think this should be a linear combination, but my numbers are coming out slightly off.

First I calculate the odds ratio from the beta estimate for psi (occupancy probability):

1. Before value: psi/(1-psi) = 0.6122/0.3878 = 1.58
2. After value: psi/(1-psi) = 0.6714/0.3286 = 2.04
3. Odds ratio: 2.04/1.58 = 1.29

Here's an example of how I calculated CI limits:

1. Lower CI limit of control site after treatment - Lower CI limit of control site before treatment: -0.2972 - (-0.3771) = 0.0798
2. exp(0.0798) = 1.08.
3. This should mean that the lower CI limit is 1.08.
4. Through the same calculation, I get that the Upper CI limit is 1.55.

However, when I check this by calculating the standard error, also using the linear combination, and then subtract 0.5*SE from the odds ratio, the number doesn't match:

1. Upper CI limit - Lower CI limit = 1.55-1.08 = 0.23.
2. SE = 0.23/2 = 0.115
3. Odds ratio - SE = 1.06
4. Likewise, the odds ratio + SE = 1.53. These figures are close but don't match the CI limits I calculated above.

Any insights as to why these values don't match? Or tips on mistakes I don't realize I'm making? Thanks!

• Are you doing the calculation for the odds ratio or the log-odds-ratio? The CI should only be symmetric for the latter. May 18, 2016 at 5:00
• I want the CI for the odds ratio. Please see edits I made to explain how I calculated the odds ratio for the estimate. I want to have the CI to match this figure, for example: 1.29 (95% CI: 1.08 to 1.55) or 1.29 +/- 0.23 May 18, 2016 at 12:02

## 1 Answer

Generally, the confidence interval for an odds ratio (and similarly for other relative risk measures such as hazard ratios or risk ratios) is not of the form $\text{odds ratio} \pm 1.96 \times \text{SE}$, but it is rather on the log scale that such a relationship holds for sufficiently large sample sizes. Sufficiently large typically means that sufficiently many people need to have had an event and sufficiently many not (a lot of people studied with no events observed is not sufficient). This is also explained in the Wikipedia article on the odds ratio, where the asymptotic formula for the standard error of the odds ratio is given. The odds ratio is then simply $e^\text{log-odds ratio}$ and the confidence interval for the odds ratio is similarly given by the exponentiated confidence interval limits for the log-odds ratio.

Thus, if you have results from some kind of model with a logit link function on a sufficiently large dataset that gives the regression coefficients representing log-odds ratios, I would assume you could simply exponentiate those and get confidence intervals in this manner. I do not know what software you are using, but the software should be able to estimate your contrasts of interest for you (at least on the log-odds scale) and ideally take into account any correlation between coefficients when calculating the contrast.

While, if if things were totally uncorrelated and there were no other covariates, you could probably calculate the confidence intervals directly by adding the variances (squared standard errors) on the log-odds-scale to obtain the variance of the differences on the log-odds-scale (=the log-odds-ratio) $$\text{SE log-odds-ratio}=\sqrt{(\text{SE log-odds}_\text{before})^2+(\text{SE log-odds}_\text{after})^2}$$ and confidence interval $e^{\text{log-odds-ratio} \pm 1.96 \times \text{SE log-odds-ratio}}$, this is a lot less straightforward when the estimates are from a more complex model (in which coefficients may be correlated). In any case your software should be able to do it for you without trouble.

• if the software in use is R then the glmglrt package offers convenient functions to estimate contrasts with confidence intervals in generalized linear models. Jun 5, 2023 at 17:49