The Chi-Square Test

What is a Chi-square test?

A Chi-square test is a hypothesis testing method. Two common Chi-square tests involve checking if observed frequencies in one or more categories match expected frequencies.

Is a Chi-square test the same as a χ² test?

Yes, χ is the Greek symbol Chi.

What are my choices?

If you have a single measurement variable, you use a Chi-square goodness of fit test. If you have two measurement variables, you use a Chi-square test of independence. There are other Chi-square tests, but these two are the most common.

Types of Chi-square tests

You use a Chi-square test for hypothesis tests about whether your data is as expected. The basic idea behind the test is to compare the observed values in your data to the expected values that you would see if the null hypothesis is true.

There are two commonly used Chi-square tests: the Chi-square goodness of fit test and the Chi-square test of independence. Both tests involve variables that divide your data into categories. As a result, people can be confused about which test to use. The table below compares the two tests.

Visit the individual pages for each type of Chi-square test to see examples along with details on assumptions and calculations.

Table 1: Choosing a Chi-square test


Chi-Square Goodness of Fit Test

Chi-Square Test of Independence

Number of variablesOneTwo
Purpose of testDecide if one variable is likely to come from a given distribution or notDecide if two variables might be related or not
ExampleDecide if bags of candy have the same number of pieces of each flavor or notDecide if movie goers' decision to buy snacks is related to the type of movie they plan to watch
Hypotheses in example

Ho: proportion of flavors of candy are the same

Ha: proportions of flavors are not the same

Ho: proportion of people who buy snacks is independent of the movie type

Ha: proportion of people who buy snacks is different for different types of movies

Theoretical distribution used in testChi-SquareChi-Square
Degrees of freedom

Number of categories minus 1

  • In our example, number of flavors of candy minus 1

Number of categories for first variable minus 1, multiplied by number of categories for second variable minus 1

  • In our example, number of movie categories minus 1, multiplied by 1 (because snack purchase is a Yes/No variable and 2-1 = 1)


How to perform a Chi-square test

For both the Chi-square goodness of fit test and the Chi-square test of independence, you perform the same analysis steps, listed below. Visit the pages for each type of test to see these steps in action.

  1. Define your null and alternative hypotheses before collecting your data.
  2. Decide on the alpha value. This involves deciding the risk you are willing to take of drawing the wrong conclusion. For example, suppose you set α=0.05 when testing for independence. Here, you have decided on a 5% risk of concluding the two variables are independent when in reality they are not.
  3. Check the data for errors.
  4. Check the assumptions for the test. (Visit the pages for each test type for more detail on assumptions.)
  5. Perform the test and draw your conclusion.

Both Chi-square tests in the table above involve calculating a test statistic. The basic idea behind the tests is that you compare the actual data values with what would be expected if the null hypothesis is true. The test statistic involves finding the squared difference between actual and expected data values, and dividing that difference by the expected data values. You do this for each data point and add up the values.

Then, you compare the test statistic to a theoretical value from the Chi-square distribution. The theoretical value depends on both the alpha value and the degrees of freedom for your data. Visit the pages for each test type for detailed examples.

Back to Top