10.2: Test of Independence
Learning Objectives
- Understand how to draw and calculate appropriate data from tables needed to run a Chi-Square test.
- Run a Test of Independence to determine whether two variables are independent or not.
- Use a Test of Homogeneity to examine the proportions of a variable attributed to different populations.
Introduction
As mentioned in the previous lesson, the Chi-Square test can be used to (1) estimate how closely an observed distribution matches an expected distribution (Goodness-of-Fit test) or (2) estimating whether two random variables are independent of one another (the Test of Independence). In this lesson, we will examine the Test of Independence in greater detail.
The Chi-Square Test of Independence is used to assess if two factors are related. This test is often used in social science research to determine if factors are independent of each other. For example, we would use this test to determine relationships between voting patterns and race, income and gender, and behavior and education.
In general, when running the Test of Independence, we ask “Is Variable independent of Variable ?” It is important to note that this test does not test how the variables are related, just simply whether or not they are independent of one another. For example, we can test if income and gender are independent, the Test of Independence cannot help us assess how one category might affect the other.
Drawing and Calculating Data from Tables
As mentioned in the previous lesson, tables help us frame our hypotheses and solve problems. Often, we use tables to list the variables and observation patterns that will help us to run the Chi-Square test. For example, we could use a table to record the answers to phone surveys or observed behavior patterns.
Example: We would use a contingency table to record the data when analyzing whether women are more likely to vote for a Republican or Democratic candidate when compared to men. Specifically, we want to know if voting patterns are independent of gender. Hypothetical data for females and males is in the contingency table below.
Democratic | Republican | Total | |
---|---|---|---|
Female | |||
Male | |||
Total |
Similar to the Chi-Square Goodness-of-Fit test, the Chi-Square Test of Independence is a comparison of the difference between the observed and expected values. However, in this test we need to calculate the expected value using the row and column totals from the table. The expected value for each cell of the table can be calculated using the formula:
In the table above, we calculated that the Row Totals are (Females) and (Males) while the Column Totals are (Democrat) and (Republican). Using this formula, we find the following expected frequency for each cell.
Expected Frequency for Female Democratic cell is
Expected Frequency for Female Republican cell is
Expected Frequency for Male Democratic cell is
Expected Frequency for Male Republican cell is
Using these calculated expected frequencies, we can modify the table above to look something like this:
Democratic | Democratic | Republican | Republican | Total | |
---|---|---|---|---|---|
Observed | Expected | Observed | Expected | ||
Female | |||||
Male | |||||
Total |
Using these figures above, we are able to calculate the Chi-Square statistic with relative ease.
The Chi-Square Test of Independence
As with the Goodness-of-Fit test described earlier, we use similar steps when running a Test-of-Independence. First, we need to establish a hypothesis based on our research question. Using our scenario of gender and voting patterns, our null hypothesis is that there is not a significant difference in the frequencies with which females vote for a Republican or Democratic candidate when compared with males. Therefore,
Null Hypothesis (there is no statistically significant difference between observed and expected frequencies)
Alternative Hypothesis (there is a statistically significant difference between observed and expected frequencies)
Using the table above, we can calculate the Degrees of Freedom and the Chi-Square statistic. The formula for calculating the Chi-Square statistic is the same as before:
where:
Chi-Square statistical value
observed frequency value for each event
expected frequency value for each event
Using this formula and the example above, we get the following expected frequencies and Chi-Square calculations.
Democratic candidate | Democratic candidate | Democratic candidate | Republican candidate | Republican candidate | Republican Candidate | |
---|---|---|---|---|---|---|
Obs. Freq. | Exp. Freq. | Obs. Freq. | Exp. Freq. | |||
Female | ||||||
Male | ||||||
Totals |
Using the table and formula above, we see that the Chi-Square statistic is equal to the sum of all of these values for .Therefore,
Using an alpha level of .05, we look under the column for and the row for Degrees of Freedom . Using the standard Chi-Square distribution table, we see that the critical value for Chi-Square is .Therefore we would reject the null hypothesis if the Chi-Square statistic is greater than .
Reject if
Since our calculated Chi-Square value of is not greater than , we fail to reject the null hypothesis. Therefore, we can conclude that females are not significantly more likely to vote for democratic candidates than males. In other words, these two factors appear to be independent of one another.
Test of Homogeneity
The Chi-Square Goodness-of-Fit and Test of Independence are two ways to examine the relationships between categorical variables. But what test do we use if we are interested in testing whether or not the assignments of these categorical variables are random? We perform the Test of Homogeneity, which is computed the same way as the Test of Independence, to examine the randomness of a sample. In other words, the Test of Homogeneity tests whether samples from populations have the same proportion of observations with a common characteristic.
The Test of Homogeneity is used when we examine the probability that the assignment of one variable is equal to another. For example, we found in our last Test of Independence that the factors of gender and voting patterns were independent of one another. However, remember that our original question was if females were more likely to vote for Democratic candidates when compared to males. We would use the Test of Homogeneity to examine the probability that choosing a Democratic candidate was the same for females and males.
Another commonly used example of a Test of Homogeneity is comparing dice to see if they all work the same way. Let’s use that example to conduct a sample Test of Homogeneity.
Example: A manager of a casino has two potentially ‘loaded’ (‘loaded dice’ are ones that are weighted on one side so that certain numbers have greater probabilities of showing up) that they want to examine. The manager rolls each of the dice exactly and comes up with the following results.
1 | 2 | 3 | 4 | 5 | 6 | Totals | |
---|---|---|---|---|---|---|---|
Dice 1 | |||||||
Dice 2 | |||||||
Totals |
Like the other Chi-Square tests, we first need to establish a hypothesis based on a research question. In this case, our research question would look something like: “Is the probability of rolling a specific number the same for Dice and Dice ?” This would give us the following hypotheses:
Null Hypothesis (The probabilities are the same for both die)
Alternative Hypothesis (The probabilities differ for both die)
Similar to the other test, we need to calculate the expected values for each cell and the total number of Degrees of Freedom. To get the expected frequency for each cell, we use the same formula as we used for the Test of Independence:
The following table has includes the Expected Frequency (in parenthesis) for each cell along with the Chi-Square statistic in a separate column.
Number Rolled on the Potentially Loaded Dice
Total | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Dice | |||||||||||||
Dice | |||||||||||||
Totals |
Using the same Chi-Square formula and the information from the table above, we find that:
Using an alpha level of .05,we look under the column for and the row for Degrees of Freedom . Using the standard Chi-Square distribution table, we see that the critical value for Chi-Square is . Therefore we would reject the null hypothesis if the Chi-Square statistic is greater than .
Reject if
Since our calculated Chi-Square value of is not greater than , we fail to reject the null hypothesis. Therefore, we can conclude that each number is just as likely to be rolled on one die as the other. This means that if the dice are loaded, they are probably loaded in the same way or were made by the same manufacturer.
Lesson Summary
1. The Chi-Square Test of Independence is used to assess if factors are related. It is commonly used in social science research to examine behaviors, preferences, measurements, etc.
2. As with the Chi-Square Goodness-if-Fit test, tables help capture and display relevant information.
3. For each cell in the table constructed to run a chi-square test, we need to calculate the expected frequency. The formula used for this calculation is:
4. To calculate the Chi-Square statistic for the Test of Independence, we use the same formula as the Goodness-of-Fit test. If the calculated Chi-Square value is greater than the critical value, we reject the null hypothesis.
5. We perform the Test of Homogeneity to examine the randomness of a sample. The Test of Homogeneity tests whether various populations are homogeneous or equal with respect to certain characteristics.
Review Questions
- What is the Chi-Square Test of Independence used for?
- True or False: In the Test of Independence, you can test if two variables are related but you cannot test the nature of the relationship itself.
- When calculating the expected frequency for a cell in a contingency table, you use the formula:
Please use the table below to answer the following review questions.
Studied Abroad | Did Not Study Abroad | |
---|---|---|
Females | ||
Males |
- What is the total number of females in the sample?
- What is the total number of observations in this sample?
- What is the expected frequency for the number of males that did not study abroad?
- How many Degrees of Freedom are in this example?
- True or False: Our null hypothesis would be that females are as likely as males to study abroad.
- What is the Chi-Square statistic for this example?
- If the Chi-Square critical value at and of freedom is and we have a calculated Chi-Square value of , we would:
- reject the null hypothesis
- fail to reject the null hypothesis
- True or False: We use the Test of Homogeneity to evaluate the equality of several samples of certain variables.
- The Test of Homogeneity is carried out the exact same way as:
- The Goodness-of-Fit test
- The Test of Independence
Review Answers
- To examine if two variables are related.
- True
- A
- D
- C
- A
- A
- True
- A
- B
- True
- B