Inferensys

Glossary

Contingency Table

A cross-tabulation matrix that displays the frequency distribution of two categorical variables, used as the foundational input for calculating odds ratios and performing chi-squared tests.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
CROSS-TABULATION MATRIX

What is a Contingency Table?

A contingency table is the foundational matrix for analyzing the relationship between two categorical variables in clinical research.

A contingency table is a cross-tabulation matrix that displays the multivariate frequency distribution of two or more categorical variables, serving as the foundational input for calculating odds ratios and performing chi-squared tests. In clinical analytics, it typically cross-references an exposure or treatment group against a binary outcome, such as disease presence or absence, to quantify statistical association.

Within a federated clinical analytics framework, constructing a contingency table requires a distributed query engine to aggregate counts across siled patient databases without centralizing protected health information. The resulting aggregated cell counts—true positives, false positives, true negatives, and false negatives—enable privacy-preserving computation of effect sizes and significance testing across a multi-institutional cohort.

FOUNDATIONAL STRUCTURE

Key Properties of Contingency Tables

A contingency table is a cross-tabulation matrix that displays the frequency distribution of two categorical variables. It serves as the foundational input for calculating odds ratios, performing chi-squared tests, and assessing association in federated clinical analytics.

01

Core Structure and Notation

A standard 2x2 contingency table organizes data by exposure status (rows) and outcome status (columns).

  • Cell a: Exposed individuals with the outcome
  • Cell b: Exposed individuals without the outcome
  • Cell c: Unexposed individuals with the outcome
  • Cell d: Unexposed individuals without the outcome

Marginal totals represent row and column sums, providing the denominators for risk calculations. This structure is the universal input for federated cohort discovery queries.

02

Odds Ratio Calculation

The odds ratio (OR) is the primary measure of association derived from a contingency table, calculated as (a/b) / (c/d) or equivalently ad / bc.

  • OR = 1: No association between exposure and outcome
  • OR > 1: Exposure associated with higher odds of outcome
  • OR < 1: Exposure associated with lower odds of outcome

In federated analytics, each site computes its local contingency table, and odds ratios are pooled using inverse variance weighting in a meta-analysis engine without sharing raw patient counts.

03

Chi-Squared Test of Independence

The chi-squared test evaluates whether two categorical variables are statistically independent by comparing observed frequencies to expected frequencies under the null hypothesis.

  • Expected frequency for each cell: (row total × column total) / grand total
  • The test statistic sums (observed - expected)² / expected across all cells
  • A significant p-value rejects the null hypothesis of independence

In distributed settings, federated chi-squared tests aggregate only the test statistic and degrees of freedom, preserving patient privacy.

04

Stratified Tables and Confounding Control

Stratification involves constructing separate contingency tables for each level of a potential confounding variable to isolate the true exposure-outcome relationship.

  • Mantel-Haenszel estimator computes a weighted average of stratum-specific odds ratios
  • Stratification addresses Simpson's Paradox, where aggregated results reverse direction within subgroups
  • Federated systems require each site to compute stratum-specific tables locally before secure aggregation

This is essential for observational studies where randomization is absent.

05

Federated Contingency Table Aggregation

In a cross-silo federated learning network, contingency tables are computed locally at each institution and only aggregated counts are shared with the central distributed query engine.

  • Each site executes the same computable phenotype definition to identify cohorts
  • Local 2x2 tables are transmitted through a secure aggregation protocol
  • The central node sums cell counts to construct a global contingency table

This approach complies with HIPAA and GDPR by ensuring patient-level data never leaves the originating institution.

06

Measures of Effect Size

Beyond the odds ratio, contingency tables support multiple effect size metrics for clinical interpretation.

  • Risk Ratio (RR): (a/(a+b)) / (c/(c+d)) — used in cohort studies
  • Risk Difference (RD): (a/(a+b)) - (c/(c+d)) — absolute measure of effect
  • Number Needed to Treat (NNT): 1 / RD — clinical relevance metric

In federated meta-analysis, these measures are computed from each site's table and combined using random-effects or fixed-effects models depending on heterogeneity assessment results.

CONTINGENCY TABLE CLARIFIED

Frequently Asked Questions

Clear, technical answers to the most common questions about the structure, calculation, and clinical application of contingency tables in federated analytics.

A contingency table is a cross-tabulation matrix that displays the joint frequency distribution of two or more categorical variables. In its most common 2x2 form, it organizes data into four cells representing the counts of subjects classified by an exposure (present/absent) and an outcome (present/absent). The rows typically represent the exposure status, while the columns represent the outcome status. The four cells are labeled: a (exposed with outcome), b (exposed without outcome), c (unexposed with outcome), and d (unexposed without outcome). The marginal totals—row sums and column sums—provide the overall counts for each category. This structure serves as the foundational input for calculating measures of association like the odds ratio, relative risk, and for performing chi-squared tests of independence. In federated clinical analytics, each institution computes its local contingency table from its private patient data and shares only these aggregated counts, never exposing individual-level records.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.