The chi-square test is used to test if two Categorical Variable variables are independent.
It is an example of a Hypothesis Test.
Example
- Testing if people who wear luminous vests to work are more likely to be injured more often than people who wear suits
- Testing if an equal number of people come into a shop each day
- Testing if gender has an impact on political party preference
Usage
To perform a chi-squared test:
- Formulate the hypotheses you wish to test
- Calculate the value of with the formula
- Calculate the degrees of freedom
- Use the tables to read a P-value
- Use the P-value to determine if the Null Hypothesis should be accepted or rejected.
Formula
Where
- is the actual frequency of a value
- is the expected value of the frequency
- is the number of elements in the sample space you are running the chi-squared test on
Degrees of Freedom
The degrees of freedom for a chi-squared test can be calculated as:
Where
- is the number of elements in the sample space you are running the chi-squared test on