Chi-Square Calculator

By Bogna Szyk
Last updated: Sep 03, 2020

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 out 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 statistic is

χ2 = (5 - 9)² / 9 = (-4)² / 9 = 16/9 = 1.778

What does this information mean? You can use the chi-square tables to compare this value with other ones. 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 had four levels (grades 2, 3, 4, and 5). Hence, the number of degrees of freedom is equal to 3.
  • 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.

  1. 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
  1. 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
  1. Sum all of the chi-square values. χ2 = 1.778 + 3.556 + 0.167 + 0.444 = 5.945
  2. Determine the number of degrees of freedom. In this case, we have 3 degrees of freedom.
  3. What is your significance level? We can assume that it is equal to 0.05.
  4. 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.
Bogna Szyk
People also viewed…

Benford's law

Benford's law calculator allows you to verify if your data set follows Benford's distribution of leading digits.

Snowman

The perfect snowman calculator uses math & science rules to help you design the snowman of your dreams!

Z-test

Our Z-test calculator is here to help you learn about, and perform, a one-sample Z-test.
main background