<meta http-equiv="refresh" content="1; url=/nojavascript/"> Test of Independence | CK-12 Foundation
Dismiss
Skip Navigation
You are reading an older version of this FlexBook® textbook: CK-12 Probability and Statistics - Advanced Go to the latest version.

10.2: Test of Independence

Created by: CK-12
 0  0  0

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 X independent of Variable Y ?” 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 76 females and 62 males is in the contingency table below.

Frequency of California Citizens voting for a Republican or Democratic Candidate
Democratic Republican Total
Female 48 28 76
Male 36 26 62
Total 84 54 138

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:

\text{Expected\ Frequency} = \frac{(\text{Row\ Total}) (\text{Column\ Total})} {\text{Total\ Number\ of\ Observations}}

In the table above, we calculated that the Row Totals are 76 (Females) and 62 (Males) while the Column Totals are 84 (Democrat) and 54 (Republican). Using this formula, we find the following expected frequency for each cell.

Expected Frequency for Female Democratic cell is 76 \times 84 / 138 = 46.24

Expected Frequency for Female Republican cell is 76 \times 54 / 138 = 29.74

Expected Frequency for Male Democratic cell is 62 \times 84 / 138 = 37.74

Expected Frequency for Male Republican cell is 62 \times 54 / 138 = 24.26

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 48 46.26 28 29.74 76
Male 36 37.74  26  24.26 62
Total 84 54 138

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 H_0:O  = E (there is no statistically significant difference between observed and expected frequencies)

Alternative Hypothesis >H_a:O \neq E (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:

\chi^2 = \sum_i \frac{(0_i - E_i)^2} {E_i}

where:

\chi^2 = Chi-Square statistical value

O_i  = observed frequency value for each event

E_i = 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. (O - E)^2 /E Obs. Freq. Exp. Freq. (O - E)^2 /E
Female 48 46.26 .07 28 29.74 .10
Male 36 37.74 .08 26 24.26 .12
Totals 84 54

\text{and the Degrees of Freedom} & = (C - 1) (R - 1) \\\text{df} & = (2-1) (2-1) = 1

Using the table and formula above, we see that the Chi-Square statistic is equal to the sum of all of these values for (O-E)^2 /E.Therefore,

 x^2 = .07 + .08 + .10 + .12 = 0.37

Using an alpha level of .05, we look under the column for .05 and the row for Degrees of Freedom (df = 1). Using the standard Chi-Square distribution table, we see that the critical value for Chi-Square is 3.84.Therefore we would reject the null hypothesis if the Chi-Square statistic is greater than 3.84.

Reject H_0:O if X^2 > 3.84

Since our calculated Chi-Square value of 0.37 is not greater than 3.84, 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 20 \;\mathrm{times} and comes up with the following results.

Number Rolled on the Potentially Loaded Dice
1 2 3 4 5 6 Totals
Dice 1 6 1 2 2 3 6 20
Dice 2 4 1 3 3 1 8 20
Totals 10 2 5 5 4 14 40

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 1 and Dice 2?” This would give us the following hypotheses:

Null Hypothesis (H_0:O) = E (The probabilities are the same for both die)

Alternative Hypothesis (H_a:O)\neq E (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:

\text{Expected\ Frequency} = \frac{(\text{Row\ Total}) (\text{Column\ Total})} {\text{Total\ Number\ of\ Observations}}

The following table has includes the Expected Frequency (in parenthesis) for each cell along with the Chi-Square statistic ((O-E)^2 / E) in a separate column.

Number Rolled on the Potentially Loaded Dice

1 X^2 2 X^2 3 X^2 4 X^2 5 X^2 6 X^2 X^2 Total
Dice 1 6 (7.5) 0.3 1 (1) 0 2 (2.5) .1 2 (2.5) .1 3 (2) .5 6 (7) .2 1.2
Dice 2 4 (7.5) 1.6 1 (1) 0 3 (2.5) .1 3 (2.5) .1 1 (2) .5 8 (7) .2 2.5
Totals 10 2 5 5 4 14

\text{and the Degrees of Freedom} & = (C - 1) (R - 1) \\\text{df} & = (6 - 1) (2-1) = 5

Using the same Chi-Square formula and the information from the table above, we find that:

X^2 = .1.2 + 2.5 = 3.7

Using an alpha level of .05,we look under the column for .05 and the row for Degrees of Freedom (df = 5). Using the standard Chi-Square distribution table, we see that the critical value for Chi-Square is 11.07. Therefore we would reject the null hypothesis if the Chi-Square statistic is greater than 11.07.

Reject(H_0:O) if X^2 > 11.07

Since our calculated Chi-Square value of 3.7 is not greater than 11.07, 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 2 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:

\text{Expected Frequency} = \frac{(\text{Row\ Total}) (\text{Column\ Total})} {\text{Total\ Number\ of\ Observations}}

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

  1. What is the Chi-Square Test of Independence used for?
  2. 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.
  3. When calculating the expected frequency for a cell in a contingency table, you use the formula:
    1. \text{Expected Frequency } =   \frac{(\text{Row Total}) (\text {Column Total})} {\text{Total Number of Observations}}
    2. \text{Expected Frequency } =  \frac{(\text{Total Observations}) (\text{Column Total})} {\text{Row Total}}
    3. \text{Expected Frequency } =  \frac{(\text{Total Observations}) (\text{Row Total})} {\text{Column Total}}

Please use the table below to answer the following review questions.

Research Question: Are females at UC-Berkeley more likely to study abroad than males?
Studied Abroad Did Not Study Abroad
Females 322 460
Males 128 152
  1. What is the total number of females in the sample?
    1. 450
    2. 280
    3. 612
    4. 782
  2. What is the total number of observations in this sample?
    1. 782
    2. 533
    3. 1,062
    4. 612
  3. What is the expected frequency for the number of males that did not study abroad?
    1. 161
    2. 208
    3. 111
    4. 129
  4. How many Degrees of Freedom are in this example?
    1. 1
    2. 2
    3. 3
    4. 4
  5. True or False: Our null hypothesis would be that females are as likely as males to study abroad.
  6. What is the Chi-Square statistic for this example?
    1. 1.60
    2. 2.45
    3. 3.32
    4. 3.98
  7. If the Chi-Square critical value at .05 and 1 \;\mathrm{degree} of freedom is 3.81 and we have a calculated Chi-Square value of 2.22, we would:
    1. reject the null hypothesis
    2. fail to reject the null hypothesis
  8. True or False: We use the Test of Homogeneity to evaluate the equality of several samples of certain variables.
  9. The Test of Homogeneity is carried out the exact same way as:
    1. The Goodness-of-Fit test
    2. The Test of Independence

Review Answers

  1. To examine if two variables are related.
  2. True
  3. A
  4. D
  5. C
  6. A
  7. A
  8. True
  9. A
  10. B
  11. True
  12. B

Image Attributions

Files can only be attached to the latest version of None

Reviews

Please wait...
Please wait...
Image Detail
Sizes: Medium | Original
 
CK.MAT.ENG.SE.1.Prob-&-Stats-Adv.10.2

Original text