TOPICS
Search

Contingency Table


A contingency table, sometimes called a two-way frequency table, is a tabular mechanism with at least two rows and two columns used in statistics to present categorical data in terms of frequency counts. More precisely, an r×c contingency table shows the observed frequency of two variables, the observed frequencies of which are arranged into r rows and c columns. The intersection of a row and a column of a contingency table is called a cell.

gendercupconesundaesandwichother
male5923002042480
female4103351802055

For example, the above contingency table has two rows and five columns (not counting header rows/columns) and shows the results of a random sample of 2200 adults classified by two variables, namely gender and favorite way to eat ice cream (Larson and Farber 2014). One benefit of having data presented in a contingency table is that it allows one to more easily perform basic probability calculations, a feat made easier still by augmenting a summary row and column to the table.

gendercupconesundaesandwichothertotal
male59230020424801200
female41033518020551000
total1002635384441352200

The above table is an extended version of the first table obtained by adding a summary row and column. These summaries allow easier computation of several different probability-related quantities. For example, the estimated probability that a person in the sampled population prefers ice cream in a cup is 1002/2200 approx 45.54%, while the estimated probability that a random participant is female is 1000/2200 approx 45.45%. Computing conditional probabilities is also made easier using contingency tables. For example, the probability that a person prefers ice cream sandwiches given that the person is male is 24/1200=2%, while the conditional probability that a person is male given that ice cream sandwiches are preferred is 24/44 approx 54.54%.

Other common statistical analyses can be performed on data given in contingency table form. Let R_r be the total of row r, C_c the total of column c, and n the sample size. The expected frequency E_(r,c) of the cell at their intersection under independence is

 E_(r,c)=(R_rC_c)/n.
(1)

Computing E_(1,1) says that the value one would expect at cell (1,1)--i.e., the expected number of men who prefer to eat ice cream from a cup--is approximately

 E_(1,1)=(1200·1002)/(2200) approx 546.54,
(2)

so the observed count 592 is greater than the expected count under independence. Knowing E_(1,1) also gives E_(2,1) without repeated application of (1):

 E_(2,1)=(total people who prefer cups)-E_(1,1) approx 1002-546.54=455.46.
(3)

One of the major benefits of computing expected frequencies is the ability to test whether the two variables being examined--in this case, gender and favorite way to eat ice cream--are independent. This is done by computing, for each cell (r,c), the expected frequency E=E_(r,c), comparing it to the observed frequency O=O_(r,c), and then performing a chi-squared test. For an R×C table, the Pearson statistic is

 X^2=sum_(r=1)^Rsum_(c=1)^C((O_(r,c)-E_(r,c))^2)/(E_(r,c)).
(4)

Under the null hypothesis of independence and the usual large-sample conditions, X^2 has approximately a chi-squared distribution with (R-1)(C-1) degrees of freedom. Its upper-tail probability is the P-value for the chi-squared test. Individual cell frequencies can also be divided by the sample size to estimate cell probabilities, with uncertainty summarized by an appropriate confidence interval under a binomial distribution or multinomial distribution model.

Another common test associated with contingency tables is the homogeneity of proportions test, a form of chi-squared test used to determine whether several proportions are equal when samples are taken from different populations (Larson and Farber 2014). The usual large-sample rule of thumb for these chi-squared approximations calls for randomly selected observations and expected frequencies of at least 5 in each cell. These tests play important roles throughout various branches of statistics.


See also

Categorical Variable, Chi-Squared Distribution, Chi-Squared Test, Conditional Probability, Confidence Interval, Frequency Distribution, Independent Events, P-Value, Probability, Sample, Statistics, Variable

Portions of this entry contributed by Christopher Stover

Explore with Wolfram|Alpha

References

Larson, R. and Farber, B. Elementary Statistics: Picturing the World, 6th ed. Indianapolis: Pearson Higher Education, 2014.Triola, M. F. Elementary Statistics, 11th ed. Boston: Addison-Wesley, 2011.

Referenced on Wolfram|Alpha

Contingency Table

Cite this as:

Weisstein, Eric W., with contributions by Christopher Stover. "Contingency Table." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/ContingencyTable.html

Subject classifications