P2010 Lecture Notes

Chi-square Tests

Example problem

Suppose that the question of the handedness of psychology majors had arisen. Some persons believed that students who choose to major in psychology are more likely to be left-handed than persons in the general public.

Suppose that in the population of persons of college age, 12% are left handed.

The interest here is in the population of psychology majors: Is the percentage of left handed people in that population equal to 12% or not?

Suppose a sample of 25 psychology majors was selected, and the handedness of each student was determined. To determine handedness, a series of tasks – writing, eating with a fork, throwing a ball overhand, etc – were described to each participant and the hand each participant reported using for the task determined. The hand used the most (with greater weight to writing and eating with a fork) was the “official” hand of each person.

The (hypothetical) data were as follows.

Person Handedness

1 R

2 R

3 R

4 L

5 R

6 L

7 R

8 R

9 R

10 L

11 R

12 R

13 R

14 L

15 R

16 R

17 L

18 L

19 R

20 R

21 R

22 L

23 R

24 R

25 R


Tests of hypotheses on population percentages:

Introduction & Relationship to Past Work

Tests for comparison of means

1) Suppose someone claims that psychology majors are more extraverted than the average of 4 on a 1-7 scale.

Appropriate test: One Sample Z test or t-test

Is the average of the extraversion scores equal to a specified value?

2) Suppose someone claims that psychology majors are less extraverted than engineering majors.

Appropriate test: Independent Sample t-test or Paired Sample t-test

Is the average of the extraversion scores in one population equal to the average of the extraversion scores in a second population?

Problem

Extraversion scores are quantities – they range from 1.0 to 7.0 on the scales we use. One person can have Extraversion = 2.3 (not very extraverted) while another can have extraversion = 5.7 (pretty extraverted) while another can have extraversion = 3.6 (about average) and so forth.

What if we're working with a categorical variable - one whose values represent only qualitative, rather than quantitative distinctions between people?

Example

Opinion - Pro, Neutral, Con

Performance – Success vs. failure

Movie preference – Action, Comedy, or Slice-of-life

Political Preference – Democrat vs. Independent vs. Republican

Religious preference – Catholic, Protestant, Jewish

For such variables, it makes no sense to ask - Is the average amount of the characteristic equal to some specific value. E.g., "Is the average amount of success equal to S.34?" or "Is the average Religion equal to Catholic and one half?"

A new question

For these variables, our interest will probably be in the percentage of persons at each value of the variable - e.g., “Is the percentage of left handed psych majors equal to 12% or not?”, "Are the percentages of movie preferences for action, comedy, and slice-of-life equal or not?” or "Are the percentages of persons in Chattanooga who are Catholic, Protestant, and Jewish equal or not?"

A new statistics: The Chi-square Statistic

For such questions - those involving numbers of persons - a test statistic different from the t statistic or Z statistic must be employed. The statistic is called the Chi-square.

There are two types of chi-square problems: One population problems and Two-population problems.

One way chi-square problems first - one population

Categorical variable analog of the One-sample t-test

The first type of problem concerns the number of persons in each category of a variable in one population. Here we're comparing percentages across the categories of a variable within a single population. For example, consider the handedness of psychology majors – Left vs. Right. "Is the percentage of psych majors who are left handed equal to 12% ?"

For this problem we would compute the percentage or left-handed psych majors and test the hypothesis that the percentages were 12%

Other types of problems

Is a coin fair: Does the Percentage of Heads and Percentage of Tails equal 50%?

Is a forest infected: Does the % of dying trees = 2.2%, the typical % in all forests?

Car Safety: Does the % of Cars with defects in air bags equal .00000002%, the % that would be expected due to normal manufacturing defects?

Fairness of a die: Does % of 1s = % of 2s = % of 3s = % of 4s = % of 5s = % of 6s = 16.67%?

Each problem involves comparison of % in a category or categories of an outcome with population percentages.


One Way Chi-square Test: Overview

The situation

Each of the persons in a single population has been placed in one of the categories of a variable. We wish to test a hypothesis about the numbers or percentages of persons in the population in each of the categories of the variable.

General procedure

We'll take a sample from the population. Using the null hypothesis, we'll compute the number of persons in the sample which would be expected in each category of the variable. We'll compare these expected frequencies (symbolized with E) with the actual observed frequencies (symbolized with O) in the categories. If the observed and expected frequencies are "close", we'll retain the null hypothesis. But if the observed and expected frequencies are "far" from each other, we'll reject the null.

Test Statistic: One way chi-square statistic The official “chi” symbol from Word: χ

(O – E)2 (O1-E1)2 (O2-E2)2 (Ok-Ek)2

X2 = S ------= ----- + ----- + . . . -----

E E1 E2 Ek

where . . .

Summation is over all the categories of the variable.

O represents the observed frequency in a category.

E represents the expected frequency in a category.

If the null hypothesis is true, the chi-square statistic has a Chi-square ( χ2) distribution with degrees of freedom equal to the Number of categories - 1.

That is, df = No. of categories - 1.

If the null is true, values of X2 should be close to the df value.

But if the null is false, values of X2 should be much larger than df.

Negative X2 values are impossible.


One way chi-square: Worked out example problem

Problem

We’ll complete the problem used to introduce this section. The question is: Is the percentage of left handed psychology majors equal to 12%. The data are on the first page of this lecture handout.

Statement of Hypotheses

H0: In the population of psych majors, the percentage of those who are left handed is 12%.

H1: In the population of psych majors, the percentage of those who are left handed is not 12%.

Test Statistic: One way chi-square

Most likely value of test statistic when Null is true

If the null is true, the most likely value of X2 is df. That's because if the null is true, the Os will be close to the expected frequencies, either slightly larger or slightly smaller than the Es. Squaring the difference and dividing by the E yields a quantity which won't be 0, but will be slightly positive. Summing these small positive values yields a value close to degrees of freedom.

Values likely when null is false.

Extremely large positive values of the test statistic would be expected if the null were false. (Negative values will never occur.)

Significance Level.

As usual, we'll set alpha = .05 (5%) This means we'll reject the null if the probability of a chi-square as large as the obtained value if the null were true is less than or equal to .05.

The results are as follows: Left handed: 7 Right handed: 18

Conclusion

Category O E O-E (O-E)2 (O-E)2/E

Left 7 12% of 25 = 3.00 4.00 16.00 16.00/ 3.00 = 5.33

Right 18 88% of 25 = 22.00 -4.00 16.00 16.00/22.00 = 0.73

-----

X2 = 6.06

Conclusion: If the null were true the probability of obtaining a chi-square as extreme as 6.06 is quite small – approximately .014. (I used my tables of p-values to get this.) So 6.06 is a value which we would NOT expect to obtain if the null were true. So we'll reject the null. It appears that the percentage of left handed psychology majors is not 12% but somewhere closer to 28%.

Completing the Corty Hypothesis Testing Answer Sheet . . .

Give the name and the formula of the test statistic that will be employed to test the null hypothesis.

One-Way Chi-square Test

Check the assumptions of the test

There are no distribution assumptions. Data must be categorical.

Null Hypothesis:______

Alternative Hypothesis:______

What significance level will you use to separate "likely" value from "unlikely" values of the test statistic?

Significance Level = ______.05______

What is the value of the test statistic computed from your data and the p-value?

Chi-square = 6.06 p-value < .05 from Table of p-values

What is your conclusion? Do you reject or not reject the null hypothesis?

Reject the null. p-value is less than .050.

What are the upper and lower limits of a 95% confidence interval appropriate for the problem? Present them in a sentence, with standard interpretive language.

Confidence intervals are not required for chi-square problems

State the implications of your conclusion for the problem you were asked to solve. That is, relate your statistical conclusion to the problem.

Data suggest that the proportion of Left-handed persons in the population of Psych majors is greater than .12.


Example problem 2: Preferences for product color. A manufacturer of an energy drink is trying to decide which color should be predominant on its drink labels. A number of cans of the drink are prepared with some predominantly red, some predominantly green, and some predominantly blue. The cans are arranged on a Walmart End-cap so that the colors are randomly distributed. A person is hired to maintain a random distribution throughout the day.

A total of 250 cans is purchased. If color does not make a difference, then we would expect one-third of the purchased cans to be red, one-third to be green, and one-third to be blue.

On the other hand, if color was important, we would expect most of the cans to be of the preferred color.

The number of red cans purchased was 110. The number of green, 75, and the number of blue, 65.

This is a One-way Chi-square test.

The null hypothesis is that in the population of purchasers, the preference for red, green, and blue is 1/3. So out of 250 cans, we would expect 83.33 to be red, 83.33 to be green, and 83.33 to be blue. (Just as the arithmetic average of a bunch of whole numbers can be a decimal, the expected frequencies in chi-square problems can be fractional.)

Working out the problem . . .

Category O __E__ O-E (O-E)2 ______(O-E)2/E______

Red 110 83.33 26.67 711.29 711.29 / 83.33 = 8.54

Green 75 83.33 -8.33 69.39 69.39 / 83.33 = 0.83

Blue 65 83.33 -18.33 335.99 335.99 / 83.33 = 4.03

Chi-square = 8.54 + 0.83 + 4.03 = 13.40

From the Table of p-values with df = 2, p is less than .006


Completing the Corty Hypothesis Testing Answer Sheet for color preferences problem . . .

Give the name and the formula of the test statistic that will be employed to test the null hypothesis.

One-Way Chi-square Test

Check the assumptions of the test

There are no distribution assumptions. Data must be categorical.

Null Hypothesis:______

Alternative Hypothesis:______

What significance level will you use to separate "likely" value from "unlikely" values of the test statistic?

Significance Level = ______.05______

What is the value of the test statistic computed from your data and the p-value?

Chi-square = 13.40 p-value < .05 from Table of p-values

What is your conclusion? Do you reject or not reject the null hypothesis?

Reject the null. p-value is less than .050.

What are the upper and lower limits of a 95% confidence interval appropriate for the problem? Present them in a sentence, with standard interpretive language.

Confidence intervals are not required for chi-square problems

State the implications of your conclusion for the problem you were asked to solve. That is, relate your statistical conclusion to the problem.

Data suggest that the shoppers preferred the Red coloring for cans of this energy drink.

Two way chi-square problems - two or more populations Start here on Tuesday

Categorical equivalent of the Independent Samples t-test.

A second type of question that must be answered when dealing with categorical variables concerns a comparison of the number of persons in each category of one variable between populations identified by categories of a second variable? For example,

"Are the percentages of persons who left handed and right handed in the population of Psychology Majors equal to the corresponding percentages of left handed and right handed persons in the population of Engineering Majors?"

Here, the percentage of persons in each category of the Handedness variable are being compared between two populations identified by categories of the Major variable.

Population of Psychology Majors Population of Engineering Majors

Percentage of left handed Psych Majors vs. Percentage of left handed Eng. Majors

Example problems

Effects of a treatment for forest infestation

Population of Trees Not Treated Population of Trees Treated with spray