The chi-square calculator will help you conduct the goodness of fit test, also known as the chi-square test. This statistic is used when you want to determine whether your data is consistent with the expected distribution. Read on to learn how to calculate the chi-square value and use the chi-square tables to determine the quality of your data. Make sure to take a look at our p-value calculator, too!
What is the chi-square test?
Imagine that you are a teacher at high school. You grade a test, giving the marks 2 (the worst) to 5 (the best). You expect 15% of the students to obtain grade 5, 40% to obtain a 4, 30% to get a 3, and 15% to fail by getting a 2. Once you grade one class's papers, you can test how your grading differs from the intended distribution using the chi-square test calculator. It is simply a test that measures how the observed values differ from the expected ones.
How to calculate chi-square?
You can find the chi-square value using the following formula:
χ2 = (observed value - expected value)² / expected value
For example, you wanted to give 15% of your students grade 5. You ended up grading 5 out of 60 students with this highest mark. 15% of 60 students is 9 students. Hence, the chi-square value for the highest mark is
χ2 = (5 - 9)² / 9 = (-4)² / 9 = 16/9 = 1.778.
How to perform the chi-square test for the goodness of fit?
The test statistic for the goodness of fit chi-square test is the sum of chi-square values that appear in the distribution in question. Hence, in our case, for all possible marks.
Once you have this sum, you can use the: there are two different factors in such a table:
Degrees of freedom: Number of levels of the analyzed variable minus one. For instance, in our grading example, we have four levels (grades 2, 3, 4, and 5). Hence, the number of degrees of freedom is equal to 3. If you're not yet familiar with this notion, take a look at the degrees of freedom calculator.
Significance level: it is denoted as a subscript next to the symbol χ2. This is the probability of rejecting your hypothesis when it was in fact true. The higher this risk is, the more extreme data is accepted as still valid.
Using chi-square calculator: an example
Let's analyze the situation with paper grading in greater detail. Let's say you have 60 students and graded them in the following way: five received a 5, twenty-two a 4, twenty-six a 3, and seven a 2.
- Calculate how many students were expected to receive each grade according to the planned distribution.
- Grade 2: 0.15 * 60 = 9
- Grade 3: 0.30 * 60 = 18
- Grade 4: 0.40 * 60 = 24
- Grade 5: 0.15 * 60 = 9
- Calculate the chi-square value for each grade.
- Grade 2:
χ2 = (5 - 9)² / 9 = 1.778
- Grade 3:
χ2 = (26 - 18)² / 18 = 3.556
- Grade 4:
χ2 = (22 - 24)² / 24 = 0.167
- Grade 5:
χ2 = (7 - 9)² / 9 = 0.444
- Sum all of the chi-square values.
χ2 = 1.778 + 3.556 + 0.167 + 0.444 = 5.945
- As we've already explained, there are 3 degrees of freedom.
- What is your significance level? We can assume that it is equal to 0.05.
- You can now use the chi-square tables to determine whether our data can be accepted as consistent with the initial distribution. For 3 degrees of freedom and significance level 0.05, chi-square's maximum permissible value is 7.815. As
χ2 = 5.945, we are in the acceptable range - the grading is not far off from the initial distribution.