+ All Categories
Home > Documents > CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Date post: 04-Jan-2016
Category:
Upload: peter-walton
View: 224 times
Download: 1 times
Share this document with a friend
Popular Tags:
42
CHAPTER 14 CHAPTER 14 Inference for Inference for Distributions of Distributions of Categorical Variables: Categorical Variables: Chi-square Procedures Chi-square Procedures
Transcript
Page 1: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

CHAPTER 14CHAPTER 14Inference for Distributions of Inference for Distributions of

Categorical Variables:Categorical Variables:Chi-square ProceduresChi-square Procedures

Page 2: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

3 Unique Chi-Square Tests3 Unique Chi-Square Tests

Chi-square test for goodness of fitChi-square test for goodness of fit– Allows us to determine whether a specified population Allows us to determine whether a specified population

distribution is validdistribution is valid– Different from other two in the calculatorDifferent from other two in the calculator

Chi-square test for homogeneity of populationsChi-square test for homogeneity of populations– (also called test for homogeneity of proportions)(also called test for homogeneity of proportions)– Allows us to compare two or more population proportionsAllows us to compare two or more population proportions

Chi-square test of association/independenceChi-square test of association/independence– Allows us to determine whether the distribution of one Allows us to determine whether the distribution of one

variable has been influenced by another variablevariable has been influenced by another variable

Page 3: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

SECTION 14.1SECTION 14.1

Test for Goodness of FitTest for Goodness of Fit

Could the observed counts for a categorical variable come from a certain hypothesized distribution?

Page 4: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Something to Start our ThoughtsSomething to Start our Thoughts

Assume you roll a die 86 times and get 9 ones, Assume you roll a die 86 times and get 9 ones, 15 twos, 10 threes, 14 fours, 17 fives, and 21 15 twos, 10 threes, 14 fours, 17 fives, and 21 sixes. sixes. Is there any reason to question the fairness of Is there any reason to question the fairness of this die?this die?What should the distribution look like?What should the distribution look like?Essentially, we have a hypothesized population Essentially, we have a hypothesized population distribution and we are trying to see whether distribution and we are trying to see whether this sample gives us any reason to doubt that this sample gives us any reason to doubt that the population distribution holds for this die.the population distribution holds for this die.

Page 5: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

chi-square (chi-square (XX22) ) test for goodness of fittest for goodness of fit

We use this to see if an observed sample We use this to see if an observed sample distribution is significantly different in some way distribution is significantly different in some way from the hypothesized population distribution.from the hypothesized population distribution.

Essentially, we are trying to see how “good” our Essentially, we are trying to see how “good” our sample data “fits” the suggested population sample data “fits” the suggested population distribution.distribution.

Page 6: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Chi-Squared StatisticChi-Squared Statistic

The chi-square (The chi-square (XX 22 ) statistic is calculated as ) statistic is calculated as

follows:follows:

XX 22 = sum[(observed - expected) = sum[(observed - expected)22/expected]/expected]

22

2

( )

( )

Observed Expected

Expected

O E

E

Page 7: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Basic Properties of Basic Properties of XX 22

XX 22 are only positive values. are only positive values.

The The XX 22 distribution is not symmetrical. It is distribution is not symmetrical. It is

skewed to the right. skewed to the right.

All All XX 22 tests are 1-tail tests. tests are 1-tail tests.

In a goodness of fit test, the degrees of In a goodness of fit test, the degrees of freedom are freedom are number of categories - 1number of categories - 1.(n-1) .(n-1)

Page 8: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Like the t-distributions, there is a Like the t-distributions, there is a different different XX

22 distribution for each distribution for each degree of freedom.degree of freedom.

Page 9: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Key NotesKey NotesThe expected count is always obtained by multiplying The expected count is always obtained by multiplying the percent of the distribution times the sample size.the percent of the distribution times the sample size.P-value is the area under the density curve to the right P-value is the area under the density curve to the right of of XX

22 and large values of and large values of XX 22 are evidence against H are evidence against H00..

HH00: Actual population percents (or proportions) are : Actual population percents (or proportions) are equal to the hypothesized percentages (props). In equal to the hypothesized percentages (props). In some cases, you may end up writing this out as a list. some cases, you may end up writing this out as a list. There is often no easy way to express the null There is often no easy way to express the null hypothesis for the goodness of fit test.hypothesis for the goodness of fit test.HHaa: The actual percentages (or proportions) are : The actual percentages (or proportions) are different from the hypothesized percentages (props).different from the hypothesized percentages (props).Test of goodness of fit can only be used when Test of goodness of fit can only be used when – We have an SRS from the population of interestWe have an SRS from the population of interest– all EXPECTED counts are at least 1 and at least 80% are all EXPECTED counts are at least 1 and at least 80% are

greater than 5 (also expressed as no more than 20% of greater than 5 (also expressed as no more than 20% of expected values are less than 5). expected values are less than 5).

Page 10: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Using the CalculatorUsing the Calculator

If you want to use the calculator, you need to enter If you want to use the calculator, you need to enter your information into lists.your information into lists.For sake of simplicity, enter your observed values into For sake of simplicity, enter your observed values into LL11 and your expected values into L and your expected values into L22. .

To find your To find your XX 22 statistic you must: statistic you must:

Find Sum. Which is under 2Find Sum. Which is under 2ndnd list > math > 5. Then do list > math > 5. Then do sum((Lsum((L11 - L - L22))22/ L/ L22) and this gives you your Chi-squared ) and this gives you your Chi-squared statistic.statistic.If you would like to see a list of your observed - If you would like to see a list of your observed - expected values, for Lexpected values, for L33, enter L, enter L11 - L - L22 and just store and just store them in Lthem in L33 and you can use L and you can use L33 instead of (L instead of (L11 - L - L22))

Page 11: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

More CalculatorMore Calculator

For finding the For finding the PP-value, go to 2-value, go to 2ndnd Vars Vars XX 22 cdf cdf

and plug in the and plug in the XX 22 statistic which is the sum statistic which is the sum

of the components of of the components of XX 22, then the ending , then the ending

value, and last the degrees of freedomvalue, and last the degrees of freedom

XX 22 cdf(cdf(xx22, E99, df) calculator gives you your , E99, df) calculator gives you your

PP-value-value

As long as your calculator isn’t too old, you As long as your calculator isn’t too old, you also have the option of using also have the option of using XX

22 GOF-Test GOF-Test

Page 12: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

ConclusionsConclusions

As always, low P-values lead us to reject As always, low P-values lead us to reject the null hypothesis. We will use the same the null hypothesis. We will use the same standards as before when making our standards as before when making our decisions.decisions.

Don’t forget to make a contextual Don’t forget to make a contextual conclusion in the context of the problem.conclusion in the context of the problem.

Page 13: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Follow Up AnalysisFollow Up Analysis

When you are making your conclusions, if When you are making your conclusions, if you reject the null hypothesis, make sure you reject the null hypothesis, make sure you look at the individual components of you look at the individual components of chi-square to see which categories caused chi-square to see which categories caused chi-square to be large enough to reject the chi-square to be large enough to reject the null hypothesis and comment on these null hypothesis and comment on these categories and their large difference categories and their large difference between what was expected and what between what was expected and what actually occurred.actually occurred.

Page 14: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

An Informal EXAMPLEAn Informal EXAMPLE(meaning not all steps are covered)(meaning not all steps are covered)

In statistics, there are usually 15% A’s, In statistics, there are usually 15% A’s, 50% B’s, 20% C’s, 10% D’s, and 5% F’s 50% B’s, 20% C’s, 10% D’s, and 5% F’s for each test.for each test.On the most recent test, there were 15 On the most recent test, there were 15 A’s, 8 B’s, 5 C’s, 5 D’s, and 9 F’s.A’s, 8 B’s, 5 C’s, 5 D’s, and 9 F’s.Is there sufficient evidence to suggest that Is there sufficient evidence to suggest that the results of this test were significantly the results of this test were significantly different than the standard grades?different than the standard grades?

Page 15: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Work for ExampleWork for Example

LL11 LL22 LL33=(L=(L11-L-L22)) LL4 4 =L=L3322/L/L22

1515 42(.15)= 6.342(.15)= 6.3 8.78.7 12.014312.0143

88 42(.50)= 2142(.50)= 21 -13-13 8.04768.0476

55 42(.20)= 8.442(.20)= 8.4 -3.4-3.4 1.37621.3762

55 42(.10)= 4.242(.10)= 4.2 0.80.8 0.15240.1524

99 42(.05)= 2.142(.05)= 2.1 6.96.9 22.671422.6714

Page 16: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Wrapping up the ExampleWrapping up the Example

sum(Lsum(L44)=44.2619)=44.2619

P-value =XP-value =X 22 cdf(cdf(44.261944.2619, E99, 4)=5.6603E-9, E99, 4)=5.6603E-9

= 0.0000000056603= 0.0000000056603

This indicates that these test results are far from This indicates that these test results are far from what we would expect. However, we had 40% what we would expect. However, we had 40% of our expected values below 5 so these results of our expected values below 5 so these results should be interpreted with caution.should be interpreted with caution.

Page 17: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Example: The Graying of AmericaExample: The Graying of America

In recent years, the expression “the graying of In recent years, the expression “the graying of America” has been used to refer to the belief America” has been used to refer to the belief that with better medicine and healthier lifestyles, that with better medicine and healthier lifestyles, people are living longer, and consequently a people are living longer, and consequently a larger percentage of the population is of larger percentage of the population is of retirement age. We want to investigate whether retirement age. We want to investigate whether this perception is accurate. The distribution of this perception is accurate. The distribution of the U.S. population in 1980 is shown in the table the U.S. population in 1980 is shown in the table on the next slide. We want to determine if the on the next slide. We want to determine if the distribution of age groups in the United States in distribution of age groups in the United States in 1996 has changed significantly from the 1980 1996 has changed significantly from the 1980 distribution.distribution.

Page 18: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

U.S. Population by age group, 1980U.S. Population by age group, 1980

Age GroupAge Group Population Population (in thousands)(in thousands) PercentPercent

0 to 240 to 24 93,77793,777 41.3941.39

25 to 4425 to 44 62,71662,716 27.6827.68

45 to 6445 to 64 44,50344,503 19.6419.64

65 and older65 and older 25,55025,550 11.2811.28

TOTALTOTAL 226,546226,546 100.00100.00

Page 19: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Step 1: ParametersStep 1: ParametersBefore we even see data from our sample (in 1996) we Before we even see data from our sample (in 1996) we can establish our hypotheses based on the scenario can establish our hypotheses based on the scenario describeddescribed

HH00: the age group distribution in 1996 is the same as the : the age group distribution in 1996 is the same as the 1980 distribution1980 distribution

HHaa: the age group distribution in 1996 is different from the : the age group distribution in 1996 is different from the 1980 distribution1980 distributionThe idea of this test (goodness of fit) is this: we compare The idea of this test (goodness of fit) is this: we compare the observed counts for a sample from the 1996 the observed counts for a sample from the 1996 population with the counts that would be expected if the population with the counts that would be expected if the 1996 distribution were the same as the 1980 distribution, 1996 distribution were the same as the 1980 distribution, that is, if Hthat is, if H00 were in fact true. The 1980 distribution is the were in fact true. The 1980 distribution is the population. The more the observed counts differ from the population. The more the observed counts differ from the expected counts, the more evidence we have to reject Hexpected counts, the more evidence we have to reject H00 and conclude that the population distribution in 1996 is and conclude that the population distribution in 1996 is significantly different from that of 1980.significantly different from that of 1980.

Page 20: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

A random sample of 500 U.S. residents in 1996 is selected and A random sample of 500 U.S. residents in 1996 is selected and the age of each subject is recorded. The counts and percents in the age of each subject is recorded. The counts and percents in

each age group category are shown in the following tableeach age group category are shown in the following table

Sample results for 500 randomly selected Sample results for 500 randomly selected individuals in 1996individuals in 1996

Age GroupAge Group PopulationPopulation PercentPercent

0 to 240 to 24 177177 35.435.4

25 to 4425 to 44 158158 31.631.6

45 to 6445 to 64 101101 20.220.2

65 and older65 and older 6464 12.812.8

TOTALTOTAL 500500 100100

Page 21: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Step 2: ConditionsStep 2: ConditionsSRS—We know that we have a random sample of 500 SRS—We know that we have a random sample of 500 individuals from 1996. These should be representative of all individuals from 1996. These should be representative of all U.S. resident in 1996 provided an SRS was used.U.S. resident in 1996 provided an SRS was used.

We also want to make sure that all EXPECTED counts are We also want to make sure that all EXPECTED counts are sufficiently large. As seen below, they are plenty big enough.sufficiently large. As seen below, they are plenty big enough.

EXPECTED COUNTSEXPECTED COUNTS

Age GroupAge Group 1980 Population %1980 Population % Expected counts Expected counts (1996)(1996)

0 to 240 to 24 41.3941.39 500(0.4139)=207.0500(0.4139)=207.0

25 to 4425 to 44 27.6827.68 500(0.2768)=138.4500(0.2768)=138.4

45 to 6445 to 64 19.6419.64 500(0.1964)=98.2500(0.1964)=98.2

65 and older65 and older 11.2811.28 500(0.1128)=56.4500(0.1128)=56.4

TOTALTOTAL 100100 500500

Page 22: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Step 3: CalculationsStep 3: CalculationsWith a goodness of fit test, it is always a good idea to With a goodness of fit test, it is always a good idea to graph the data before proceeding with the test. To do graph the data before proceeding with the test. To do this, create a segmented or side-by-side bar graph to this, create a segmented or side-by-side bar graph to show the comparison effectively.show the comparison effectively.

In order to determine whether the distribution has In order to determine whether the distribution has changed since 1980, we need a way to measure how changed since 1980, we need a way to measure how well the observed counts (O) from 1996 fit the well the observed counts (O) from 1996 fit the expected counts (E) under expected counts (E) under HH00. The procedure is to . The procedure is to calculate (O-E)calculate (O-E)22/E for each age category and then add /E for each age category and then add up these terms to arrive at our chi-square (Xup these terms to arrive at our chi-square (X22) statistic. ) statistic. The larger the differences between the observed and The larger the differences between the observed and expected values, the larger Xexpected values, the larger X22 will be, and the more will be, and the more evidence there will be against evidence there will be against HH00..

Page 23: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Step 3 (continued): CalculationsStep 3 (continued): CalculationsCalculating the Goodness of FitCalculating the Goodness of Fit

Age GroupAge GroupObservedObserved

OO

ExpectedExpected

EE(O-E)(O-E)22/E/E

0 to 240 to 24 177177 207.0207.0 4.34784.3478

25 to 4425 to 44 158158 138.4138.4 2.77572.7757

45 to 6445 to 64 101101 98.298.2 0.07980.0798

65 and older65 and older 6464 56.456.4 1.02411.0241

XX22 8.22758.2275

Since there are 4 age groups, we have 4-1 or 3 degrees of freedom.

We use df=3 and X2=8.2275 to determine that our P-value is 0.0415

Page 24: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Step 4: InterpretationStep 4: InterpretationBased on our low Based on our low PP-value, we will reject the null -value, we will reject the null hypothesis.hypothesis.

The probability of observing a result as extreme as the The probability of observing a result as extreme as the one we actually observed, by chance alone, is less one we actually observed, by chance alone, is less than 5%. than 5%.

We conclude that the population distribution in 1996 is We conclude that the population distribution in 1996 is significantly different from the 1980 distribution.significantly different from the 1980 distribution.

As a follow up analysis, we note that the 0 to 24 age As a follow up analysis, we note that the 0 to 24 age group is considerably smaller than we would expect (if group is considerably smaller than we would expect (if nothing had changed since 1980) in a group of 500 nothing had changed since 1980) in a group of 500 people. This age group was the most noticeably people. This age group was the most noticeably different in 1996 as compared to 1980.different in 1996 as compared to 1980.

Page 25: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

SECTION 14.2SECTION 14.2Inference for Two-Way TablesInference for Two-Way Tables

Chi-square test for homogeneity of populationsChi-square test for homogeneity of populations– Does a single categorical variable have the same Does a single categorical variable have the same

distribution in two or more distinct populations?distribution in two or more distinct populations?

Chi-square test of association/independenceChi-square test of association/independence– Are two categorical variables associated or Are two categorical variables associated or

independent?independent?

Page 26: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

The Big IdeasThe Big IdeasThe relationship between two categorical variables measured The relationship between two categorical variables measured on the same individuals is displayed in a two-way table of on the same individuals is displayed in a two-way table of counts.counts.The chi-square test assesses whether the relationship between The chi-square test assesses whether the relationship between two categorical variables is statistically significant. The test is two categorical variables is statistically significant. The test is based on comparing observed counts in the two-way table to based on comparing observed counts in the two-way table to the counts we would expect if knowing the value of one variable the counts we would expect if knowing the value of one variable gives no information about the other.gives no information about the other.Large values of the chi-square statistic are evidence against the Large values of the chi-square statistic are evidence against the null hypothesis of no relationship. That is, the test is always null hypothesis of no relationship. That is, the test is always one-sided. one-sided. PP-values come from the chi-square distributions.-values come from the chi-square distributions.Because the chi-square test does not look for any particular Because the chi-square test does not look for any particular form of relationship, be sure to describe the observed form of relationship, be sure to describe the observed relationship along with the test.relationship along with the test.

Page 27: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Chi-square test for Two-way tablesChi-square test for Two-way tables

A table is used and laid out by Rows vs Columns. For example a A table is used and laid out by Rows vs Columns. For example a 3x2 table has 3 rows and 2 columns. Rows being horizontal 3x2 table has 3 rows and 2 columns. Rows being horizontal and columns being vertical.and columns being vertical.

Generically, our hypotheses will be:Generically, our hypotheses will be:HHoo: there is no relationship between 2 categorical variables : there is no relationship between 2 categorical variables HHaa: that there is a relationship between 2 categorical variables: that there is a relationship between 2 categorical variables

Expected count = Expected count = row total x column totalrow total x column total table totaltable totalIf the observed counts are far from the expected counts, that is If the observed counts are far from the expected counts, that is

evidence against Hevidence against Hoo..You can safely use the chi-square test when the at least 80% of You can safely use the chi-square test when the at least 80% of

expected counts are greater than 5 and all expected counts are expected counts are greater than 5 and all expected counts are 1 or greater. Of course you also need to make sure the data 1 or greater. Of course you also need to make sure the data comes from one or more SRSs (depending on the scenario).comes from one or more SRSs (depending on the scenario).

Page 28: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Calculator for Two-Way TablesCalculator for Two-Way Tables

Go to matrix and plug the observed values into Go to matrix and plug the observed values into matrix A (row is first number column is second) matrix A (row is first number column is second)

Ex. r=3 c=2; 3x2 matrixEx. r=3 c=2; 3x2 matrix

Then go to Stat:Tests XThen go to Stat:Tests X22 test test

Observed: [A] and it plugs the expected values Observed: [A] and it plugs the expected values into matrix [B] after hitting calculateinto matrix [B] after hitting calculate

It gives you your XIt gives you your X22, your , your PP-value and your -value and your degrees of freedom which are (r-1)(c-1).degrees of freedom which are (r-1)(c-1).

Page 29: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Let’s try one INFORMAL example Let’s try one INFORMAL example (like before, that means this won’t include all steps):(like before, that means this won’t include all steps):

Is there a relationship between your class Is there a relationship between your class and your preference for lunch?and your preference for lunch?

Freshmen Sophomore Junior Senior TOTAL

Bring lunch 334 296 247 236

Buy lunch 297 215 206 133

Don’t eat 56 92 101 86

Go out to lunch 3 40 64 147

TOTAL

WHICH TEST DO WE USE?

Chi-square test of association/independence

Page 30: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Observed vs. ExpectedObserved vs. Expected Freshmen Sophomore Junior Senior TOTAL

Bring lunch 334 296 247 236 1113

Buy lunch 297 215 206 133 851

Don’t eat 56 92 101 86 335

Go out to lunch 3 40 64 147 254

TOTAL 690 643 618 602 2553

Freshmen Sophomore Junior Senior TOTAL

Bring lunch 300.81 280.32 269.42 262.45

Buy lunch 230 214.33 206 200.67

Don’t eat 90.54 84.37 81.09 78.99

Go out to lunch 68.65 63.97 61.49 59.89

TOTAL

The expected count for freshmen that bring their lunch

1113 x 690 / 2553 = 300.81 (Note: these are stored in Matrix [B] )

Page 31: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Running the TestRunning the TestNull hypothesis is that there is no relationship between high school class and lunch preference.

The alternative is that there is a relationship between high school class and lunch preference.

All individual expected counts are at least one (the lowest is 59.89) and since they are all at least 5 then we know that no more than 20% are less than 5.

X2 = 269.33

P-value = 8.19 x 10-53

df = (r - 1)(c - 1) = (4-1)(4-1) = 9Based on the extremely low P-value we reject the null hypothesis and are comfortable accepting the alternative hypothesis.This means that there is a relationship between a students grade level and their lunch preference.

Page 32: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

DON’T FORGET:DON’T FORGET:Follow Up AnalysisFollow Up Analysis

You should do some follow up analysis of the differences between observed and expected values.

This can be more challenging than in the previous section simply because you don’t get a chance to look at the components of chi-square unless you determine them individually.

Instead, you can simply look at the most noticeable raw differences, calculate the component of chi-square for that cell, and see how big a part of your chi-square statistic this would be. This gives a better idea of how important that cell is to making the relationship significant. Essentially, if you reject the null hypothesis, make some comments about what aspects of the relationship led to a high enough chi-square value for this decision.

In this case, the large difference in two cells (freshmen and seniors who go out to eat) were the main reason for a large chi-square statistic (127.58 and 62.78 respectively).

Page 33: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

A Full Example: A Full Example: Health care: Canada and the United StatesHealth care: Canada and the United States

Canada has universal health care. The U.S. does not, Canada has universal health care. The U.S. does not, but often offers more elaborate treatment to patients but often offers more elaborate treatment to patients with access. How do the two systems compare in with access. How do the two systems compare in treating heart attacks? A comparison of random treating heart attacks? A comparison of random samples of 2600 U.S. and 400 Canadian heart attack samples of 2600 U.S. and 400 Canadian heart attack patients found: “The Canadian patients typically patients found: “The Canadian patients typically stayed in the hospital one day longer stayed in the hospital one day longer ((PP-value<0.001),-value<0.001), coronary angioplasty coronary angioplasty (11% vs. 29%, (11% vs. 29%, PP-value<0.001),-value<0.001), and and coronary bypass surgery coronary bypass surgery (3% vs. 14%, (3% vs. 14%, PP-value<0.001).-value<0.001).””The study then looked at many outcomes a year after The study then looked at many outcomes a year after the heart attack. There was no significant difference the heart attack. There was no significant difference in the patients’ survival rate. Another key outcome in the patients’ survival rate. Another key outcome was the patients’ own assessment of their quality of was the patients’ own assessment of their quality of life relative to what it had been before the heart attack. life relative to what it had been before the heart attack. Here are the data for the patients who survived a Here are the data for the patients who survived a year:year:

Page 34: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Patients Who Survived One YearPatients Who Survived One Year

Quality of LifeQuality of Life CanadaCanada United StatesUnited States

Much BetterMuch Better 7575 541541

Somewhat BetterSomewhat Better 7171 498498

About the SameAbout the Same 9696 779779

Somewhat WorseSomewhat Worse 5050 282282

Much WorseMuch Worse 1919 6565

TOTALTOTAL 311311 21652165

Page 35: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

The two-way table shows The two-way table shows the relationship between the relationship between two categorical variables. two categorical variables. The explanatory variable The explanatory variable is the patient’s country is the patient’s country and the response variable and the response variable is the quality of life a year is the quality of life a year after a heart attack. The after a heart attack. The two-way table gives the two-way table gives the counts for all 10 counts for all 10 combinations of values of combinations of values of these variables. Each of these variables. Each of the 10 counts occupies a the 10 counts occupies a cell of the table. It is hard cell of the table. It is hard to compare the counts to compare the counts because the U.S. sample because the U.S. sample is much larger. Here are is much larger. Here are the percents of each the percents of each sample with each sample with each outcome:outcome:

Quality of Quality of LifeLife CanadaCanada United United

StatesStates

Much Much BetterBetter 24%24% 25%25%

Somewhat Somewhat BetterBetter 23%23% 23%23%

About the About the SameSame 31%31% 36%36%

Somewhat Somewhat WorseWorse 16%16% 13%13%

Much Much WorseWorse 6%6% 3%3%

TOTALTOTAL 100%100% 100%100%

NOTICE ANYTHING STRIKINGLY DIFFERENT ABOUT THESE PERCENTS?

Page 36: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Be Careful With AnalysisBe Careful With AnalysisClearly, the first two categories don’t show any Clearly, the first two categories don’t show any difference worth discussing. The last three categories difference worth discussing. The last three categories are off by enough that we may be inclined to use are off by enough that we may be inclined to use procedures from previous chapters to “test” whether procedures from previous chapters to “test” whether one particular category has a significant difference in one particular category has a significant difference in proportions between the U.S. and Canada. If we did proportions between the U.S. and Canada. If we did this, for example, with the “much worse” category, we this, for example, with the “much worse” category, we would find that the proportions are significantly would find that the proportions are significantly different different ((PP-value=0.0047).-value=0.0047). But is it surprising that one of five categories would But is it surprising that one of five categories would differ by this much? differ by this much? – Really, it is “cheating” to pick out the largest of five Really, it is “cheating” to pick out the largest of five

differences and then test its significance as if it were the only differences and then test its significance as if it were the only comparison we had in mind.comparison we had in mind.

Page 37: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

So which test should we perform?So which test should we perform?The chi-square test for homogeneity of populations. The chi-square test for homogeneity of populations. WHY?WHY?– Because our data comes from two distinct populations and Because our data comes from two distinct populations and

we want to determine if there is a significant difference in we want to determine if there is a significant difference in quality of life after a heart attack in the two countries.quality of life after a heart attack in the two countries.

STEP 1: ParametersSTEP 1: Parameters– The null hypothesis is that there is no difference between the The null hypothesis is that there is no difference between the

distributions of outcomes in Canada and the United States. distributions of outcomes in Canada and the United States.

– HH00: there is no relationship between nationality and quality of : there is no relationship between nationality and quality of lifelife

– The alternative hypothesis is that there is a relationship but The alternative hypothesis is that there is a relationship but does not specify any particular kind of relationship.does not specify any particular kind of relationship.

– HHaa: there is some relationship between nationality and quality : there is some relationship between nationality and quality of lifeof life

Page 38: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Step 2: ConditionsStep 2: ConditionsSRS: The data came SRS: The data came from independent from independent random samples from random samples from the two populations of the two populations of interest—Canadian interest—Canadian and U.S. heart attach and U.S. heart attach patients.patients.

Expected counts are Expected counts are all well over 5 so all well over 5 so there are no there are no concerns. Show the concerns. Show the expected counts.expected counts.

Quality of Quality of LifeLife CanadaCanada United United

StatesStates

Much BetterMuch Better 77.3777.37 538.63538.63

Somewhat Somewhat BetterBetter 71.4771.47 497.53497.53

About the About the SameSame 109.91109.91 765.09765.09

Somewhat Somewhat WorseWorse 41.7041.70 290.30290.30

Much Much WorseWorse 10.5510.55 73.4573.45

TOTALTOTAL 311311 21652165

Page 39: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Steps 3 & 4: Steps 3 & 4: Calculations and InterpretationCalculations and Interpretation

XX22=11.725=11.725PP-value = 0.0195-value = 0.0195df = (5-1)(2-1) = 4df = (5-1)(2-1) = 4Since the P-value is so small, we will reject the null Since the P-value is so small, we will reject the null hypothesis. There is quite good evidence that the hypothesis. There is quite good evidence that the distributions of outcomes are different in Canada and distributions of outcomes are different in Canada and the United States.the United States.Follow-up analysis: The biggest contributor to our Follow-up analysis: The biggest contributor to our high chi-square statistic is for Canadians who report a high chi-square statistic is for Canadians who report a much worse quality of life. That cell has a chi-square much worse quality of life. That cell has a chi-square component of 6.766 which is over half of the total chi-component of 6.766 which is over half of the total chi-square statistic. A higher proportion of Canadians square statistic. A higher proportion of Canadians report a much worse quality of life and this is the most report a much worse quality of life and this is the most important difference between the two countries.important difference between the two countries.

Page 40: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

One more quick exampleOne more quick exampleThe type of medical care that a The type of medical care that a patient receives sometimes patient receives sometimes varies with the age of the varies with the age of the patient. For example, women patient. For example, women should receive a mammogram should receive a mammogram and biopsy of any suspicious and biopsy of any suspicious lump in the breast. Here are lump in the breast. Here are data from a study that asked data from a study that asked whether women did receive whether women did receive these diagnostic tests when a these diagnostic tests when a lump in the breast was lump in the breast was discovered.discovered.

Tests Done?Tests Done?

AgeAge NoNo YesYes

45-6445-64 6161 158158

65-7465-74 4040 103103

75-9075-90 5353 7777

Which test should be done for this two-way table?Since a single sample was classified two ways (by age and whether or not a test was done) this setting requires a chi-square test for association/independence.

Page 41: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Running our Chosen TestRunning our Chosen TestSteps 1 & 2: Parameters & ConditionsSteps 1 & 2: Parameters & Conditions

Our null hypothesis is that there is no Our null hypothesis is that there is no relationship between a women’s age and relationship between a women’s age and whether or not she has diagnostic testing done whether or not she has diagnostic testing done when a lump appears on her breast.when a lump appears on her breast.

Our alternative is that there is a relationship Our alternative is that there is a relationship between these two categorical variables.between these two categorical variables.

Assuming that this study used an SRS when Assuming that this study used an SRS when collecting the data, we should be fine using this collecting the data, we should be fine using this test because all of the expected values are well test because all of the expected values are well over 5.over 5.

Page 42: CHAPTER 14 Inference for Distributions of Categorical Variables: Chi-square Procedures.

Steps 3 & 4: Steps 3 & 4: Calculations and InterpretationCalculations and Interpretation

XX22=7.3668=7.3668PP-value = 0.0251-value = 0.0251df = (3-1)(2-1) = 2df = (3-1)(2-1) = 2Based on the low Based on the low PP-value, we will reject -value, we will reject the null hypothesis.the null hypothesis.There is good evidence that the There is good evidence that the proportion of women in the population for proportion of women in the population for whom the tests were done differs among whom the tests were done differs among the three age groups.the three age groups.Comparing the expected values (to the Comparing the expected values (to the right) to the observed values, we can see right) to the observed values, we can see that the most notable difference is for the that the most notable difference is for the older group that did not get the test older group that did not get the test done. We can speculate as to why, but done. We can speculate as to why, but this test does not provide that type of this test does not provide that type of information.information.

Tests Done?Tests Done?

AgeAge NoNo YesYes

45-6445-64 68.5568.55 150.45150.45

65-7465-74 44.7644.76 98.2498.24

75-9075-90 40.6940.69 89.3189.31


Recommended