# contingency analysis. sample test statistic null hypothesis null distribution compare how unusual is...

Post on 16-Dec-2015

219 views

Category:

## Documents

Embed Size (px)

TRANSCRIPT

• Slide 1
• Contingency analysis
• Slide 2
• Sample Test statistic Null hypothesis Null distribution compare How unusual is this test statistic? P < 0.05 P > 0.05 Reject H o Fail to reject H o
• Slide 3
• Using one tail in the 2 We always use only one tail for a 2 test Why?
• Slide 4
• Data match null expectation exactly 0 Data deviate from null expectation in some way
• Slide 5
• Reality Result H o trueH o false Reject H o Do not reject H o correct Type I error Type II error
• Slide 6
• Test statistic If null hypothesis is really true Do not reject Ho Correct answer Reject Ho Type I error
• Slide 7
• Test statistic If null hypothesis is really false Do not reject Ho Type II error Reject Ho correct
• Slide 8
• Errors and statistics These are theoretical - you usually dont know for sure if youve made an error Pr[Type I error] = Pr[Type II error] = Requires power analysis Depends on sample size
• Slide 9
• Contingency analysis Estimates and tests for an association between two or more categorical variables
• Slide 10
• Music and wine buying OBSERVEDFrench music playing German music playing Totals Bottles of French wine sold 401252 Bottles of German wine sold 82230 Totals483482
• Slide 11
• Mosaic plot
• Slide 12
• Odds ratio Odds of success = probability of success divided by the probability of failure
• Slide 13
• Estimating the Odds ratio Odds of success = probability of success divided by the probability of failure
• Slide 14
• Music and wine buying OBSERVEDFrench music playing Bottles of French wine sold 40 Bottles of German wine sold 8 Totals48
• Slide 15
• Example Out of 48 bottles of wine, 40 were French
• Slide 16
• Example Out of 48 bottles of wine, 40 were French Interpretation: people are about 5 times more likely to buy a French wine
• Slide 17
• O=1 Success and failure equally likely Success more likely Failure more likely
• Slide 18
• Odds ratio The odds of success in one group divided by the odds of success in a second group
• Slide 19
• Estimating the Odds ratio The odds of success in one group divided by the odds of success in a second group
• Slide 20
• Music and wine buying Group 1 = French music, Group 2 = German music Success = French wine
• Slide 21
• Group 2 Out of 34 bottles of wine, 12 were French
• Slide 22
• Music and wine buying Group 1 = French music, Group 2 = German music Success = French wine
• Slide 23
• Music and wine buying Group 1 = French music, Group 2 = German music Success = French wine Interpretation: people are about 9 times more likely to buy French wine in Group 1 compared to Group 2
• Slide 24
• OR=1 Success more likely in Group 1 Success more likely in Group 2 Success equally likely in both groups
• Slide 25
• Hypothesis testing Contingency analysis Is there a difference in odds between two groups?
• Slide 26
• Hypothesis testing Contingency analysis Is there an association between two categorical variables?
• Slide 27
• Music and wine buying OBSERVEDFrench music playing German music playing Totals Bottles of French wine sold 401252 Bottles of German wine sold 82230 Totals483482
• Slide 28
• Contingency analysis Is there a difference in the odds of buying French wine depending on the music that is playing? Is there an association between wine bought and music playing? Is the nationality of the wine independent of the music playing when it is sold?
• Slide 29
• Hypotheses H 0 : The nationality of the bottle of wine is independent of the nationality of the music played when it is sold. H A : The nationality of the bottle of wine sold depends on the nationality of the music being played when it is sold.
• Slide 30
• Calculating the expectations With independence, Pr[ French wine AND French music] = Pr[French wine] Pr[French music]
• Slide 31
• Calculating the expectations Pr[French wine] = 52/82=0.634 Pr[French music] = 48/82= 0.585 OBS.French music German music Totals French wine sold 52 German wine sold 30 Totals 483482 By H 0, Pr[French wine AND French music] = (0.634)(0.585)=0.37112
• Slide 32
• Calculating the expectations EXP.French musicGerman musicTotals French wine sold 0.37 (82) = 30.4 52 German wine sold 30 Totals 483482 By H 0, Pr[French wine AND French music] = (0.634)(0.585)=0.37112
• Slide 33
• Calculating the expectations EXP.French musicGerman musicTotals French wine sold 0.37 (82) = 30.4 21.652 German wine sold 17.612.430 Totals 483482
• Slide 34
• 22
• Slide 35
• Degrees of freedom For a 2 Contingency test, df = # categories -1- # parameters df= (# columns -1)(# rows -1) For music/wine example, df = (2-1)(2-1) = 1
• Slide 36
• Conclusion 2 = 20.0 >> 2 = 3.84, So we can reject the null hypothesis of independence, and say that the nationality of the wine sold did depend on what music was played.
• Slide 37
• Assumptions This 2 test is just a special case of the 2 goodness-of-fit test, so the same rules apply. You cant have any expectation less than 1, and no more than 20% < 5
• Slide 38
• Fishers exact test For 2 x 2 contingency analysis Does not make assumptions about the size of expectations JMP will do it, but cumbersome to do by hand
• Slide 39
• Other extensions you might see Yates correction for continuity G-test Read about these in your book