### Statistics Knowledge Portal

A free online introduction to statistics

# 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.

### 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.