# Contingency Table: A Measure of Association

Contingency tables (also called two-way frequency tables or crosstabs or cross-tabulations) are used to find the relationship (association or dependencies) between two or more variables measured on the nominal or ordinal measurement scale.

A contingency table contains R rows and C columns measured, the order of contingency table is $R \times C$. There should be minimum of 2 (categories in row variable without row header) and 2 (categories in column variable without column header).

A cross table is created by listing all the categories (groups or levels) of one variable as rows in the table and the categories (groups or levels) of other (second) variable as columns, and then joint (cell) frequency (or counts) for each cell. The cell frequencies are totaled across both the rows and the columns. These totals (sums) are called marginal canadian pharmacy king frequencies. The sum (total) of columns sums (or rows sum) can be called a grand total and must be equal to $N$. The frequencies or counts in each sell is the observed frequency.

The next step in calculating the Chi-square statistics is the computation of the expected frequency for each cell of the contingency table. The expected values of each cell are computed by multiplying the marginal frequencies of the row and marginal frequencies of the column (row sums and columns sums are multiplied) and then divided by the total number of observations (grand total, $N$). It can be formulated as
$Expected\,\, Frequency = \frac{(Row\,\, Total \,\, * \,\, Column\,\, Total)}{ Grand \,\, Total}$

The same procedures is used to compute the expected frequencies for all the cells of the contingency table.

The next step related to computation of amount of deviation or error for each cell. for this purpose the subtract the expected cell frequency from the observed cell frequency for each cell. The Chi-square statistic is computed by squaring the difference and then dividing the square of the difference by the expected frequency for each cell.

Finally the aggregate Chi-square statistic is computed by summing the Chi-square statistic. For formula is,
$\chi^2=\sum_{i=1}^n \frac{\left(O_{if}-E_{ij}\right)^2}{E_{ij}}$

The $\chi^2$ table value, the degrees of freedom and level of significance is required. The degrees of freedom for a contingency table is computed as
$df=(number\,\, of \,\, rows – 1)(number \,\, of \,\, columns -1)$.

For further detail about the contingency table and its example about how to compute expected frequencies and Chi-Square statistics, see the video lecture 