A Chi-squared test ( test) is a statistical hypothesis test used for categorical variables. It can be seen as a generalization of the proportion test, extending its application beyond binary outcomes to multiple categories. The Chi-squared test was initially developed by Karl Pearson in 1900.

Note that Chi () is pronounced as the "ki" in "kite"

The Chi-squared test can be applied in various scenarios, including

  • Goodness-of-fit tests: To determine if an observed frequency distribution differs from a theoretical distribution.
  • Tests of independence: To assess whether there is a significant association between two categorical variables.

We test the test statistic against the chi-squared distribution. Since the distribution is always positive, the test statistic of the test is also always positive, and we will always have a one-tailed tests.

Goodness of Fit Test

The Chi-squared goodness-of-fit test has the null hypothesis that any difference between observed frequencies and the expected frequency is due to chance alone.

It has the following assumptions:

For a test with categories, the test statistic is

where is the observed frequency and is the expected frequency for category .

The degrees of freedom is .

Test for Independence

The chi-squared test for independence has the null hypothesis that there is no association between the two categorical variables. The frequencies are arranged in a 2D grid that can be visualized by a contingency table like the following:

Sleep during lectureNot sleepTotal
like class204060
dislike class202040
Total4060100

The test statistic is similar to the goodness of fit test too. If you have rows and columns,

The degrees of freedom for the distribution is .

Interesting Fact

Ronald Fisher used the tests for independence to claim that some of Gregor Mendel’s data may be too perfect to be realistic. Despite this, Fisher holds very high regard of Mendel and didn’t think he was guilty of data manipulation 1.

Footnotes

  1. Ending the Mendel-Fisher Controversy