Professional Documents
Culture Documents
AP Stats Ch25
AP Stats Ch25
Comparing Counts
Objectives
Chi-Square Model
Chi-Square Statistic
Knowing when and how to use the Chi-
Square Tests;
Goodness of Fit
Test of Independence
Test of Homogeneity
Standardized Residual
Categorical Data
Chi Square tests are used for when we have counts
for the categories of a categorical variable:
Goodness of Fit Test
Allows us to test whether a certain population
distribution seems valid. This is a one variable, one
sample test
Test of Independence
Cross categorizing one group on two-variables to see if
there is an association between variables. This is a two
variable, one sample test.
Test for Homogeneity
Compares observed distribution for several groups to
each other to see if there is a difference among the
population. This is a one variable, many samples test.
Chi Square Model
Just like the student t-models, chi square has a family
of models depending on degrees of freedom.
Unlike the student t-models, a chi square distribution
is not symmetric. It’s skewed right.
A chi square test statistic is always a one-sided, right-
tailed test.
The Chi-Square ( 2 ) Distribution - Properties
It is a continuous distribution.
It is not symmetric.
It is skewed to the right.
The distribution depends on the degrees of
freedom.
The value of a 2 random variable is always
nonnegative.
There are infinitely many 2 distributions,
since each is uniquely defined by its degrees
of freedom.
The Chi-Square ( 2 ) Distribution - Properties
For small sample size, the 2 distribution is
very skewed to the right.
As n increases, the 2 distribution becomes
more and more symmetrical.
The Chi-Square ( 2 ) Distribution - Properties
Since we will be using the 2 distribution for
the tests in this chapter, we will need to be
able to find critical values associated with the
distribution.
Critical Value
• Since we will be using the 2 distribution for the tests
in this chapter, we will need to be able to find critical
values associated with the distribution.
• Explanation of the term – critical or rejection region: A
critical or rejection region is a range of test statistic
values for which the null hypothesis will be rejected.
• This range of values will indicate that there is a
significant or large enough difference between the
postulated parameter value and the corresponding
point estimate for the parameter.
Critical Value
• Explanation of the term – non-critical or non-rejection
region: A non-critical or non-rejection region is a
range of test statistic values for which the null
hypothesis will not be rejected.
• This range of values will indicate that there is not a
significant or large enough difference between the
postulated parameter value and the corresponding
point estimate for the parameter.
Critical Value
(Rejection Region)
Non-Critical Region
(Non-Rejection Region)
The Chi-Square ( 2 ) Distribution - Properties
Notation: 2, df
Explanation of the notation 2, df: 2, df is a
2 value with n degrees of freedom such that
(the significance level) area is to the right of
the corresponding 2 value.
The Chi-Square ( 2 ) Distribution - Properties
Diagram
explaining the
notation
2, df
The Chi-Square ( 2 ) Distribution - Table
The Chi-Square ( 2 ) Distribution - Table
α=.05
df=10
χ2 critical value
The Chi-Square ( 2 ) Distribution - Table
20.10,20 = 28.41
CHI-SQUARE (2) TEST
FOR GOODNESS OF FIT
Goodness-of-Fit
A test of whether the distribution of counts in
one categorical variable matches the
distribution predicted by a model is called a
goodness-of-fit test.
As usual, there are assumptions and
conditions to consider…
Assumptions and Conditions
Counted Data Condition: Check that the data
are counts for the categories of a categorical
variable.
Independence Assumption: The counts in
the cells should be independent of each
other.
Randomization Condition: The individuals who
have been counted and whose counts are
available for analysis should be a random
sample from some population.
Assumptions and Conditions
Sample Size Assumption: We must have
enough data for the methods to work.
Expected Cell Frequency Condition: We
should expect to see at least 5 individuals in
each cell.
This is similar to the condition that np
and nq be at least 10 when we tested
proportions.
Calculations
Since we want to examine how well the
observed data reflect what would be
expected, it is natural to look at the
differences between the observed and
expected counts (Obs – Exp).
Calculations (cont.)
The test statistic, called the chi-square (or
chi-squared) statistic, is found by adding up
the sum of the squares of the deviations
between the observed and expected counts
divided by the expected counts:
Obs Exp
2
2
all cells Exp
One-Sided or Two-Sided?
The chi-square statistic is used only for
testing hypotheses, not for constructing
confidence intervals.
If the observed counts don’t match the
expected, the statistic will be large—it can’t
be “too small.”
So the chi-square test is always one-sided.
If the calculated statistic value is large enough,
we’ll reject the null hypothesis.
One-Sided or Two-Sided?
The mechanics may work like a one-sided
test, but the interpretation of a chi-square test
is in some ways many-sided.
There are many ways the null hypothesis
could be wrong.
There’s no direction to the rejection of the null
model—all we know is that it doesn’t fit.
Procedure
Procedure (cont.)
Expected Frequencies
E=np
each expected frequency is found by
multiplying the sum of all observed
frequencies by the probability for the
category
Expected Frequencies
=
2 (O – E)2
E
Critical Values
1. Found in Table using k – 1 degrees of
freedom where k = number of categories
2. Goodness-of-fit hypothesis tests are
always right-tailed.
EXAMPLE
There are 4 TV sets that are located in
the student center of a large university. At
a particular time each day, four different
soap operas (1, 2, 3, and 4) are viewed on
these TV sets. The percentages of the
audience captured by these shows during
one semester were 25 percent, 30 percent,
25 percent, and 20 percent, respectively.
During the first week of the following
semester, 300 students are surveyed.
EXAMPLE (Continued)
(a) If the viewing pattern has not changed,
what number of students is expected to
watch each soap opera?
Solution: Based on the information, the
expected values will be: 0.25300 = 75,
0.30300 = 90, 0.25300 = 75, and
0.20300 = 60.
EXAMPLE (Continued)
(b) Suppose that the actual observed
numbers of students viewing the soap
operas are given in the following table, test
whether these numbers indicate a change
at the 1 percent level of significance.
EXAMPLE (Continued)
Solution: Given = 0.01, n = 4, df = 4 – 1
= 3, 20.01, 3= 11.345. The observed and
expected frequencies are given below
EXAMPLE (Continued)
Solution (continued): The 2 test statistic
is computed below.
EXAMPLE (Continued)
Solution (continued):
Diagram showing
the rejection
region.
The Chi-Square test for Goodness of Fit
Your Turn
The Advanced Placement (AP) Statistics examination was
first administered in May 1997. Students’ papers are
graded on a scale of 1–5, with 5 being the highest score.
Over 7,600 students took the exam in the first year, and
the distribution of scores was as follows (not including
exams that were scored late).
Score 5 4 3 2 1 .
Frequency 7 13 7 6 2
O E
2
Score Observed Expected % Expected
Counts (pi) Counts (npi)
E
5 7 15.3 5.355 .50533
4 13 22 7.7 3.6481
=
2 (O – E)2
E
Critical Values
1. Found in Table using
degrees of freedom = (r – 1)(c – 1)
r is the number of rows and c is the number of
columns
2. Tests of Independence are always right-
tailed.
Tests of Independence
H0: The row variable is independent of the
column variable
n • p
(probability of a cell)
Total
1692 422 64 45 2223
We will use the mortality table from the Titanic to find expected
frequencies. For the upper left hand cell, we find:
(706)(1692)
E= = 537.360
2223
Observed and Expected Frequencies
Men Women Boys Girls Total
332 318 29 27 706
Survived 537.360
Total
1692 422 64 45 2223
Find the expected frequency for the lower left hand cell, assuming
independence between the row variable and the column variable.
(1517)(1692)
E= = 1154.640
2223
Observed and Expected Frequencies
Men Women Boys Girls Total
332 318 29 27 706
Survived 537.360 134.022 20.326 14.291
To interpret this result for the lower left hand cell, we can say that although 1360
men actually died, we would have expected 1154.64 men to die if survivablility is
independent of whether the person is a man, woman, boy, or girl.
Example: Using a 0.05 significance level, test the claim
that when the Titanic sank, whether someone survived or
died is independent of whether that person is a man,
woman, boy, or girl.
2
0
475.554 475.554
485 539.108
2
539.108
24.74
Solution: Classical Approach
Step 4: There are r = 2 rows and c =3
columns, so we find the critical
value using (2-1)(3-1) = 2 degrees
of freedom.
The critical value is 0.01 9.210 .
2
Solution: Classical Approach
Step 5: Since the test statistic, 0 24.74
2
Solution: P-Value Approach
Step 5: Since the P-value is less than the
level of significance = 0.01, we
reject the null hypothesis.
Solution
Step 6: There is sufficient evidence to
reject the null hypothesis at the =
0.01 level of significance. We
conclude that the proportion of
individuals who believe that
teaching is a very prestigious career
is different for at least one of the
three years.
Example: Should Dentist Advertise?
It may seem hard to believe but until the
1970’s most professional organizations
prohibited their members from advertising. In
1977, the U.S. Supreme Court ruled that
prohibiting doctors and lawyers from
advertising violated their free speech rights.
Should Dentist Advertise?
The paper “Should Dentist Advertise?” (J. of
Advertising Research (June 1982): 33 – 38)
compared the attitudes of consumers and
dentists toward the advertising of dental
services. Separate samples of 101
consumers and 124 dentists were asked to
respond to the following statement: “I favor
the use of advertising by dentists to attract
new patients.”
Example: Should Dentist Advertise?
Possible responses were: strongly agree,
agree, neutral, disagree, strongly disagree.
Dentists 9 18 23 28 46 124
43 67 32 32 51 225
• How do we determine the expected cell count under the assumption of homogeneity?
• That’s right, the expected cell counts are estimated from the sample data (assuming
that H0 is true) by using …
43 67 32 32 51 225
2
Expected Count
...
19.30 30.08 28.11
Step 1 Mall
A
Mall
B
Mall
C
Total
Ho: p1 = p2 = p3
Will 52 45 36 133
Ha: At least one Partici
pate
is different
Step 2 Will 40 47 56 143
not
α = 0.01 partici
pate
Step 3
2
( 2) Total 92 92 92 276
Homogeneity of Proportions
Step 4
Put into your calculator
Observed in matrix A
Expected in matrix B
Test statistic = 5.602
P-value = 0.06
Homogeneity of Proportions
Step 5
Do Not Reject Ho
Step 6
There is not sufficient evidence to suggest that
at least one is different.
Chi-Square and Causation
Chi-square tests are common, and tests for
independence are especially widespread.
We need to remember that a small P-value is not
proof of causation.
Since the chi-square test for independence treats
the two variables symmetrically, we cannot
differentiate the direction of any possible
causation even if it existed.
And, there’s never any way to eliminate the
possibility that a lurking variable is responsible for
the lack of independence.
Chi-Square and Causation (cont.)
In some ways, a failure of independence
between two categorical variables is less
impressive than a strong, consistent, linear
association between quantitative variables.
Two categorical variables can fail the test of
independence in many ways.
Examining the standardized residuals can help
you think about the underlying patterns.
CHI-SQUARE INFERENCE
TEST FOR GOODNESS OF FIT
• Used to determine if a particular population
distribution fits a specified form
HYPOTHESES:
H0: Actual population percents are equal to
hypothesized percentages
Ha: Actual population percents are different from
hypothesized percentages
CHI-SQUARE INFERENCE
TEST FOR INDEPENDENCE
• Used to determine if two variables within a single
population are independent
HYPOTHESES:
H0: There is no relationship between the two variables
in the population
Ha: There is a dependent relationship between the two
variables in the population
CHI-SQUARE INFERENCE
TEST FOR HOMOGENEITY
• Used to determine if two separate populations are
similar in respect to a single variable
HYPOTHESES:
H0: There are no differences among proportions of
success in the populations
Ha: There are differences among proportions of
success in the populations