


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















r × k contingency tableFishers exact test
Timothy Hanson
Department of Statistics, University of South Carolina
Stat 506: Introduction to Experimental Design
r × k contingency tableFishers exact test
So far we have considered designs that have led to continuous outcomes, e.g. hours until bond failure, number of salable flowers, etc. Many experimental designs lead to discrete outcomes, with the simplest being whether some event has occurred, e.g. cancer going into remission, cure of a rash, etc. Without loss of generality, we will consider binary outcomes of “success” and “failure”. As with continuous data, the simplest design is to consider one factor with two levels; this is where we start.
r × k contingency tableFishers exact test
Migraine headache patients took part in a double-blind clinical trial to assess experimental surgery. 75 patients were randomly assigned to real surgery on migraine trigger sites (n 1 = 49) or sham surgery (n 2 = 26) in which an incision was made but nothing else. The surgeons hoped that patients would experience “a substantial reduction in migraine headaches,” which we will label as success.
r × k contingency tableFishers exact test
ˆp 1 = 41/49 = 83.7% for real surgeries. ˆp 2 = 15/26 = 57.7% for sham surgeries. Real appears to be better than sham, but is this difference significant?
r × k contingency tableFishers exact test
p 1 and p 2 are conditional probabilities. For the migraine data, p 1 = P{success|real} and p 2 = P{success|sham}. ˆp 1 = 0.84 and ˆp 2 = 0.58 estimate these conditional probabilities. For the HIV testing data, p 1 = P{tested|female} and p 2 = P{tested|male}. ˆp 1 = 0.15 and ˆp 2 = 0.14 estimate these conditional probabilities.
r × k contingency tableFishers exact test
No difference between groups when H 0 : p 1 = p 2 is true. That is, H 0 : P{success|group 1} = P{success|group 2}. If H 0 is true then the outcome (migraine reduction, being tested for HIV, etc.) is independent of the group. This is tested using the chi-square statistic
χ^2 S =
i=
(oi − ei )^2 ei
where i = 1, 2 , 3 , 4 are the four cells in the middle of the contingency table. The oi are the observed counts and the ei are what’s expected if p 1 = p 2.
r × k contingency tableFishers exact test
χ^2 S = (41^ −^36 .59)
2
(15 − 19 .41)^2
(8 − 12 .41)^2
(11 − 6 .59)^2
r × k contingency tableFishers exact test
When H 0 : p 1 = p 2 is true, χ^2 S has a χ^21 distribution, chi-square with 1 degree of freedom. The P-value is the tail probability of a chi-square density with 1 df greater than what we saw χ^2 S. The P-value is the probability of seeing ˆp 1 and ˆp 2 even further away from each other than what we saw. We can get the P-value out of R using chisq.test, but now we need to put in a contingency table in the form of a matrix to get our P-value.
r × k contingency tableFishers exact test
To get the usual statistic and P-value, we have to turn the Yates correction “off” using chisq.test(surgery,correct=FALSE).
chisq.test(surgery,correct=FALSE) Pearson’s Chi-squared test data: surgery X-squared = 6.0619, df = 1, p-value = 0. We reject H 0 : p 1 = p 2 at the 5% level. The surgery significantly reduces migraines. Either P-value = 0.029 (using Yate’s) or P-value = 0. 014 (regular) is fine.
r × k contingency tableFishers exact test
There are two ways to collect 2 × 2 contingency table data. Cross-sectional data is collected by randomly sampling n individuals and cross-classifying them on two variables. Example Ask n = 143 random individuals two questions: salary high/low and education high-school/college. The row and column totals are random. Product binomial data is collected when a fixed number from one group is sampled, and a fixed number from another group is sampled. Example: Real vs. sham surgery for migraine.
r × k contingency tableFishers exact test
A random sample of college students found that 13 of them had gotten a flu shot at the beginning of the winter and 28 had not. Of the 13 who had a flu shot, 3 got the flu during the winter. Of the 28 who did not get a flu shot, 15 got the flu.
Want to test H 0 : p 1 = p 2 vs. H 0 : p 1 > p 2 where p 1 is probability of getting flu among those without shots and p 2 is probability of getting flu among those that got shots.
r × k contingency tableFishers exact test
Tables where p 1 and p 2 are even further apart in the direction of HA : p 1 > p 2
P-value = 0.05298 + 0.01174 + 0.00138 + 0.00006 = 0. 06616.
r × k contingency tableFishers exact test
Using fisher.test we can test H 0 : p 1 = p 2 versus one of (a) HA : p 1 6 = p 2 , (b) HA : p 1 < p 2 , or (c) HA : p 1 > p 2. Use alternative="two.sided" (the default) or alternative="less" or alternative="greater". Fisher’s test is better than the chi-square test; just use the Fisher test in your homework. You will use chisq.test for tables larger than 2 × 2 instead, our next topic...
r × k contingency tableFishers exact test
The number of categories is generalized to r instead of 2. The number of groups is generalized to k instead of 2. Still want to test H 0 : the probabilities of being in each of the r categories do not change across the k groups. In the next example, r = 3 categories (agricultural field, prairie dog habitat, grassland) and k = 3 groups (2004, 2005, 2006).