We are often interested in whether a categorical distribution is the same in two or more groups of individuals. The categorical data in each group can be expressed as a frequency table. Combining these frequency tables into a single rectangular array gives a contingency table.

Categorical variables and groups

The raw data may be a list of values from each of several groups (as above) or the groups may be specified by a categorical variable in a single data matrix.