HomeStatistics & Probability › Odds Ratio Calculator

Odds Ratio Calculator

Computes the odds ratio and relative risk of a 2×2 exposure/outcome table with confidence intervals by the log method (Woolf), plus the absolute risk difference and the number needed to treat or harm.

When to use

You have counts of events and non-events in an exposed/treated group and an unexposed/control group (case-control or cohort data, clinical trials) and need OR, RR or NNT.

Do not use when: You need a significance test for the table (use chi-square-test), the outcome is continuous (use cohens-d), or you want predictive values of a diagnostic test (use diagnostic-test).

Formula

OR = a·d / (b·c); SE(ln OR) = √(1/a + 1/b + 1/c + 1/d); CI = exp(ln OR ± z·SE). RR = (a/(a+b)) / (c/(c+d)); SE(ln RR) = √(1/a − 1/(a+b) + 1/c − 1/(c+d)); ARD = a/(a+b) − c/(c+d); NNT = 1/|ARD|

Confidence intervals use the Woolf logit method with the normal critical value. If any cell is 0, 0.5 is added to every cell (Haldane–Anscombe correction) for OR, RR and their intervals, and a note is returned. Relative risk is only meaningful for cohort or trial designs, not case-control sampling.

Inputs

ParameterTypeUnitRequiredDescription
aintegeryesExposed / treated group: number with the outcome (events). Range: ≥ 0
bintegeryesExposed / treated group: number without the outcome. Range: ≥ 0
cintegeryesUnexposed / control group: number with the outcome. Range: ≥ 0
dintegeryesUnexposed / control group: number without the outcome. Range: ≥ 0
confidence_level_percentnumber%default 95Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. Range: > 0

Outputs

OutputTypeUnitDescription
odds_rationumber(a·d) / (b·c): odds of the outcome in the exposed relative to the unexposed group.
or_ci_lowernumberLower confidence limit of the OR (log method).
or_ci_uppernumberUpper confidence limit of the OR.
relative_risknumber(a/(a+b)) / (c/(c+d)): risk in the exposed divided by risk in the unexposed (cohort / trial data only).
rr_ci_lowernumberLower confidence limit of the RR (log method).
rr_ci_uppernumberUpper confidence limit of the RR.
risk_exposednumbera / (a + b).
risk_unexposednumberc / (c + d).
risk_differencenumberrisk_exposed − risk_unexposed (positive = exposure increases risk).
nntnumber1 / |risk_difference|: people to treat (benefit) or expose (harm) for one additional outcome; conventionally rounded up. Omitted when the risks are equal.
nnt_typestring'NNT (benefit)' when the exposure lowers risk, 'NNH (harm)' when it raises it.
interpretationstringDirection of the association and whether the OR interval excludes 1.

Example

Exposed 20/100 events, unexposed 10/100: {"a":20,"b":80,"c":10,"d":90}{"odds_ratio":2.25,"or_ci_lower":0.9943,"or_ci_upper":5.0915,"relative_risk":2,"rr_ci_lower":0.9866,"rr_ci_upper":4.0545,"risk_exposed":0.2,"risk_unexposed":0.1,"risk_difference":0.1,"nnt":10,"nnt_type":"NNH (harm)"}

Treatment 15/100 events vs control 30/100: {"a":15,"b":85,"c":30,"d":70}{"odds_ratio":0.4118,"or_ci_lower":0.2053,"or_ci_upper":0.8258,"relative_risk":0.5,"rr_ci_lower":0.2872,"rr_ci_upper":0.8704,"risk_difference":-0.15,"nnt":6.7,"nnt_type":"NNT (benefit)"}

GET https://tttkmbb.com/api/v1/calculate/odds-ratio?a=20&b=80&c=10&d=90

Machine access

Sources

FAQ

Odds ratio or relative risk?

RR is easier to interpret but requires knowing the risks, so it is valid for cohort studies and trials; case-control studies can only estimate the OR. The OR approximates the RR when the outcome is rare (below about 10 %).

How do I read the confidence interval?

If the OR (or RR) interval includes 1, the association is not statistically significant at the chosen level; the interval width shows the precision of the estimate.

Related calculators