# Chi-Square (χ2) Statistic: What It Is, Examples, How and When to Use the Test

![Chi-Square Statistic](https://www.investopedia.com/thmb/KaQmk9a4mrB9xmK9wgELjbleL3w=/1500x0/filters:no_upscale():max_bytes(150000):strip_icc()/Chi-SquareStatistic_Final_4199464-7eebcd71a4bf4d9ca1a88d278845e674.jpg)

*— Paige McLaughlin / Investopedia*

> **Definition**
>
> Chi-square is a statistical measurement that shows how well a model fits the observed data.

## What Is a Chi-Square (χ2) Statistic?

A chi-square (_χ_) statistic is a test that compares observed data to the model and measures its fit. The data used in calculating a chi-square statistic must be random, raw, mutually exclusive, drawn from independent variables, and derived from a sufficiently large sample. For example, the results of tossing a fair coin meet these criteria.

Chi-square tests are often used to test hypotheses. The chi-square statistic compares the size of any discrepancies between the expected results and the actual results, given the size of the sample and the number of variables in the relationship.

For these tests, [degrees of freedom](https://www.investopedia.com/terms/d/degrees-of-freedom.asp) are used to determine if a certain [null hypothesis](https://www.investopedia.com/terms/n/null_hypothesis.asp) can be rejected based on the total number of variables and samples within the experiment. As with any statistic, the larger the sample size, the more reliable the results.

### Key Takeaways

*   Chi-square is useful for analyzing such differences in categorical variables, especially those nominal in nature.
*   _χ_ depends on the size of the difference between actual and observed values, the degrees of freedom, and the sample size.
*   _χ_ can be used to test whether two variables are related or independent of each other.
*   It can also be used to test the goodness of fit between an observed distribution and a theoretical distribution of frequencies.

## Formula for a Chi-Square (χ2) Statistic

﻿ $\begin{aligned}&\chi^2_c = \sum \frac{(O_i - E_i)^2}{E_i} \\&\textbf{where:}\\&c=\text{Degrees of freedom}\\&O=\text{Observed value(s)}\\&E=\text{Expected value(s)}\end{aligned}$﻿

## What a Chi-Square (χ2) Statistic Can Tell You

There are two main kinds of chi-square tests that will provide different information:

*   The test of independence, which asks a question of relationship, such as, “Is there a relationship between student gender and course choice?”
*   The goodness-of-fit test, which asks a theoretical question such as, “How well does the coin in my hand match a theoretically fair coin?”

> **Fast Fact**
>
> Chi-square analysis is applied to categorical variables and is especially useful when those variables are nominal (where order doesn’t matter, like marital status or gender).

### Test of Independence

When considering student gender and course choice, a _χ_ test for independence could be used. To do this test, the researcher would collect data on the two chosen variables (gender and courses picked) and then compare the frequencies at which male and female students select among the offered classes using the formula given above and a _χ_ statistical table.

If there is no relationship between gender and course selection (that is if they are independent), then the actual frequencies at which male and female students select each offered course should be expected to be approximately equal, or conversely, the proportion of male and female students in any selected course should be approximately equal to the proportion of male and female students in the [sample](https://www.investopedia.com/terms/s/sample.asp).

A _χ_ test for independence can tell us how likely it is that random chance can explain any observed difference between the actual frequencies in the data and these theoretical expectations.

In a test of independence, a company may want to evaluate whether its new product, an herbal supplement that promises to give people an energy boost, is reaching the people who are most likely to be interested.

It is being [advertised](https://www.investopedia.com/terms/m/marketing.asp) on websites related to sports and fitness, on the assumption that active and health-conscious people are most likely to buy it. It does an extensive poll that is intended to evaluate interest in the product by demographic group. The poll suggests no correlation between interest in this product and the most health-conscious people.

### Test of Goodness of Fit

_χ_ provides a way to test how well a sample of data matches the (known or assumed) characteristics of the larger population that the sample is intended to represent. This is known as goodness of fit.

If the sample data does not fit the expected properties of the population in which one is interested, then one would not want to use this sample to draw conclusions about the larger population.

As an example of a test of [goodness of fit](https://www.investopedia.com/terms/g/goodness-of-fit.asp), a marketing professional is considering launching a new product that the company believes will be irresistible to women over age 45. The company has conducted product testing panels of 500 potential product buyers.

The marketing professional has information about the age and gender of the test panels. This allows the construction of a chi-square test showing the [distribution](https://www.investopedia.com/terms/n/normaldistribution.asp) by age and gender of the people who said they would buy the product.

The result will show whether or not the likeliest buyer is a woman over 45. If the test shows that men over age 45 or women ages 18 to 44 are just as likely to buy the product, then the marketing professional will revise the advertising, promotion, and placement of the product to appeal to this wider group of customers.

## Example of How to Use a Chi-Square (χ2) Statistic

For example, consider an imaginary coin with exactly a 50/50 chance of [landing heads or tails](https://www.investopedia.com/terms/a/apriori.asp) and a real coin that you toss 100 times. If this coin is fair, then it will also have an equal probability of landing on either side, and the expected result of tossing the coin 100 times is that heads will come up 50 times and tails will come up 50 times.

In this case, _χ_ can tell us how well the actual results of 100 coin flips compare to the theoretical model that a fair coin will give 50/50 results. The actual toss could come up 50/50, or 60/40, or even 90/10.

The farther away the actual results of the 100 tosses are from 50/50, the less good the fit of this set of tosses is to the theoretical expectation of 50/50, and the more likely one might conclude that this coin is not actually a fair coin.

## When to Use a Chi-Square (χ2) Test

A chi-square test is used to help determine if observed results are in line with expected results and to rule out that observations are due to chance.

A chi-square test is appropriate for this when the data being analyzed is from a [random sample](https://www.investopedia.com/terms/s/simple-random-sample.asp), and when the variable in question is a categorical variable. A categorical variable consists of selections such as type of car, race, educational attainment, male or female, or how much somebody likes a political candidate (from very much to very little).

These types of data are often collected via survey responses or questionnaires. Therefore, chi-square analysis is often most useful in analyzing this type of data.

> **Fast Fact**
>
> The chi-square test is most effective with a sufficiently large sample size. The expected frequency for each cell should be at least 1, and greater than 5 for the majority (80%+) of the cells.

## How to Perform a Chi-Square (χ2) Test

These are the basic steps whether you are performing a goodness-of-fit test or a test of independence:

*   Create a table of the observed and expected frequencies.
*   Use the formula to calculate the chi-square value.
*   Find the critical chi-square value using a chi-square value table or [statistical software](https://www.investopedia.com/terms/d/data-analytics.asp).
*   Determine whether the chi-square value or the critical value is the larger of the two.
*   Reject or accept the null hypothesis.  
    

## Limitations of a Chi-Square (χ2) Statistic

The chi-square test is sensitive to sample size. Relationships may appear to be significant when they aren’t, simply because a very large sample is used.

In addition, the chi-square test cannot establish whether one variable has a causal relationship with another. It can only establish whether two variables are related.  

## What Is a Chi-Square Test Used for?

Chi-square is a statistical test used to examine the differences between categorical variables from a random sample in order to judge the goodness of fit between expected and observed results.

## Who Uses Chi-Square Analysis?

Since chi-square applies to categorical variables, it is most used by researchers who are studying survey response data. This type of research can range from demography to consumer and marketing research to political science and economics.

## Is Chi-Square Analysis Used When the Independent Variable Is Nominal or Ordinal?

A nominal variable is a categorical variable that differs by quality, but whose numerical order could be irrelevant. For instance, asking somebody their favorite color would produce a nominal variable. Asking somebody’s age, on the other hand, would produce an ordinal set of data. Chi-square can be best applied to nominal data.

## The Bottom Line

A chi-square statistic is used to measure the difference between the observed and expected frequencies of the outcomes of a set of variables. It can be helpful for analyzing differences in categorical variables, especially those nominal in nature. The two different types of chi-square tests—test of independence and test of goodness of fit—will answer different relational questions.  

> **Article Sources**
>
> 1.  Kent State University. "[Chi Square Test of Independence](https://libguides.library.kent.edu/spss/chisquare)."