Hypothesis Statement For Chi Square

The Chi-square test of independence determines whether there is a statistically significant relationship between categorical variables. It is a hypothesis test that answers the question—do the values of one categorical variable depend on the value of other categorical variables?

As you no doubt guessed, I’m a huge fan of statistics. I’m also a big Star Trek fan. Consequently, it’s not surprising that I’m writing a blog post about both! In the Star Trek TV series, Captain Kirk and the crew wear different colored uniforms to identify the crewmember’s work area. Those who wear red shirts have the unfortunate reputation of dying more often that those who wear gold or blue shirts.

In this post, I’ll show you how the Chi-square test of independence works. Then, I’ll show you how to perform the analysis and interpret the results by working through the example. I’ll use this test to determine whether wearing the dreaded red shirt in Star Trek is the kiss of death!

If you need a primer on the basics, read my hypothesis testing overview.

Overview of the Chi-Square Test of Independence

The Chi-square test of association evaluates relationships between categorical variables. Like any statistical hypothesis test, the Chi-square test has both a null hypothesis and an alternative hypothesis.

  • Null hypothesis: There are no relationships between the categorical variables. If you know the value of one variable, it does not help you predict the value of another variable.
  • Alternative hypothesis: There are relationships between the categorical variables. Knowing the value of one variable does help you predict the value of another variable.

The Chi-square test of independence works by comparing the distribution that you observe to the distribution that you expect if there is no relationship between the categorical variables. In the Chi-square context, the word “expected” is equivalent to what you’d expect if the null hypothesis is true. If your observed distribution is sufficiently different than the expected distribution (no relationship), you can reject the null hypothesis and infer that the variables are related.

For a Chi-square test, a p-value that is less than or equal to your significance level indicates there is sufficient evidence to conclude that the observed distribution is not the same as the expected distribution. You can conclude that a relationship exists between the categorical variables.

Star Trek Fatalities by Uniform Colors

We’ll perform a Chi-square test of independence to determine whether there is a statistically significant association between shirt color and deaths. We need to use this test because these variables are both categorical variables. Shirt color can be only blue, gold, or red. Fatalities can be only dead or alive.

The color of the uniform represents each crewmember’s work area. We will statistically assess whether there is a connection between uniform color and the fatality rate. Believe it or not, there are “real” data about the crew from authoritative sources and the show portrayed the deaths onscreen. The table below shows how many crewmembers are in each area and how many have died.

BlueScience and Medical1367
GoldCommand and Helm559
RedOperations, Engineering, and Security23924
Ship’s totalAll43040

Performing the Chi-Square Test of Independence for Uniform Color and Fatalities

For our example, we are going to determine whether the observed counts of deaths by uniform color is different from the distribution that we’d expect if there is no association between the two variables.

The table below shows how I’ve entered the data into the worksheet. You can also download the CSV dataset for StarTrekFatalities.


You can use the dataset to perform the analysis in your preferred statistical software. The Chi-squared test of independence results are below. As an aside, I use this example in my post about degrees of freedom in statistics. Learn why there are two degrees of freedom for the table below.

In our statistical results, both p-values are less than 0.05. We can reject the null hypothesis and conclude there is a relationship between shirt color and deaths. The next step is to define that relationship.

Describing the relationship between categorical variables involves comparing the observed count to the expected count in each cell of the Dead column. I’ve annotated this comparison in the statistical output above. Additionally, you can graph the contribution of each table cell to the Chi-square statistic, which is below.

Surprise! It’s the blue and gold uniforms that contribute the most to the Chi-square statistic and produce the statistical significance! Red shirts add almost nothing. In the statistical output, the comparison of observed counts to expected counts shows that blue shirts die less frequently than expected, gold shirts die more often than expected, and red shirts die at the expected rate.

The graph below reiterates these conclusions by displaying the percentage of fatalities by uniform color along with the overall death rate.

The Chi-square test indicates that red shirts don’t die more frequently than expected. Hold on. There’s more to this story!

Time for a bonus lesson and a bonus analysis in this blog post!

2 Proportions test to compare Security Red-Shirts to Non-Security Red-Shirts

The bonus lesson is that is vital to include the truly pertinent variables in the analysis. Perhaps the color of the shirt is not the important variable but rather the crewmember’s work area. Crewmembers in Security, Engineering, and Operations all wear red shirts. Maybe only security guards have a higher death rate?

We can test this theory using the 2 Proportions test. We’ll compare the fatality rates of red-shirts in security to red-shirts who are not in security.

The summary data are below. In the table, the events represent the counts of deaths while the trials are the number of personnel.

Not security6149

The p-value of 0.000 signifies that the difference between the two proportions is statistically significant. Security has a mortality rate of 20% while the other red-shirts are only at 4%.

Security officers have the highest mortality rate on the ship, closely followed by the gold-shirts. Red-shirts that are not in security have a fatality rate similar to the blue-shirts.

As it turns out, it’s not the color of the shirt that has an effect; it’s the duty area. That makes more sense.

Risk by Work Area Summary

The Chi-square test of independence and the 2 Proportions test both indicate that the death rate varies by work area on the U.S.S. Enterprise. Doctors, scientists, engineers, and those in ship operations are the safest with about a 5% fatality rate. Crewmembers that are in command or security have death rates that exceed 15%!

Related Posts on Statistics by Jim

Filed Under: Hypothesis TestingTagged With: analysis example, interpreting results

Printer-friendly version

Chi-Square Test of Independence

Do you remember how to test the independence of two categorical variables? This test is performed by using a Chi-square test of independence.

Recall that we can summarize two categorical variables within a two-way table, also called a r × c contingency table, where r = number of rows, c = number of columns. Our question of interest is “Are the two variables independent?”  This question is set up using the following hypothesis statements:

Null Hypothesis: The two categorical variables are independent.

Alternative Hypothesis: The two categorical variables are dependent.

The chi-square test statistic is calculated by using the formula:


where O represents the observed frequency. E is the expected frequency under the null hypothesis and computed by:

 \[E=\frac{\text{row total}\times\text{column total}}{\text{sample size}}\]

We will compare the value of the test statistic to the critical value of \(\chi_{\alpha}^2\) with degree of freedom = (r - 1) (c - 1), and reject the null hypothesis if \(\chi^2 \gt \chi_{\alpha}^2\).


Is gender independent of education level? A random sample of 395 people were surveyed and each person was asked to report the highest education level they obtained. The data that resulted from the survey is summarized in the following table:

 High School

Question:  Are gender and education level dependent at 5% level of significance?  In other words, given the data collected above, is there a relationship between the gender of an individual and the level of education that they have obtained?

Here's the table of expected counts:

 High School

So, working this out, \(\chi^2= (60−50.886)^2 / 50.886 + \cdots + (57 − 48.132)^2 / 48.132 = 8.006\)

The critical value of \(\chi^2\) with 3 degree of freedom is 7.815. Since 8.006 > 7.815, therefore we reject the null hypothesis and conclude that the education level depends on gender at a 5% level of significance.

Using Minitab

We can enter the data into Minitab and request that the 'Chi-square test' be conducted for the above hypotheses. The Minitab output for this example is shown below:

The Chi-square test of independence value that Minitab calculated is 8.006, which is the same as we calculated above.

The Chi-square test for independence is an important method for determining if there is a relationship between variables where the chance that something falls into a particular category depends on whether the variable falls into another category comes into play.  This relationship of independence / dependence is important to be able to understand and use.

Chi-Square Goodness-of-Fit Tests

Do you remember how to use the chi-square goodness of fit test to test whether random categorical variables follow a particular probability distribution?  Let's take a look at an example:


Suppose the Penn State student population is 20% PA resident and 80% non-PA resident. Then, if a sample of 100 students yields 16 PA resident and 84 non-PA resident, how 'good' do the data 'fit' the assumed probability model of 20% PA resident and 80% non-PA resident?

We can use the chi-square goodness-of-fit statistic to test the hypotheses statements:

Null Hypothesis: \(P_r = 0.2\)

Alternative Hypothesis:  \(P_r \ne 0.2\)

Working this out we get, \[\chi^2= \frac{(16−20)^2}{20} + \cdots +\frac{(84−80)^2}{80}=1\]

The critical value of  \(\chi^2\) with 1 degree of freedom is 3.84. Since 1 < 3.84, we can not reject the null hypothesis. There is not enough evidence to conclude that the data don't fit the assumed probability model at 5% level of significance.  In other words, the students that were randomly selected in this example did resemble the probability distribution that was specified.

0 thoughts on “Hypothesis Statement For Chi Square”


Leave a Comment

Your email address will not be published. Required fields are marked *