Skip to content
LearnStatisticspowered by UpThink

Statistics and data science, defined

Contingency Table

A contingency table is a tabular representation of categorical data. A contingency table usually shows frequencies for particular combinations of values of two discrete random variables X and Y. Each cell in the table represents a mutually exclusive combination of X-Y values.

For example, consider a sample of N=200 beer-drinkers. For each drinker we have information on sex (variable X, taking on 2 possible values: “Male” and “Female”) and preferred category of beer (variable Y, taking on 3 possible values: “Light”, “Regular”, “Dark”). A contingency table for these data might look like the following

LightRegularDarkTotal
Male204050110
Female50202090
Total:706070200

This is a two-way 2×3 contingency table (i.e. two rows and three columns).

Sometimes three-way (and more) contingency tables are used. Suppose the beer-drinkers data, besides sex and preference, are also stratified by age group. The third discrete variable Z (“Age”) in this case might, for example, take on 4 values: “65”.

In this case we would have a three-way 2x3x4 contingency table, equivalent to 4 two-way 2×3 contingency tables (one 2×3 table for each of the 4 age-groups).

Related entries

Where this gets used

We teach data science and statistics online, one subject at a time, on fixed start dates with an instructor who marks your work.