A

chi-square test（also calledPearson’s chi-squared test)is used to assess two types of comparison: tests of goodness of fit and tests of independence (here).The

test of independenceis applied when you have two categorical variables from a single population. It is used to determine whether there is a significant association between the two variables.

Suppose that Variable A has *r* levels, and Variable B has *c* levels. The null hypothesis states that knowing the level of Variable A does not help you predict the level of Variable B. That is, the variables are independent.

H_{0}: Variable A and Variable B are independent. H_{a}: Variable A and Variable B are not independent.

The alternative hypothesis is that knowing the level of Variable A *can* help you predict the level of Variable B (not independent).

**Expected cell count rule:** Adequate expected cell counts needed. A common rule is 5 or more in all cells of a 2-by-2 table, and 5 or more in 80% of cells in larger tables, but no cells with zero expected count. When the expected cell counts less than 5, using Fisher’s exact test instead.