Video

(Video) Chi-Squared Test

by Math Meeting

Chi-squared test (χ2χ^2) is a statistical test applied to sets of categorical data (in the case of the video above the categorical variable would be the number rolled on the dice) to evaluate how likely it is that any observed difference between the sets arose by chance.

The chi-squared test is suitable for unpaired data from large samples.

x^2 = (o - e)^2/e such that o is the observed value and e is the expected value

Chi-squared formula.


Note: data is described as unpaired when the sets of data arise from different individuals, while data is paired when it arises from the same individual at different points in time.


Illustrated · 3 min

The Chi-Square Test

The Chi-Square Test is a statistical test that is used to determine any differences between sets of data. We usually use the chi-square test to assess the “goodness of fit” between our observed values and the values we would theoretically expect. The Goodness-of-Fit Test

As said before, the chi-squared test can be used in a goodness-of-fit test to test if a set of data follows a certain distribution. This measures the “goodness-of-fit” of the data to the distribution.

Let’s say that you are playing a dice game with your friends. In order to win a round, you must have the highest number in the group. However, your friend Ben decides that he is going to use his “lucky” die, rather than the die given to him. Suspicious of this “lucky” die, you decide that you’re going to record the number Ben gets on his roll. You collected the following data.

Table of data.  The columns are Value on die and Observed Frequency.  The values, row by row, are:
1, 3
2, 2
3, 4
4, 6
5, 8
6, 13
Total, 36

Image source: by Sarah Walker

With your prior math knowledge, you know that each value on the die has a 16\frac{1}{6} chance of happening. From the looks of these rolls, you think his “lucky” die might be loaded.

However, since you do not want to risk the friendship between you and Ben, you decide you want to test if the die is loaded, or if it was just chance that he rolled higher numbers most of the time. You set up a new table to begin your journey.

Table of data.  The columns are Value on die, Observed Frequency, and expected frequency.  The values, row by row, are:
1, 3, 6
2, 2, 6
3, 4, 6
4, 6, 6
5, 8, 6
6, 13, 6
Total, 36, 36

Image source: by Sarah Walker

Now, we want to hypothesize what is going to come from performing the chi-square test. You decide to give Ben the benefit of the doubt, and hypothesize that the dice are fair dice. You can write out the hypotheses as: HoH_o (Null hypothesis): The dice are fair HaH_a (Alternative hypothesis): The dice are NOT fair

In order to test the goodness-of-fit of the collected data to the expected data, we can use the chi-square statistic to get a chi-square value.

χ2=Σ(Observed Frequency – Expected Frequency)2Expected Frequency\chi^2 = \Sigma\frac{\text{(Observed Frequency – Expected Frequency)}^2}{\text{Expected Frequency}}

What this says is that we can get a chi-squared value by summing up the values of the observed frequencies minus the expected frequencies squared, divided by the expected frequency. We can create another table that looks like:

Table of data.  The columns are Value on die, Observed Frequency, Expected Frequency, (Observed - Expected)^2, and Chi-Square.  The values, row by row, are:
1, 3, 6, 9, 1.5
2, 2, 6, 16, 2.67
3, 4, 6, 4, 0.67
4, 6, 6, 0, 0
5, 8, 6, 4, 0.67
6, 13, 6, 49, 8.17
Total, 36, 36, 82, 13.68

Image source: by Sarah Walker

What we gather from this is that our χ2\chi^2 value is 13.6813.68. Now, we need to find our degrees of freedom, which is equal to the number of terms used in calculating the chi-square value. This was the total number of values on the die, so our degrees of freedom for this problem is 66.

Now, we must go to a standard table of chi-square values to look for the standard chi-square value for 66 degrees of freedom. From the table, we see that for a chi-square test with 66 degrees of freedom, our value is 12.591612.5916.

This critical value is less than our calculated chi-square value, meaning we reject our null hypothesis, HoH_o, which means that the “lucky” die does NOT follow a standard die’s expected output. Needless to say, you are not inviting Ben over for game night anymore, since the “lucky” die is actually weighted!

Summary

In order to perform a goodness-of-fit chi-square test, you must do the following:

11) Collect data

22) Establish hypotheses

33) Calculate chi-square statistic using the number of observations, expected values, and observed values

44) Use the degrees of freedom to find the tabular chi-square value

55) Decide on whether or not to accept the null hypothesis. If the calculated chi-square is larger than the tabular, we reject the null hypothesis. If the calculated chi-square is smaller than the tabular, we accept the null hypothesis.

Type a concept, like “slope” or “photosynthesis”.

↑ ↓ to choose · Enter to openSearch explanations and problems