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
|Number of variables||One||Two|
|Purpose of test||Decide if one variable is likely to come from a given distribution or not||Decide if two variables might be related or not|
|Example||Decide if bags of candy have the same number of pieces of each flavor or not||Decide 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 test||Chi-Square||Chi-Square|
|Degrees of freedom|
Number of categories minus 1
Number of categories for first variable minus 1, multiplied by number of categories for second variable minus 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.
- Define your null and alternative hypotheses before collecting your data.
- 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.
- Check the data for errors.
- Check the assumptions for the test. (Visit the pages for each test type for more detail on assumptions.)
- 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.