# When to use the chi-square goodness of fit test – tables, formulas and examples

The chi-square goodness of fit test is a statistical test used to determine whether there is a significant difference between the expected and observed frequencies in one or more categories. It is often applied when dealing with categorical data and is useful for assessing whether the distribution of observed categorical data differs from a theoretical or expected distribution.

### Chi-Square Goodness of Fit Test Formula:

The chi-square statistic (�2) is calculated using the following formula:

�2=∑(��−��)2��

where:

• �� is the observed frequency in category ,
• �� is the expected frequency in category ,
• indicates the sum across all categories.

### Chi-Square Goodness of Fit Test Steps:

1. Formulate Hypotheses:
• Null Hypothesis (�0): The observed frequencies are consistent with the expected frequencies.
• Alternative Hypothesis (��): There is a significant difference between the observed and expected frequencies.
2. Choose Significance Level ():
• Common choices are 0.05 or 0.01.
3. Determine Degrees of Freedom (��):
• ��=Number of Categories−1
4. Calculate Expected Frequencies:
• Based on a theoretical distribution or hypothesis.
5. Calculate Chi-Square Statistic:
• Use the formula mentioned above.
6. Compare with Critical Value or P-value:
• If using critical values, compare �2 with the critical value from the chi-square distribution table.
• If using p-values, compare the p-value with the chosen significance level.
7. Make a Decision:
• If �2 is greater than the critical value or if the p-value is less than , reject the null hypothesis.

### Example:

Let’s say you have survey data on the favorite color of people in a town and you want to test whether the distribution matches a hypothesized distribution.

• Observed Frequencies:
• Red: 25
• Blue: 30
• Green: 15
• Yellow: 10
• Expected Frequencies (Hypothesized Distribution):
• Red: 20
• Blue: 25
• Green: 20
• Yellow: 15
• Degrees of Freedom (��): ��=4−1=3 (four color categories)
• Calculate Chi-Square:
• Use the formula to calculate the chi-square statistic.
• Compare with Critical Value or P-value:
• Refer to the chi-square distribution table or use statistical software to find the critical value or p-value.
• Make a Decision:
• If the chi-square statistic is greater than the critical value or the p-value is less than the significance level, reject the null hypothesis.

The chi-square goodness of fit test is applicable when you are comparing observed and expected frequencies in categorical data, and it is crucial to ensure that the assumptions of the test are met, such as the data being independent and the expected frequencies in each category being reasonably large.