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.
Glossary
Contingency Table

What is a Contingency Table?
A contingency table is the foundational matrix for analyzing the relationship between two categorical variables in clinical research.
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.
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.
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.
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.
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)² / expectedacross 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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The contingency table is the fundamental building block for epidemiological statistics. These related terms define the measures, tests, and biases directly derived from or interacting with this cross-tabulation matrix.
Odds Ratio
A measure of association derived directly from a 2x2 contingency table. It quantifies the odds that an outcome will occur given a particular exposure, compared to the odds of the outcome occurring without that exposure. In a case-control study, the odds ratio estimates the relative risk when the disease is rare. Calculation: (a/b) / (c/d), where 'a' and 'c' are exposed cases and controls, and 'b' and 'd' are unexposed cases and controls.
Chi-Squared Test
A statistical hypothesis test that evaluates whether there is a significant association between the two categorical variables displayed in a contingency table. It compares the observed frequencies in each cell to the expected frequencies under the null hypothesis of independence. A significant p-value indicates the variables are likely dependent, though it does not measure the strength of the association.
Confounding Variable
An extraneous variable that correlates with both the exposure and the outcome, potentially creating a spurious association within a contingency table. If not controlled for through stratified analysis or regression, a confounder can distort the true relationship. The Mantel-Haenszel procedure is a classic method for calculating an adjusted odds ratio across stratified contingency tables to remove this bias.
Fisher's Exact Test
An alternative to the chi-squared test used when sample sizes are small. It calculates the exact probability of observing a specific distribution of frequencies in a 2x2 contingency table, given fixed marginal totals. This test is essential when any expected cell frequency is less than 5, a scenario where the chi-squared approximation becomes unreliable.
Propensity Score Matching
A quasi-experimental technique used to balance observed covariates between treatment and control groups before constructing a contingency table. By matching subjects with similar propensity scores—the probability of receiving treatment given observed covariates—researchers aim to mimic randomization and reduce selection bias, allowing for a less confounded calculation of the treatment effect.
Sensitivity and Specificity
Key performance metrics for a binary classification test, calculated from a 2x2 contingency table that cross-tabulates predicted outcomes against actual outcomes. Sensitivity (True Positive Rate) measures the ability to correctly identify positives. Specificity (True Negative Rate) measures the ability to correctly identify negatives. These metrics are foundational for evaluating diagnostic models in federated clinical analytics.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us