Tutorials › Statistical Theory I - Probability and Distribution Theory › Independence in Two-Way Probability Tables

Independence and Dependence · Tutorial 242 of 994

Independence in Two-Way Probability Tables

Use marginal products to check independence in finite probability tables, and apply the determinant criterion when the table has two rows and two columns.

Intermediate 9 min read

What You'll Learn

  • Identify joint cell probabilities and their row and column marginals.
  • Check independence by comparing every cell with the product of its marginals.
  • Explain why the cellwise criterion is equivalent to independence for finite-valued variables.
  • Derive and apply the determinant criterion for a two-by-two probability table.
  • Recognize why a single matching cell does not establish independence in larger tables.

Reading Independence From a Probability Table

A two-way probability table records the joint distribution of two finite-valued random variables. Its entries describe how probability is allocated across pairs of values; its row and column totals give the marginal distributions. Independence has a precise table-level meaning: every joint cell probability must equal the product of the corresponding row and column probabilities. The comparison is exact for a probability table, not a statistical test applied to observed counts.

This gives a direct way to assess independence and, for a two-by-two table, a compact equivalent test using a determinant. The key is to distinguish the probability in a cell from the marginal probabilities obtained by summing across its row and column.

Definitions and the Cellwise Criterion

Let \(X\) take values in a finite set \(\{x_1,\ldots,x_r\}\) and \(Y\) take values in a finite set \(\{y_1,\ldots,y_s\}\). Write the joint cell probabilities as \(p_{ij}=P(X=x_i,Y=y_j)\). The row totals \(r_i\) and column totals \(c_j\) are the marginal probabilities of the corresponding values.

$$ p_{ij}=P(X=x_i,Y=y_j),\qquad r_i=P(X=x_i)=\sum_{j=1}^{s}p_{ij},\qquad c_j=P(Y=y_j)=\sum_{i=1}^{r}p_{ij}. $$

All entries are nonnegative and their total is one: \(\sum_i\sum_j p_{ij}=1\). A row total or column total may be zero if its associated value has probability zero.

Definition: The finite-valued random variables \(X\) and \(Y\) are independent if, for every pair of subsets \(A\subseteq\{x_1,\ldots,x_r\}\) and \(B\subseteq\{y_1,\ldots,y_s\}\), \(P(X\in A,Y\in B)=P(X\in A)P(Y\in B)\). For a finite two-way probability table, this is equivalent to requiring \(p_{ij}=r_i c_j\) for every cell.

The cellwise statement is often the most practical form. For each cell, multiply its row total by its column total and compare the result with the cell entry. Independence holds only if all these comparisons agree. A zero row or column causes no difficulty: its cells must all be zero, and their products with the corresponding zero marginal are also zero.

Theorem: For finite-valued \(X\) and \(Y\), independence is equivalent to the cellwise factorization \(p_{ij}=r_i c_j\) for all \(i,j\).

Proof. If \(X\) and \(Y\) are independent, apply the definition to the singleton sets \(A=\{x_i\}\) and \(B=\{y_j\}\). This gives \(p_{ij}=r_i c_j\) for every cell.

Conversely, suppose this factorization holds in every cell. For any subsets \(A\) and \(B\), add the cell probabilities over the corresponding rows and columns:

$$ \begin{aligned} P(X\in A,Y\in B) &=\sum_{x_i\in A}\sum_{y_j\in B}p_{ij}\\ &=\sum_{x_i\in A}\sum_{y_j\in B}r_i c_j\\ &=\left(\sum_{x_i\in A}r_i\right) \left(\sum_{y_j\in B}c_j\right)\\ &=P(X\in A)P(Y\in B). \end{aligned} $$

The sums are finite, so the product of sums equals the double sum of the products. This verifies independence for every pair of subsets, as required. \(\square\)

Worked Example: Checking an Independent Two-by-Three Table

Suppose \(X\) has two values and \(Y\) has three. The row marginals are \(0.4\) and \(0.6\), and the column marginals are \(0.2\), \(0.5\), and \(0.3\). If the variables are independent, each cell is the product of its row and column marginals. Calculate those products and check the table.

For the first row, the three cell probabilities must be \(0.4(0.2)=0.08\), \(0.4(0.5)=0.20\), and \(0.4(0.3)=0.12\). For the second row, they must be \(0.6(0.2)=0.12\), \(0.6(0.5)=0.30\), and \(0.6(0.3)=0.18\).

\(Y=y_1\)\(Y=y_2\)\(Y=y_3\)Row total
\(X=x_1\)0.080.200.120.40
\(X=x_2\)0.120.300.180.60
Column total0.200.500.301.00

The entries sum to \(0.40+0.60=1\), and the column totals match the specified marginals. Each entry equals its row total times its column total; for example, \(0.20=0.40(0.50)\) and \(0.18=0.60(0.30)\). Therefore, \(X\) and \(Y\) are independent.

Worked Example: Detecting Dependence in a Two-by-Three Table

Consider the following joint probability table. Determine its marginals and test for independence.

\(Y=y_1\)\(Y=y_2\)\(Y=y_3\)Row total
\(X=x_1\)0.300.100.100.50
\(X=x_2\)0.100.200.200.50
Column total0.400.300.301.00

The row totals are \(0.30+0.10+0.10=0.50\) and \(0.10+0.20+0.20=0.50\). The column totals are \(0.30+0.10=0.40\), \(0.10+0.20=0.30\), and \(0.10+0.20=0.30\). These totals confirm that the entries form a probability table.

If the variables were independent, the probability in the first cell would be \(0.50(0.40)=0.20\). Its actual probability is \(0.30\), so the cellwise condition fails. The variables are dependent. A second check gives the same conclusion: the cell for \((x_1,y_2)\) is \(0.10\), whereas its marginal product is \(0.50(0.30)=0.15\).

One mismatch is enough to reject independence. There is no need to check every other cell once a failure has been found.

The Determinant Criterion for a Two-by-Two Table

When each variable has exactly two listed values, write the joint probabilities as \(a,b,c,d\), arranged so the first index indicates the row and the second indicates the column. The determinant of this matrix is \(ad-bc\). For a two-by-two probability table, independence is equivalent to this determinant being zero.

Theorem: Let a two-by-two probability table have nonnegative entries \(\begin{pmatrix}a&b\\c&d\end{pmatrix}\) with \(a+b+c+d=1\). Its two variables are independent if and only if \(ad-bc=0\).

Proof. First suppose the variables are independent. Each entry is a row marginal times a column marginal. If the row marginals are \(r_1,r_2\) and the column marginals are \(c_1,c_2\), then \(a=r_1c_1\), \(b=r_1c_2\), \(c=r_2c_1\), and \(d=r_2c_2\). Thus

$$ ad-bc=(r_1c_1)(r_2c_2)-(r_1c_2)(r_2c_1)=0. $$

For the converse, assume \(ad-bc=0\). The row and column marginals are \(a+b,c+d\) and \(a+c,b+d\), respectively. The difference between the upper-left entry and the product of its marginals is

$$ \begin{aligned} a-(a+b)(a+c) &=a-a^2-ab-ac-bc\\ &=a(1-a-b-c)-bc\\ &=ad-bc\\ &=0, \end{aligned} $$

where \(1-a-b-c=d\) follows from the total probability being one. The other three differences are

$$ \begin{aligned} b-(a+b)(b+d)&=bc-ad=0,\\ c-(c+d)(a+c)&=bc-ad=0,\\ d-(c+d)(b+d)&=ad-bc=0. \end{aligned} $$

Therefore, every cell equals the product of its row and column marginals. By the finite-table criterion, the variables are independent. \(\square\)

Worked Example: Using a Zero Determinant to Verify Independence

Consider the table

\(Y=y_1\)\(Y=y_2\)Row total
\(X=x_1\)0.180.120.30
\(X=x_2\)0.420.280.70
Column total0.600.401.00

Its determinant is \(ad-bc=(0.18)(0.28)-(0.12)(0.42)=0.0504-0.0504=0\). The determinant criterion therefore establishes independence. Direct checks confirm the result: \(0.30(0.60)=0.18\), \(0.30(0.40)=0.12\), \(0.70(0.60)=0.42\), and \(0.70(0.40)=0.28\).

Worked Example: A Nonzero Determinant Reveals Dependence

Now consider a table with entries \(a=0.40\), \(b=0.10\), \(c=0.20\), and \(d=0.30\). The entries are nonnegative and sum to \(1\). Its determinant is

\(ad-bc=(0.40)(0.30)-(0.10)(0.20)=0.12-0.02=0.10\), which is not zero. The variables are not independent.

The marginal totals are \(0.50\) and \(0.50\) for the rows, and \(0.60\) and \(0.40\) for the columns. Independence would require the upper-left cell to be \(0.50(0.60)=0.30\), but that cell is \(0.40\). This direct comparison agrees with the determinant test.

What the Tests Do—and Do Not—Tell You

The general cellwise criterion applies to a table with any finite number of rows and columns. The determinant shortcut is specific to two-by-two tables; do not use one selected two-by-two block as a substitute for checking all cells in a larger table. In a larger table, independence still requires \(p_{ij}=r_i c_j\) for every row-column pair.

A common mistake is to see one cell that matches its marginal product and conclude that the variables are independent. For example, in a larger table, one equality \(p_{ij}=r_i c_j\) verifies only that cell. Independence is a simultaneous set of equalities, one for each cell. The correction is to check every cell—or, when there is a mismatch, stop and conclude dependence.

Another useful distinction is between an exact probability table and observed counts. Here each entry is already a probability, so the factorization criterion is an exact mathematical statement. Counts from a sample are not themselves the joint distribution; apparent departures from a product of empirical margins can occur through sampling variation. Assessing such counts requires methods beyond this table-level probability criterion.

Key takeaway: For finite-valued \(X\) and \(Y\), independence means \(P(X=x_i,Y=y_j)=P(X=x_i)P(Y=y_j)\) in every cell. In a two-by-two probability table, this is equivalent to \(ad-bc=0\).

Check Your Understanding

Use the row and column marginals as well as the joint cell probabilities in your reasoning.

  1. A two-by-three table has row totals \(0.25\) and \(0.75\), and column totals \(0.20\), \(0.30\), and \(0.50\). What must its first-row entries be if the variables are independent?
  2. In a finite two-way probability table, why does one cell that fails the marginal-product check establish dependence?
  3. For a two-by-two table with entries \(a,b,c,d\), state the determinant criterion for independence.
  4. A two-by-two table has \(a=0.25\), \(b=0.25\), \(c=0.25\), and \(d=0.25\). Compute its determinant and determine whether the variables are independent.
  5. Why is the determinant shortcut not a complete independence check for a general two-by-three table?