Biostatistics Study NotesFrom concepts and derivations to interpretation

CHAPTER 05 · TOPIC 03

Contingency Tables, Odds Ratios, and Relative Risks

Read 2×2 tables in context and estimate odds ratios, relative risks, and their log-scale confidence intervals.

On this page
  1. Structure of 2×2 contingency table
  2. Joint Probability, Conditional Probability, and Independence
  3. Study Design Determines Interpretation
  4. Odds and the Odds Ratio
  5. Estimate the OR on a logarithmic scale
  6. Risk and Relative Risk
  7. Estimate RR on a logarithmic scale
  8. Difference Between OR and RR
  9. Why the Log-Scale Variance Formulas Work: The Delta Method
  10. Zero Cells and Small Samples
  11. Reporting in Practice

A contingency table (crosstab) organizes two or more categorical variables at the same time. In particular, the 2 × 2 table is the basic form for quantifying the direction and magnitude of an association through odds ratios (ORs) and relative risks (RRs) as well as tests of independence.

Structure of 2×2 contingency table#

With result Y=1No result Y=0total
Exposure X=1ABA+B
No exposure X=0CDC+D
totalA+CB+DN

A to D are cell frequencies that satisfy the simultaneous condition, and the sum of rows and columns is the marginal frequency. Although it is optional to place one in a row and one in a column, the numerator/denominator and interpretation of the effect size depend on the arrangement, so the definition should be clearly stated.

Joint Probability, Conditional Probability, and Independence#

equal conditional probabilitiesP(Y=1X=1)=P(Y=1X=0)=PYP(Y=1\mid X=1)=P(Y=1\mid X=0)=P_Y
Definition of independenceP(X=i,Y=j)=P(X=i)P(Y=j)P(X=i,Y=j)=P(X=i)P(Y=j)

Study Design Determines Interpretation#

designSampling criteriaQuantities that are easy to estimate directly
Cohort/randomized trialTracking from exposure/intervention groupRisk, RR, risk difference, OR
case control studyExtract based on presence/absence of resultsOR (Generally, risk and RR cannot be directly estimated)
cross-sectional studyMeasure exposure and outcomes at a single point in timePrevalence ratio/OR

Even with the same four numbers, the meaning of the denominator changes depending on who is extracted from which population. Check the research design before looking at the calculation formula.

Odds and the Odds Ratio#

odds of probability podds=p1p\operatorname{odds}=\frac{p}{1-p}
Odds ratio between exposed and unexposed groupsOR=A/BC/D=ADBCOR=\frac{A/B}{C/D}=\frac{AD}{BC}

OR=1 indicates no association, OR>1 indicates higher odds of outcome in the exposed group, and OR<1 indicates lower odds. For example, OR=2 is not twice the probability, but twice the odds.

Estimate the OR on a logarithmic scale#

log odds ratiolog(OR)=logA+logDlogBlogC\log(OR)=\log A+\log D-\log B-\log C
approximate varianceVar[log(OR)]1A+1B+1C+1D\operatorname{Var}[\log(OR)]\approx\frac1A+\frac1B+\frac1C+\frac1D
standard errorSE[log(OR)]=1A+1B+1C+1DSE[\log(OR)]=\sqrt{\frac1A+\frac1B+\frac1C+\frac1D}
test statisticZ=log(OR)SE[log(OR)]Z=\frac{\log(OR)}{SE[\log(OR)]}
CI1α(OR)=exp{log(OR)±z1α/2SE[log(OR)]}CI_{1-\alpha}(OR)=\exp\left\{\log(OR)\pm z_{1-\alpha/2}SE[\log(OR)]\right\}

Risk and Relative Risk#

Risk of exposure groupR1=AA+BR_1=\frac{A}{A+B}
Risk for unexposed groupR0=CC+DR_0=\frac{C}{C+D}
relative riskRR=R1R0=A/(A+B)C/(C+D)RR=\frac{R_1}{R_0}=\frac{A/(A+B)}{C/(C+D)}

RR=1 is equal risk, RR=2 is twice the risk of the exposed group, and RR=0.5 is half the risk. It is naturally interpreted in cohort studies and trials where the follow-up period and denominator can be defined.

Estimate RR on a logarithmic scale#

Approximate variance of log relative riskVar[log(RR)](1A1A+B)+(1C1C+D)\operatorname{Var}[\log(RR)]\approx\left(\frac1A-\frac1{A+B}\right)+\left(\frac1C-\frac1{C+D}\right)
standard errorSE[log(RR)]=(1A1A+B)+(1C1C+D)SE[\log(RR)]=\sqrt{\left(\frac1A-\frac1{A+B}\right)+\left(\frac1C-\frac1{C+D}\right)}
test statisticZ=log(RR)SE[log(RR)]Z=\frac{\log(RR)}{SE[\log(RR)]}
CI1α(RR)=exp{log(RR)±z1α/2SE[log(RR)]}CI_{1-\alpha}(RR)=\exp\left\{\log(RR)\pm z_{1-\alpha/2}SE[\log(RR)]\right\}

Difference Between OR and RR#

itemORRR
amount to compareoddsrisk (probability)
unrelated value11
case control studyEstimableUsually not directly estimated
rare resultsApproximate to RRdirect
If the result is not rareIt tends to appear larger than RR in the direction away from 1.Clinical interpretation is relatively intuitive
p0p1ppORRRp\approx0\quad\Longrightarrow\quad\frac{p}{1-p}\approx p\quad\Longrightarrow\quad OR\approx RR

Why the Log-Scale Variance Formulas Work: The Delta Method#

The variance of a nonlinear function is found by a first-order approximation near the estimated value. This is the basis of the log standard error of OR/RR.

Var[f(X)][f(μ)]2Var(X)\operatorname{Var}[f(X)]\approx[f'(\mu)]^2\operatorname{Var}(X)

Since the derivative of log(x) is 1/x, the logarithmic variance of the counts is approximately 1/x. When we add and subtract independent logarithmic cell frequencies, the variances add up and we get 1/A+1/B+1/C+1/D of log(OR). In RR, since the numerator and denominator in the same row are shared, covariance is taken into consideration, and −1/(A+B) and −1/(C+D) appear.

Zero Cells and Small Samples#

If any cell is 0, the normal OR or log standard error will be infinite or undefined. Since mechanical 0.5 addition can change the estimation target, we will consider the exact method, conditional estimation, penalized logistic regression, etc. depending on the purpose, and specify the method to be adopted.

Reporting in Practice#

  1. Specify row/column definitions, target population, and research design
  2. Check the four cells and marginal frequencies, and indicate how to handle missing values.
  3. Select OR, RR, and risk difference if necessary to suit your design and purpose.
  4. Report point estimates and 95% confidence intervals
  5. Explain not only the p-value of the independence test, but also the direction, magnitude, and clinical significance of the effect.
  6. Describes limitations of small samples, zero cells, confounding, and selection bias.