Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9 Chapter 22. Tests for two-way tables. Objectives (PSLS Chapter 22) The chi-square test for two-way tables (Award: NHST Test for Independence)[B.

Similar presentations


Presentation on theme: "Lecture 9 Chapter 22. Tests for two-way tables. Objectives (PSLS Chapter 22) The chi-square test for two-way tables (Award: NHST Test for Independence)[B."— Presentation transcript:

1 Lecture 9 Chapter 22. Tests for two-way tables

2 Objectives (PSLS Chapter 22) The chi-square test for two-way tables (Award: NHST Test for Independence)[B level]  Two-way tables  Hypotheses for the chi-square test for two-way tables  Expected counts in a two-way table  Conditions for the chi-square test  Chi-square test for two-way tables of fit  Simpson’s paradox

3 4001380 4161823 1881168 An experiment has a two-way factorial design if two categorical factors are studied with several levels of each factor. Two-way tables organize data about two categorical variables with any number of levels/treatments obtained from a factorial design design or two-way observational study. Two-way tables First factor: Parent smoking status Second factor: Student smoking status High school students were asked whether they smoke, and whether their parents smoke:

4 Marginal distribution The marginal distributions (in the “margins” of the table) summarize each factor independently. 4001380 4161823 1881168 Marginal distribution for parental smoking: P(both parent) = 1780/5375 = 33.1% P(one parent) = 41.7% P(neither parent) = 25.2%

5 The cells of the two-way table represent the intersection of a given level of one factor with a given level of the other factor. They represent the conditional distributions. Conditional distribution of student smoking for different parental smoking statuses: P(student smokes | both parent) = 400/1780 = 22.5% P(student smokes | one parent) = 416/2239 =18.6% P(student smokes | neither parent) = 188/1356 = 13.9% 4001380 4161823 1881168 Conditional distribution

6 Hypotheses A two-way table has r rows and c columns. H 0 states that there is no association between the row and column variables in the table. Statistical Hypotheses H 0 : There is no association between the row and column variables H a : There is an association/relationship between the 2 variables We will compare actual counts from the sample data with the counts we would expect if the null hypothesis of no relationship were true.

7 Cocaine addiction Cocaine produces short-term feelings of physical and mental well being. To maintain the effect, the drug may have to be taken more frequently and at higher doses. After stopping use, users will feel tired, sleepy and depressed. A study compares the rates of successful rehabilitation for cocaine addicts following 1 of 3 treatment options: 1: antidepressant treatment (desipramine) 2: standard treatment (lithium) 3: placebo (“sugar pill”)

8 Cocaine addiction What should be the expected cell counts if relapse is independent of the treatment. In other words, there is no association between treatment and relapse.

9 Expected counts in a two-way table A two-way table has r rows and c columns. H 0 states that there is no association between the row and column variables (factors) in the table. The expected count in any cell of a two-way table when H 0 is true is: The expected count is the average count you would get for that cell if the null hypotheses was true.

10 25*26/74 ≈ 8.78 25*0.35 16.22 25*0.65 9.14 26*0.35 16.86 25*0.65 8.08 23*0.35 14.92 25*0.65 Desipramine Lithium Placebo 35% Expected % Observed % Expected relapse counts No Yes

11 Situations appropriate for the chi-square test The chi-square test for two-way tables looks for evidence of association between multiple categorical variables (factors) in sample data. The samples can be drawn either:  By randomly selecting SRSs from different populations (or from a population subjected to different treatments)  girls vaccinated for HPV or not, among 8th graders and 12th graders  remission or no remission for different treatments  Or by taking 1 SRS and classifying the individuals according to 2 categorical variables (factors)  11 th graders’ smoking status and parents’ status When looking for associations between two categorical/nominal variables.

12 We can safely use the chi-square test when:  no more than 20% of expected counts are less than 5 (< 5)  all individual expected counts are 1 or more (≥1) What goes wrong? With small expected cell counts the sampling distribution will not be chi-square distributed. Statistician’s note: If one factor has many levels and too many expected counts are too low, you might be able to “collapse” some of the levels (regroup them) and thus have large-enough expected counts.

13 P-value: P(  2 variable ≥ calculated  2 | H 0 is true) The  2 statistic sums over all r x c cells in the table When H 0 is true, the  2 statistic follows ~  2 distribution with (r-1)(c-1) degrees of freedom. The chi-square test for two-way tables H 0 : there is no association between the row and column variables H a : H 0 is not true

14 Table D Ex: df = 6 If  2 = 15.9 the P-value is between 0.01 −0.02.

15 15 8.78 10 16.22 7 9.14 19 16.86 4 8.08 19 14.92 Desipramine Lithium Placebo No relapse Relapse Table of counts: “actual/expected,” with three rows and two columns: df = (3 − 1)(2 − 1) = 2 We compute the X 2 statistic: Using Table D: 10.60 P > 0.0025 The P-value is very small (JMP gives P = 0.0047) and we reject H 0.  There is a significant relationship between treatment type (desipramine, lithium, placebo) and outcome (relapse or not).

16 Interpreting the  2 output When the  2 test is statistically significant: The largest components indicate which condition(s) are most different from H 0. You can also compare the observed and expected counts, or compare the computed proportions in a graph. The largest X 2 component, 4.41, is for desipramine/norelapse. Desipramine has the highest success rate (see graph).  2 components Desipramine Lithium Placebo No relapse Relapse

17 Influence of parental smoking Here is a computer output for a chi-square test performed on the data from a random sample of high school students (rows are parental smoking habits, columns are the students’ smoking habits). What does it tell you? Is the sample size sufficient? What are the hypotheses? Are the data ok for a  2 test? What else should you ask? What is your interpretation?

18 Caution with categorical data An association that holds for all of several groups can reverse direction when the data are combined to form a single group. This reversal is called Simpson's paradox. Kidney stones It turns out that for any given patient that PCNL is more likely to result in failure. Can you think of a reason why? A study compared the success rates of two different procedures for removing kidney stones: open surgery and percutaneous nephrolithotomy (PCNL), a minimally invasive technique. 273 289 77 61 22% 17%

19 The procedures are not chosen randomly by surgeons! In fact, the minimally invasive procedure is most likely used for smaller stones (with a good chance of success) whereas open surgery is likely used for more problematic conditions. 273 289 77 61 22% 17% For both small stones and large stones, open surgery has a lower failure rate. This is Simpson’s paradox. The more challenging cases with large stones tend to be treated more often with open surgery, making it appear as if the procedure were less reliable overall. Beware of lurking variables!

20 Objectives (PSLS Chapter 22) The chi-square test for two-way tables (Award: NHST Test for Independence)[B level]  Two-way tables  Hypotheses for the chi-square test for two-way tables  Expected counts in a two-way table  Conditions for the chi-square test  Chi-square test for two-way tables of fit  Simpson’s paradox


Download ppt "Lecture 9 Chapter 22. Tests for two-way tables. Objectives (PSLS Chapter 22) The chi-square test for two-way tables (Award: NHST Test for Independence)[B."

Similar presentations


Ads by Google