What is the Chi-Square Test

Guide: Chi-Square Test

Author's Avatar

Daniel Croft

Daniel Croft is an experienced continuous improvement manager with a Lean Six Sigma Black Belt and a Bachelor's degree in Business Management. With more than ten years of experience applying his skills across various industries, Daniel specializes in optimizing processes and improving efficiency. His approach combines practical experience with a deep understanding of business fundamentals to drive meaningful change.

Have you ever found yourself drowning in a sea of data, wondering how to make sense of it all? Enter the Chi-Square Test, your reliable guide to exploring and understanding the relationships between categorical variables. Whether you’re a seasoned researcher or a newcomer curious about the realm of data analysis, this comprehensive guide aims to simplify this robust statistical method.

Here, we’ll walk you through what the Chi-Square Test is, its various types, and why it’s so widely used. We’ll also cover when to use it, how to perform it step-by-step, and how to interpret the results. Plus, we’ll delve into its limitations and assumptions to help you use it more effectively. So, strap in as we demystify the Chi-Square Test and empower you to make more informed decisions based on your data.

Table of Contents

What is the Chi-Square Test?

Think of the Chi-Square Test like a detective tool for your data. It helps you find out if two things are related or not. For example, let’s say you run a bookstore and you want to know if people who buy mystery novels are also more likely to buy coffee from your in-store café. The Chi-Square Test can help you figure that out!

In technical terms, the Chi-Square Test is used to see if there’s a significant relationship between two sets of categorical data. Categorical data is just a fancy way to say data that falls into categories or groups, like “buys mystery novels” and “buys coffee.”

The Null Hypothesis

Before you start, you set up something called a “null hypothesis,” which is your starting point. It’s like saying, “Let’s assume that buying mystery novels and buying coffee have nothing to do with each other.” The Chi-Square Test then checks if this is true or not.

Chi-Square Formula: Breaking It Down

The formula to perform this test might look a bit intimidating at first, but it’s really just a way to compare what you see in your data (observed frequencies) with what you would expect to see if there were no relationship (expected frequencies).

Here’s the formula:

Chi-Square Test Formula

Let’s break it down:

  • χ2 (Chi-Square) is what you’re trying to calculate.
  • O stands for “Observed Frequency,” which is the actual number you’ve counted. For example, how many people bought both mystery novels and coffee.
  • E is the “Expected Frequency,” the number you’d expect if there was no relationship between the two categories.
  • The symbol ∑ means to sum up or add together the calculations for each category in your data.


Imagine you observed the following in a week:

  • 30 people bought mystery novels but no coffee
  • 20 people bought both mystery novels and coffee

And you expected:

  • 25 people to buy mystery novels but no coffee
  • 25 people to buy both

The formula would look something like this for the “both” category:

Both formula

And like this for the “mystery novels but no coffee” category:

Novel no coffee formula

Chi-square example novels and coffee

By looking up this value in a Chi-Square distribution table, you can find out whether there’s a significant relationship or not.

We will cover this in more detail through the guide.

Types of Chi-Square Tests

Understanding which Chi-Square Test to use can be like choosing the right tool for a job. Different problems require different solutions. So, let’s break down the three main types of Chi-Square Tests and see what each one is good for.

1. Chi-Square Test of Independence

This test helps you find out if two things are connected or not. For example, you might want to know if the type of car someone drives is related to their likelihood of getting a parking ticket.

How to Use it?

Create a table with the observed numbers (how many people in each group got a ticket or didn’t). Then use the Chi-Square formula to see if the type of car and getting a ticket are independent or related.

2. Chi-Square Goodness-of-Fit Test

This test is like a reality check for your expectations. Let’s say you expect equal numbers of customers to visit your store each day of the week, but you want to know if what’s actually happening matches your expectations.

How to Use it?

Collect the data of customer visits for each day and compare it against what you’d expect if each day were the same. The Chi-Square Goodness-of-Fit Test will tell you if your data fits your expectations.

3. Chi-Square Test for Homogeneity

This test helps you compare different groups to see if they behave the same way. Imagine you have two factories making the same product, and you want to know if the defect rates are the same at both factories.

How to Use it?

You would collect the number of products with and without defects from both factories. Then you’d use the Chi-Square Test for Homogeneity to see if the defect rates are similar or different.


  • Chi-Square Test of Independence: Use it when you want to see if two categories are related.
  • Chi-Square Goodness-of-Fit Test: Use it to check if your data matches your expectations.
  • Chi-Square Test for Homogeneity: Use it to compare how different groups are behaving in the same categories.

These tests are like three different lenses for looking at your data, each giving you a unique perspective. Understanding when to use each type can be a powerful asset in making better decisions.

Why Use the Chi-Square Test? Understanding its Benefits

Making decisions based on data can be like finding your way through a maze; the more tools you have, the easier it is to find the right path. The Chi-Square Test is one of those invaluable tools that can help you understand your data better and make more informed decisions. Let’s delve into why this test is so beneficial.

1. Simplicity: Easy to Perform and Understand

The beauty of the Chi-Square Test is its simplicity. You don’t need to be a statistics whiz to use it. With some basic data and a few straightforward steps, you can perform the test and interpret the results.


Let’s say you’re a teacher, and you want to know if students’ grades improve when they attend extra classes. You don’t need complex software or specialized training—just a simple table comparing grades and attendance can give you a good idea.

2. Versatility: Can Be Applied in Various Fields

The Chi-Square Test is like a Swiss Army knife for data analysis. Whether you’re in healthcare, manufacturing, education, or any other field, you can use this test to explore relationships between variables.


In healthcare, you might use it to examine if a new treatment is effective across different age groups. In manufacturing, you could use it to see if machine types affect product quality.

3. Insightful: Helps in Decision-Making

Data alone is just numbers on a screen. It’s the insights you gain from the data that are valuable. The Chi-Square Test can tell you not just what is happening, but also give you clues as to why it’s happening, helping you make informed decisions.


Imagine you’re a store manager, and you find that sales of organic products are higher on weekends. Knowing this, you can decide to run weekend promotions to boost sales even further.


  • Simplicity: Even if you’re new to statistics, the Chi-Square Test is accessible and easy to grasp.
  • Versatility: Its broad applicability makes it a go-to tool for various kinds of data exploration.
  • Insightful: The test goes beyond just showing data points; it helps you understand what the data means so you can make smarter decisions.

The Chi-Square Test offers a combination of simplicity, versatility, and insight, making it a valuable addition to your toolbox for data analysis and decision-making.

When to Use the Chi-Square Test

Understanding when to use a specific tool can be just as important as knowing how to use it. The Chi-Square Test is incredibly useful, but it’s not a one-size-fits-all solution. There are specific scenarios where it shines. Let’s delve into when you should consider using the Chi-Square Test for your data analysis.

1. When You Have Categorical Data

Categorical data is information that can be sorted into groups or categories. For example, colors (red, blue, green), grades (A, B, C), or types of fruits (apple, banana, orange) are all categorical data.

Why It Matters

The Chi-Square Test is tailor-made for categorical data. If you try to use it for continuous data, like height or weight, it won’t give you accurate results.

2. When You Want to Compare Two or More Groups

Suppose you want to compare how different groups behave or respond. For instance, you might want to know if men and women prefer different types of movies or if different age groups respond differently to a marketing campaign.

Why It Matters

The Chi-Square Test lets you make these comparisons easily. It can show you if the observed differences between groups are just random variations or if they’re statistically significant.

3. When Your Sample Size is Sufficiently Large

In statistics, the bigger your sample size, the more confident you can be in your results. A general rule of thumb for the Chi-Square Test is that each category should have at least 5 observations.

Why It Matters

If your sample size is too small, the results won’t be reliable. You might think you’ve found a meaningful pattern when, in reality, you’ve just got random noise.


  • Categorical Data: The Chi-Square Test is designed for data that can be sorted into distinct categories.
  • Comparing Groups: If you’re interested in seeing how different groups stack up against each other, this is the test for you.
  • Sample Size: Make sure you have enough data to get results you can trust.

By keeping these factors in mind, you’ll be better equipped to decide if the Chi-Square Test is the right tool for your data analysis needs.

How to Perform a Chi-Square Test: A Step-by-Step Guide

Sometimes, knowing the theory behind a concept isn’t enough; you need to see it in action. So, let’s walk through a real-world example to see how to perform a Chi-Square Test from start to finish. This example will help you understand each step clearly, even if you’re new to the subject.


Imagine you work in a manufacturing unit, and there are two types of machines: Type A and Type B. You want to know if the type of machine affects the quality of the product being produced.

Step 1: Collect Data and Create a Contingency Table

First, gather your data. For simplicity, let’s say you’ve already collected it and it looks something like this:


Good Quality

Poor Quality


Machine Type A




Machine Type B








Step 2: Calculate Expected Frequencies

Understanding the Formula:

The formula to calculate the expected frequency () for each cell in the contingency table is:

E=Row Total×Column TotalGrand Total

Here’s what each term represents:

  • Row Total: The total count of all observations in the specific row.
  • Column Total: The total count of all observations in the specific column.
  • Grand Total: The total count of all observations in the entire table.

Why Do We Use This Formula?

The formula allows us to estimate how many observations we would expect in each category if the null hypothesis were true (i.e., the variables are independent). We then compare these expected frequencies to the observed frequencies to determine whether our sample data fits what we would expect under the null hypothesis.

Practical Example:

Suppose you are examining the effect of machine type on product quality. You have a 2×2 contingency table like this:

 Good QualityPoor QualityRow Total
Machine Type A401050
Machine Type B351550
Column Total7525100

To find the expected frequency () for Machine Type A producing Good Quality products, you use the formula:

Formula 3

Here, the Row Total for Machine Type A is 50, the Column Total for Good Quality is 75, and the Grand Total is 100.

You would then repeat this calculation for each of the other cells in the contingency table to get their expected frequencies.

By calculating these expected frequencies, you’re setting a baseline that you can compare with the observed frequencies. This comparison will be crucial for the Chi-Square Test, which will tell you whether the observed and expected frequencies are statistically different.

Step 3: Compute Chi-Square Value – A Detailed Explanation

Understanding the Formula:

The Chi-Square formula is:


Here’s a breakdown of each term in the formula:

  • (Chi-Square) is the test statistic we’re calculating.

  • indicates that we’re summing up values across all the categories.
  • represents the Observed Frequency for each category.

  • represents the Expected Frequency for each category.

Purpose of the Formula:

This formula measures how much the observed frequencies deviate from the expected frequencies . A high value means that the observed and expected frequencies differ significantly, suggesting that the variables are dependent.

Practical Example:

Let’s continue with the example of Machine Type and Product Quality. You have observed and expected frequencies like so:

 Good Quality (O)Poor Quality (O)Good Quality (E)Poor Quality (E)
Machine Type A401037.512.5
Machine Type B351537.512.5

To compute , you’d use the formula for each cell and then sum them up:

For Machine Type A and Good Quality:

Formula 4

For Machine Type A and Poor Quality:


…and so on for all the other categories. Finally, sum these up to get the value.


Once you calculate the value, you’ll compare it to a critical value from the Chi-Square distribution table to determine whether to reject the null hypothesis.

Step 4: Determine Degrees of Freedom – A Detailed Explanation

Understanding the Concept:

Degrees of freedom () is an important concept in statistics that refers to the number of values in the final calculation that are free to vary. In the context of the Chi-Square Test, helps us know which distribution to use for comparing our test statistic, , against a critical value.

The Formula:

The formula for calculating the degrees of freedom () in a Chi-Square Test is:

Here’s a breakdown of the terms:

  • Number of rows: The number of different categories in one variable.
  • Number of columns: The number of different categories in the other variable.

Why It’s Important:

The degrees of freedom are used to determine the critical value from the Chi-Square distribution table. This critical value is what your calculated value will be compared against to decide whether to reject the null hypothesis.

Practical Example:

In our example contingency table with Machine Type and Product Quality, we have:

  • 2 rows (Machine Type A and Machine Type B)
  • 2 columns (Good Quality and Poor Quality)

Using the formula, the degrees of freedom would be:

So for this table, we have 1 degree of freedom. This will guide us to the right row in the Chi-Square distribution table when looking up the critical value for our test.

Would you like to know how to use this degree of freedom to find the critical value, or is there another aspect you’re interested in exploring?

Step 5: Find the P-value – A Detailed Explanation

What is the P-value?

The P-value is a probability that provides a measure of the evidence against the null hypothesis. In the context of the Chi-Square Test, a smaller P-value means that there is stronger evidence against the null hypothesis, which usually suggests that our observed and expected frequencies are statistically different.

How to Calculate the P-value:

  1. Locate the Degrees of Freedom: First, find the degrees of freedom you calculated earlier. This will guide you to the correct row in the Chi-Square distribution table.

  2. Use the Chi-Square Distribution Table: With your value and degrees of freedom, consult a Chi-Square distribution table to find the corresponding P-value. Usually, tables will provide critical values for different significance levels (e.g. ). You can then compare your calculated value with these to find the P-value.

  3. Statistical Software: Alternatively, you can use statistical software to directly compute the P-value based on the value and degrees of freedom.

Degrees of Freedom (df)Significance Level (alpha = 0.05)Significance Level (alpha = 0.01)Significance Level (alpha = 0.001)

Interpreting the P-value:

  • P-value < 0.05: This is generally considered evidence that the observed frequencies are significantly different from the expected frequencies, and you may reject the null hypothesis.

  • P-value > 0.05: This suggests that there’s not enough statistical evidence to reject the null hypothesis; the observed and expected frequencies are not significantly different.

Practical Implication:

For example, if you find a value of 6.0 with 1 degree of freedom, you would look this up in a Chi-Square distribution table. If the P-value is less than 0.05, you have sufficient evidence to reject the null hypothesis, indicating that the variables in your study are likely dependent.


Data analysis can often feel like a daunting task, especially if you’re new to the field. However, tools like the Chi-Square Test make it accessible and straightforward. Throughout this guide, we’ve demystified this statistical method, breaking it down into simple terms and practical steps. Whether you’re in manufacturing, healthcare, or any sector that relies on making data-driven decisions, the Chi-Square Test offers you a reliable way to explore relationships between categorical variables.

While it’s essential to be aware of its limitations and assumptions, its benefits of simplicity, versatility, and insight make it a valuable asset in your analytical toolkit. Armed with this knowledge, you’re now ready to apply the Chi-Square Test in your own projects, gaining deeper insights and making more informed decisions.


A: The Chi-Square Test is primarily used to evaluate the relationship between two categorical variables. It helps to determine if the observed distribution of categories is statistically different from an expected distribution. This can be valuable in various fields like marketing, healthcare, and manufacturing for making data-driven decisions.

A: You should use a Chi-Square Test when you are dealing with categorical variables and you want to test their independence or compare their distributions across different groups. It’s especially useful when you have a large sample size. It’s not suitable for continuous data or when sample sizes are very small.

A: The Chi-Square Test assumes that the data is randomly sampled and that the categories are mutually exclusive. It may not provide accurate results for small sample sizes. Also, it can only be used for categorical data, not for continuous or ordinal data.

A: The P-value helps you determine the significance of your results. A P-value less than 0.05 usually indicates that there is a significant relationship between the variables being tested, allowing you to reject the null hypothesis. A P-value greater than 0.05 suggests that you fail to reject the null hypothesis and that the variables are likely independent.

A: The Chi-Square Test is widely used in various fields. In marketing, it can help test customer preferences across different groups. In healthcare, it’s used to study the association between different types of treatments and outcomes. In manufacturing, it can help assess the impact of different factors on product quality.


Picture of Daniel Croft

Daniel Croft

Daniel Croft is a seasoned continuous improvement manager with a Black Belt in Lean Six Sigma. With over 10 years of real-world application experience across diverse sectors, Daniel has a passion for optimizing processes and fostering a culture of efficiency. He's not just a practitioner but also an avid learner, constantly seeking to expand his knowledge. Outside of his professional life, Daniel has a keen Investing, statistics and knowledge-sharing, which led him to create the website learnleansigma.com, a platform dedicated to Lean Six Sigma and process improvement insights.

All Posts

Download Template

Free Lean Six Sigma Templates

Improve your Lean Six Sigma projects with our free templates. They're designed to make implementation and management easier, helping you achieve better results.

Other Guides