The ChiSquare Test
What is a Chisquare test?
A Chisquare test is a hypothesis testing method. Two common Chisquare tests involve checking if observed frequencies in one or more categories match expected frequencies.
Is a Chisquare 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 Chisquare goodness of fit test. If you have two measurement variables, you use a Chisquare test of independence. There are other Chisquare tests, but these two are the most common.
Types of Chisquare tests
You use a Chisquare 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 Chisquare tests: the Chisquare goodness of fit test and the Chisquare 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 Chisquare test to see examples along with details on assumptions and calculations.
Table 1: Choosing a Chisquare test
ChiSquare Goodness of Fit Test  ChiSquare Test of Independence  
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  H_{o}: proportion of flavors of candy are the same H_{a}: proportions of flavors are not the same  H_{o}: proportion of people who buy snacks is independent of the movie type H_{a}: proportion of people who buy snacks is different for different types of movies 
Theoretical distribution used in test  ChiSquare  ChiSquare 
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 Chisquare test
For both the Chisquare goodness of fit test and the Chisquare 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 Chisquare 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 Chisquare 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.