Why Build the Interval on the Log Scale?
An odds ratio compares the odds of an outcome in one group with the odds in another. Its estimate is positive and can range from nearly zero to arbitrarily large values, so an interval built directly by adding and subtracting a margin of error can be awkward: it might even have a negative lower endpoint. Taking the logarithm changes the ratio into a difference, gives a standard large-sample standard error, and makes a symmetric interval practical. The final step is to exponentiate the interval endpoints to return to the odds-ratio scale.
This tutorial considers two independent groups and a binary outcome, such as whether a hypothetical participant experiences an event. The groups could be assigned treatments or arise from a comparison of existing groups; the odds ratio describes their association with the outcome, not by itself a causal effect.
Four Counts and the Odds Ratio
Let \(a\) and \(b\) be the numbers with and without the outcome in group 1, and let \(c\) and \(d\) be the corresponding counts in group 2. Each group total is fixed by its two counts: \(n_1=a+b\) and \(n_2=c+d\). The odds of the outcome in group 1 are \(a/b\), and those in group 2 are \(c/d\).
The comparison order matters: \(\widehat{OR}\) here is group 1 odds divided by group 2 odds. Reversing the groups gives the reciprocal, \(1/\widehat{OR}\). An odds ratio of 1 means equal odds; a value above 1 means greater estimated odds in group 1, and a value below 1 means lower estimated odds in group 1.
Worked Example: Calculating an Odds Ratio
Suppose a hypothetical comparison records the outcome for 300 people in group 1 and 300 in group 2. In group 1, 90 have the outcome and 210 do not; in group 2, 60 have it and 240 do not. Estimate the odds ratio, with group 1 in the numerator.
The estimated odds are \(90/210\) in group 1 and \(60/240\) in group 2. Therefore,
The estimated odds of the outcome in group 1 are about 1.714 times the estimated odds in group 2. The log estimate should be calculated from the unrounded ratio: \(\log(\widehat{OR})=\log(12/7)\approx0.5390\). Using an unrounded value avoids small discrepancies caused by taking a logarithm of an already rounded ratio.
Deriving the Standard Error
The standard error describes the sampling variability of the log odds ratio estimate. To derive it, assume each group is an independent sample and the outcome for each individual is binary. Within group \(i\), the number of outcomes has a binomial model with sample size \(n_i\) and population probability \(p_i\). Thus the sample proportion \(\hat p_i\) has approximate variance \(p_i(1-p_i)/n_i\).
The estimated log odds in a group can be written as the logit of its sample proportion, \(g(\hat p_i)=\log\{\hat p_i/(1-\hat p_i)\}\). The derivative of \(g(p)=\log\{p/(1-p)\}\) is \(g'(p)=1/\{p(1-p)\}\). The delta method says that, for a smooth function of an estimate, its approximate variance is the variance of the estimate multiplied by the square of the function’s derivative. Applying it here gives the following approximation:
Replace the unknown probability \(p_i\) by the observed proportion \(x_i/n_i\), where \(x_i\) is the number with the outcome. Since \(n_i-x_i\) is the number without it, the estimated variance becomes
The log odds ratio is the group 1 log odds minus the group 2 log odds. Because the groups are independent, the estimated variances of these two log odds add. Substituting the four cell counts gives the standard error formula.
Constructing and Interpreting the Confidence Interval
Under the large-sample approximation, the estimate \(\log(\widehat{OR})\) is approximately normally distributed around the population log odds ratio \(\log(\theta)\), with estimated standard error given above. For a confidence level \(C\), let \(z^*\) be the standard normal critical value with central area \(C\). The confidence interval on the log scale is the estimate plus or minus \(z^*\) standard errors.
The exponential function is increasing, so exponentiating the lower and upper log-scale endpoints preserves their order and gives a confidence interval for \(\theta\). A 95% interval uses \(z^*\approx1.96\). The resulting interval is generally asymmetric around \(\widehat{OR}\), even though the interval on the log scale is symmetric around \(\log(\widehat{OR})\).
Label the outcome and no-outcome counts \(a,b\) for group 1 and \(c,d\) for group 2. This fixes the direction of the odds ratio.
Compute \(\widehat{OR}=ad/(bc)\), then calculate \(\log(\widehat{OR})\) and the four-count standard error.
Add and subtract \(z^*SE\) from \(\log(\widehat{OR})\) to obtain the lower and upper endpoints.
The exponentiated values are the lower and upper confidence limits for the odds ratio. Interpret them in the stated group order.
Worked Example: A 95% Confidence Interval
Use the hypothetical counts from the first example: \(a=90\), \(b=210\), \(c=60\), and \(d=240\). Construct and interpret a 95% confidence interval for the population odds ratio comparing group 1 with group 2. Suppose the independent groups and binary outcomes described above are appropriate, and assume the counts are large enough for the large-sample approximation.
The estimated odds ratio is \(12/7\), so its unrounded log estimate is \(\log(12/7)\approx0.5390\). The estimated standard error is
For 95% confidence, use \(z^*=1.96\). The margin of error on the log scale is \(1.96(0.1916)\approx0.3755\), giving endpoints \(0.5390-0.3755=0.1635\) and \(0.5390+0.3755=0.9145\), to the displayed precision. Exponentiating both endpoints gives
The interval estimates that the population odds of the outcome in group 1 are between about 1.178 and 2.496 times the population odds in group 2. In repeated sampling under the stated conditions, this method produces intervals that contain the population odds ratio about 95% of the time. It does not mean that there is a 95% probability that this particular fixed population parameter lies in the calculated interval.
Worked Example: An Estimated Odds Ratio Below One
In a second hypothetical comparison, group 1 has 18 outcomes and 82 non-outcomes, while group 2 has 36 outcomes and 64 non-outcomes. Construct a 95% confidence interval for the odds ratio comparing group 1 with group 2. Assume the samples are independent, the outcome is binary, and the observed counts support the large-sample approximation.
The sample odds ratio and its logarithm, calculated without rounding the ratio first, are
The standard error is
The 95% margin is \(1.96(0.3334)\approx0.6535\). Thus the log-scale endpoints are approximately \(-0.9410-0.6535=-1.5944\) and \(-0.9410+0.6535=-0.2875\). Exponentiating gives
The estimated odds in group 1 are lower than those in group 2, and the interval expresses the uncertainty around that comparison in the same group order. Reversing the comparison would invert the estimate and reverse the interval endpoints after taking reciprocals; it would not change the underlying data.
Worked Example: Using a 90% Confidence Level
A third hypothetical comparison has \(a=45\), \(b=155\), \(c=30\), and \(d=170\). Assume independent groups, binary outcomes, and counts adequate for the normal approximation. Construct a 90% confidence interval for the odds ratio for group 1 relative to group 2.
The estimate is \(\widehat{OR}=(45\times170)/(155\times30)=7650/4650\approx1.6452\), and \(\log(\widehat{OR})\approx0.4978\). The standard error is
For a central 90% interval, \(z^*\approx1.645\). The margin is \(1.645(0.2606)\approx0.4286\). The log-scale limits are approximately \(0.4978-0.4286=0.0692\) and \(0.4978+0.4286=0.9265\). Therefore,
This 90% interval estimates the population odds ratio for group 1 relative to group 2. Its confidence level is lower than that of a 95% interval constructed from the same data, so its margin on the log scale is smaller.
Assumptions and Common Pitfalls
Before relying on this interval, check that the data fit the comparison being described. Each individual contributes to one group and has one binary outcome; observations within a group should be independent under the sampling or study design, and the two groups should be independent of one another. The large-sample approximation also needs enough information in each of the four cells for the log odds ratio to behave approximately normally. There is no single count cutoff that guarantees good approximation in every setting. A zero cell makes the displayed estimate or standard error undefined, and a very small cell can make the interval unstable.
- Using the wrong group order. Mixing the group 1 and group 2 cells changes the odds ratio to its reciprocal. Label the groups before calculating.
- Using an unpooled proportion-difference standard error. The formula here is for the log odds ratio and uses the reciprocals of all four cell counts. It is not the standard error for a difference in proportions.
- Exponentiating only the estimate. The confidence limits come from exponentiating both log-scale endpoints, not from adding and subtracting a margin directly on the odds-ratio scale.
- Rounding too early. Keep the odds ratio unrounded when taking its logarithm, and round the reported endpoints only after exponentiation. For example, \(\log(16/41)\approx-0.9410\); computing from a rounded odds ratio can shift the last digits.
- Treating a confidence level as a probability for this interval. The 95% statement concerns the long-run performance of the interval procedure under its assumptions, not a 95% probability that the fixed population odds ratio is inside the observed limits.
Check Your Understanding
Try these questions before moving on.
- For counts \(a=24\), \(b=76\), \(c=15\), and \(d=85\), write the sample odds ratio comparing group 1 with group 2 as a ratio of cell-count products.
- Why are the four reciprocal cell counts added in the estimated variance of the log odds ratio?
- What steps convert a log-scale confidence interval into an interval for the odds ratio?
- If the group order is reversed, how is the estimated odds ratio changed?
- Why is it incorrect to interpret a 95% confidence interval as giving a 95% probability that the fixed population odds ratio lies within the interval?