Contingency table

A contingency table is a table/matrix which shows the frequency of different combinations of two categorical variables.

They show the frequency of each combination - the number of times each combination occurs in the data. They don’t show the proportion or frequency.

Total rows/columns

We can add a row and column to show the total of the rows and columns in the table. That’s useful if we want to find a conditional probability from it, or to calculate the chi squared value.

The total rows and columns just show the total frequency of each category of the variables - the values in the rows and columns, all added up.

Example

Likes pelicansLikes axolotlsLikes parrots
Age < 1810515
Age 18-65201025
Age > 65+51510

The two categorical variables in this example are:

We can add up each row and column to find the row and column totals:

Likes pelicansLikes axolotlsLikes parrotsTotal
Age < 181051530
Age 18-6520102555
Age > 65+5151030
Total353050115