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 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
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:
Marginal distribution The marginal distributions (in the “margins” of the table) summarize each factor independently Marginal distribution for parental smoking: P(both parent) = 1780/5375 = 33.1% P(one parent) = 41.7% P(neither parent) = 25.2%
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% Conditional distribution
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.
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”)
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.
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.
25*26/74 ≈ * * * * * *0.65 Desipramine Lithium Placebo 35% Expected % Observed % Expected relapse counts No Yes
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.
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.
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
Table D Ex: df = 6 If 2 = 15.9 the P-value is between 0.01 −0.02.
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: P > The P-value is very small (JMP gives P = ) and we reject H 0. There is a significant relationship between treatment type (desipramine, lithium, placebo) and outcome (relapse or not).
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
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?
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 % 17%
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 % 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!
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