Presentation is loading. Please wait.

Presentation is loading. Please wait.

Statistical analyses for two- way contingency tables HRP 261 January 10, 2005 Read Chapter 2 Agresti.

Similar presentations


Presentation on theme: "Statistical analyses for two- way contingency tables HRP 261 January 10, 2005 Read Chapter 2 Agresti."— Presentation transcript:

1 Statistical analyses for two- way contingency tables HRP 261 January 10, 2005 Read Chapter 2 Agresti

2 Overview of statistical tests for two-way contingency tables Table Size Test or measures of association 2x2risk ratio odds ratio Chi-square difference in proportions Fischer’s Exact test (cell size less than 5) RxCChi-square Fischer’s Exact test (cell size less than 5)

3 Exposure (E)No Exposure (~E) Disease (D)ab No Disease (~D)cd a+cb+d risk to the exposed risk to the unexposed Review: The Risk Ratio (RR)

4 Exposure (E)No Exposure (~E) Disease (D)a = P (D& E)b = P(D& ~E) No Disease (~D)c = P (~D&E)d = P (~D&~E) Review: The Odds Ratio (OR) Odds of disease in the exposed Odds of disease in the unexposed

5 Practice Problem: Suppose the following data were collected on a random (cross-sectional) sample of teenagers: Calculate the odds ratio and risk ratio for the association between exposure to smoking in movies and smoking behavior. Ever tried smoking Never smoked Exposed to high occurrence of smoking in films 100300 Lower exposure to smoking in films 30370

6 Answer OR = (100*370)/(30*300) = 4.11 RR = (100/400=.25)/(30/400=.075) = 3.33 Ever tried smokingNever smoked Exposed to high occurrence of smoking in films 100300 Lower exposure to smoking in films 30370

7 Standard error of the difference of two proportions=Standard error of a proportion= Null distribution of a difference in proportions Standard error can be estimated by= (still normally distributed) The variance of a difference is the sum of variances (for independent samples) Simply the overall proportion of positive outcomes in the total sample.

8 Null distribution of a difference in proportions Difference of proportions

9 Difference of proportions… Example An August 2003 research article in Developmental and Behavioral Pediatrics reported the following about a sample of UK kids: when given a choice of a non-branded chocolate cereal vs. CoCo Pops, 97% (36) of 37 girls and 71% (27) of 38 boys preferred the CoCo Pops. Is this evidence that girls are more likely to choose brand-named products?

10 Answer 1. Hypotheses: H0: p ♂ -p ♀ = 0 Ha: p ♂ -p ♀ ≠ 0 [two-sided] 2. Null distribution of difference of two proportions: 3. Observed difference in our experiment =.97-.71=.26 4. Calculate the p-value of what you observed: p<.01 5. p-value is sufficiently low for us to reject the null; there does appear to be a difference in gender preferences here. Null says p’s are equal so estimate standard error using overall observed p

11 Ever SmokedNever smoked High exposure to smoking in film 100300400 Low exposure 30370400 130670800 Difference of two proportions…

12 Corresponding confidence interval

13 Chi-square test for comparing proportions (of a categorical variable) between groups Chi-Square Test of Independence When both your predictor and outcome variables are categorical, they may be cross- classified in a contingency table and compared using a chi-square test of independence. A contingency table with R rows and C columns is an R x C contingency table.

14 Example Asch, S.E. (1955). Opinions and social pressure. Scientific American, 193, 31-35.

15 The Experiment A Subject volunteers to participate in a “visual perception study.” Everyone else in the room is actually a conspirator in the study (unbeknownst to the Subject). The “experimenter” reveals a pair of cards…

16 The Task Cards Standard lineComparison lines A, B, and C

17 The Experiment Everyone goes around the room and says which comparison line (A, B, or C) is correct; the true Subject always answers last – after hearing all the others’ answers. The first few times, the 7 “conspirators” give the correct answer. Then, they start purposely giving the (obviously) wrong answer. 75% of Subjects tested went along with the group’s consensus at least once.

18 Further Results In a further experiment, group size (number of conspirators) was altered from 2-10. Does the group size alter the proportion of subjects who conform?

19 The Chi-Square test Conformed? Number of group members? 246810 Yes 2050756030 No8050254070 Apparently, conformity less likely when less or more group members…

20 20 + 50 + 75 + 60 + 30 = 235 conformed out of 500 experiments. Overall likelihood of conforming = 235/500 =.47

21 Calculating the expected, in general Null hypothesis: variables are independent Recall that under independence: P(A)*P(B)=P(A&B) Therefore, calculate the marginal probability of B and the marginal probability of A. Multiply P(A)*P(B)*N to get the expected cell count.

22 Expected frequencies if no association between group size and conformity… Conformed? Number of group members? 246810 Yes 47 No53

23 Do observed and expected differ more than expected due to chance?

24 Chi-Square test Degrees of freedom = (rows-1)*(columns-1)=(2-1)*(5-1)=4

25 The Chi-Square distribution: is sum of squared normal deviates The expected value and variance of a chi- square: E(x)=df Var(x)=2(df)

26 Chi-Square test Rule of thumb: if the chi-square statistic is much greater than it’s degrees of freedom, indicates statistical significance. Here 85>>4. Degrees of freedom = (rows-1)*(columns-1)=(2-1)*(5-1)=4

27 Caveat **When the sample size is very small in any cell (<5), Fischer’s exact test is used as an alternative to the chi-square test.

28 Same data, but use Chi-square test Ever SmokedNever smoked High exposure smoking in film 100300400 Low exposure 30370400 130670800

29 Fisher’s Exact Test

30 Fisher’s “Tea-tasting experiment” (p. 40 Agresti) Claim: Fisher’s colleague (call her “Cathy”) claimed that, when drinking tea, she could distinguish whether milk or tea was added to the cup first. To test her claim, Fisher designed an experiment in which she tasted 8 cups of tea (4 cups had milk poured first, 4 had tea poured first). Null hypothesis: Cathy’s guessing abilities are no better than chance. Alternatives hypotheses: Right-tail: She guesses right more than expected by chance. Left-tail: She guesses wrong more than expected by chance

31 Fisher’s “Tea-tasting experiment” (p. 40 Agresti) Experimental Results: MilkTea Milk31 Tea13 Guess poured first Poured First 4 4

32 Fisher’s Exact Test Step 1: Identify tables that are as extreme or more extreme than what actually happened: Here she identified 3 out of 4 of the milk-poured-first teas correctly. Is that good luck or real talent? The only way she could have done better is if she identified 4 of 4 correct. MilkTea Milk31 Tea13 Guess poured first Poured First 4 4 MilkTea Milk40 Tea04 Guess poured first Poured First 4 4

33 Fisher’s Exact Test Step 2: Calculate the probability of the tables (assuming fixed marginals) MilkTea Milk31 Tea13 Guess poured first Poured First 4 4 MilkTea Milk40 Tea04 Guess poured first Poured First 4 4

34 Step 3: to get the left tail and right-tail p-values, consider the probability mass function: Probability mass function of X, where X= the number of correct identifications of the cups with milk-poured-first: “right-hand tail probability”: p=.243 “left-hand tail probability” (testing the null hypothesis that she’s systematically wrong): p=.986

35 SAS code and output for generating Fisher’s Exact statistics for 2x2 table MilkTea Milk31 Tea13 4 4

36 data tea; input MilkFirst GuessedMilk Freq; datalines; 1 1 3 1 0 1 0 1 1 0 0 3 run; data tea2; *Fix quirky reversal of SAS 2x2 tables; set tea; MilkFirst=1-MilkFirst; GuessedMilk=1-GuessedMilk;run; proc freq data=tea2; tables MilkFirst*GuessedMilk /exact; weight freq;run;

37 SAS output Statistics for Table of MilkFirst by GuessedMilk Statistic DF Value Prob ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Chi-Square 1 2.0000 0.1573 Likelihood Ratio Chi-Square 1 2.0930 0.1480 Continuity Adj. Chi-Square 1 0.5000 0.4795 Mantel-Haenszel Chi-Square 1 1.7500 0.1859 Phi Coefficient 0.5000 Contingency Coefficient 0.4472 Cramer's V 0.5000 WARNING: 100% of the cells have expected counts less than 5. Chi-Square may not be a valid test. Fisher's Exact Test ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ Cell (1,1) Frequency (F) 3 Left-sided Pr <= F 0.9857 Right-sided Pr >= F 0.2429 Table Probability (P) 0.2286 Two-sided Pr <= P 0.4857 Sample Size = 8

38 Sample Size needed for comparing two proportions: Example: I am going to run a case-control study to determine if pancreatic cancer is linked to drinking coffee. If I want 80% power to detect a 10% difference in the proportion of coffee drinkers among cases vs. controls (if coffee drinking and pancreatic cancer are linked, we would expect that a higher proportion of cases would be coffee drinkers than controls), how many cases and controls should I sample? About half the population drinks coffee.

39 Derivation of a sample size formula: Variance of a proportion = Variance of difference of 2 (independent) proportions = The standard error of the difference of two proportions is:

40 Here, if we assume equal sample size and that, under the null hypothesis proportions of coffee drinkers is.5 in both cases and controls, then s.e.(diff)= Derivation of a sample size formula:

41 Sample size: difference of proportions Null distrib: difference is 0; d null =0 Alternative distrib: difference is.10 d alternative =.10 Critical value = 0 +1.96 (standard error) If you are 1.96 Z-scores above 0, then you will reject the null.

42 Because it’s difficult to tell people to look up the area to the right of –Z, we make a little fudge here and present the formula without the negative sign and allow people to look up area to the left of +Z.

43 For 80% power… There is 80% area to the left of a Z-score of.84 on a standard normal curve; therefore, there is 80% area to the right of -.84. Would take 392 cases and 392 controls to have 80% power! Total=784

44 Question 2: How many total cases and controls would I have to sample to get 80% power for the same study, if I sample 2 controls for every case? Ask yourself, what changes here?

45 Different size groups… Need: 294 cases and 2x294=588 controls. 882 total. Note: you get the best power for the lowest sample size if you keep both groups equal (882 > 784). You would only want to make groups unequal if there was an obvious difference in the cost or ease of collecting data on one group. E.g., cases of pancreatic cancer are rare and take time to find.

46 General sample size formula

47 General sample size needs when outcome is binary:


Download ppt "Statistical analyses for two- way contingency tables HRP 261 January 10, 2005 Read Chapter 2 Agresti."

Similar presentations


Ads by Google