Calculators
Odds Ratio and Relative Risk Calculator
Calculate the odds ratio and relative risk from a 2x2 exposure and outcome table locally in your browser, with 95% confidence intervals, risk difference, and interpretation.
Enter the four cells of a 2×2 exposure and outcome table. Group the counts by exposure and by outcome: a is exposed with the outcome, b is exposed without the outcome, c is unexposed with the outcome, and d is unexposed without the outcome. The calculator returns the risk in each group, the absolute risk difference, the relative risk (RR), the odds ratio (OR), and 95% confidence intervals for both. All calculations run locally in your browser; your values are not uploaded or stored. Odds ratios compare odds while relative risks compare risks; use relative risk for cohort studies and odds ratios for case-control studies, where the risk cannot be measured directly.
Compare the odds and risk of an outcome between exposed and unexposed groups.
Enter the four cells of a 2x2 table: a is exposed with the outcome, b is exposed without the outcome, c is unexposed with the outcome, and d is unexposed without the outcome. The risk in each group is outcome divided by group total, the absolute risk difference is the two risks subtracted, the relative risk (RR) is [a / (a + b)] / [c / (c + d)], and the odds ratio (OR) is (a × d) / (b × c). For example, a = 80, b = 920, c = 20, d = 980 gives risks of 8% and 2%, a risk difference of 6 percentage points, RR = 4.00, and OR = 4.26. A 95% confidence interval is computed with the log method: exp(ln(estimate) ± 1.96 × SE), where SE(OR) = sqrt(1/a + 1/b + 1/c + 1/d) and SE(RR) = sqrt(1/a − 1/(a + b) + 1/c − 1/(c + d)). A ratio above 1 means the exposure is associated with a higher outcome, below 1 means a lower outcome, and a confidence interval that excludes 1 is statistically significant at the 0.05 level. Relative risk is preferred for cohort studies, while odds ratios are used for case-control studies where risk cannot be measured directly. All calculations run locally in your browser; your values are not uploaded or stored.
Frequently Asked Questions
Everything you need to know about this tool, how it works, and privacy.
What is the difference between odds ratio and relative risk?
Relative risk (RR) compares the probability of an outcome between groups: RR = [a / (a + b)] / [c / (c + d)]. Odds ratio (OR) compares the odds: OR = (a × d) / (b × c). When the outcome is rare, OR and RR are close; when the outcome is common, the OR moves further from 1 than the RR. Use RR for cohort studies and OR for case-control studies where risk cannot be measured directly.
How do I interpret an odds ratio or relative risk?
A value of 1 means the exposure has no association with the outcome. A value above 1 means the exposure is associated with a higher outcome, and a value below 1 means a lower outcome (protective). Check the 95% confidence interval: if it excludes 1 the result is statistically significant at the 0.05 level; if it includes 1 it is not.
What do a, b, c, and d represent?
In a 2x2 table grouped by exposure and outcome: a is exposed with the outcome, b is exposed without the outcome, c is unexposed with the outcome, and d is unexposed without the outcome. The risk in the exposed group is a / (a + b) and the risk in the unexposed group is c / (c + d).
How are the 95% confidence intervals calculated?
Both intervals use the log method: exp(ln(estimate) ± 1.96 × SE). For the odds ratio SE = sqrt(1/a + 1/b + 1/c + 1/d); for relative risk SE = sqrt(1/a − 1/(a + b) + 1/c − 1/(c + d)). The intervals are not defined when a required cell is zero, because the log of zero or infinity is undefined.
Are my counts uploaded?
No. All calculations run locally in your browser. CodeASystem does not upload or store the values you enter.