STAT 250 Dr Kari Lock Morgan Testing for

  • Slides: 34
Download presentation
STAT 250 Dr. Kari Lock Morgan Testing for an Association between two Categorical Variables

STAT 250 Dr. Kari Lock Morgan Testing for an Association between two Categorical Variables SECTION 7. 2 • χ2 test for association (7. 2) Statistics: Unlocking the Power of Data Lock 5

Painkillers and Miscarriage �Is use of painkillers during pregnancy associated with miscarriage? �Scientists interviewed

Painkillers and Miscarriage �Is use of painkillers during pregnancy associated with miscarriage? �Scientists interviewed 1009 women soon after they got a positive pregnancy test about their use of painkillers around the time of conception or the early weeks of pregnancy �The researchers then kept track of which of the pregnancies ended in miscarriage Li, D-K. , et. al. (2003). “Exposure to non-steroidal anti-inflammatory drugs during pregnancy and risk of miscarriage: population based cohort study, ” British Medical Journal, 327(7411): 1. Statistics: Unlocking the Power of Data Lock 5

Painkillers and Miscarriage 103 5 13 No Miscarriage 659 17 40 TOTAL 762 22

Painkillers and Miscarriage 103 5 13 No Miscarriage 659 17 40 TOTAL 762 22 53 Acetaminophen 24 148 172 TOTAL 145 864 1009 No painkiller Aspirin Ibuprofen �Does this data provide evidence that these two variables are associated? Statistics: Unlocking the Power of Data Lock 5

Two Categorical Variables • The statistics behind a χ2 test easily extends to two

Two Categorical Variables • The statistics behind a χ2 test easily extends to two categorical variables • A χ2 test for association (often called a χ2 test for independence) tests for an association between two categorical variables • Everything is the same as a chi-square goodness-of-fit test, except: • The hypotheses • The expected counts • Degrees of freedom for the χ2 -distribution Statistics: Unlocking the Power of Data Lock 5

Hypotheses �General hypotheses: H 0: The two variables are not associated Ha: The two

Hypotheses �General hypotheses: H 0: The two variables are not associated Ha: The two variables are associated �Painkillers and miscarriage: H 0: Type of painkiller taken is not associated with whether or not pregnancy ends in miscarriage Ha: Type of painkiller taken is associated with whether or not pregnancy ends in miscarriage Statistics: Unlocking the Power of Data Lock 5

Expected Counts Miscarriage No painkiller Aspirin Ibuprofen Acetaminophen TOTAL 762 22 53 172 145

Expected Counts Miscarriage No painkiller Aspirin Ibuprofen Acetaminophen TOTAL 762 22 53 172 145 Statistics: Unlocking the Power of Data 864 1009 Lock 5

Expected Count Miscarriage No painkiller Aspirin Ibuprofen Acetaminophen TOTAL 762 22 53 172 145

Expected Count Miscarriage No painkiller Aspirin Ibuprofen Acetaminophen TOTAL 762 22 53 172 145 864 1009 Give the expected count for Aspirin, Miscarriage. a) 2. 1 b) 3. 16 c) 4. 72 d) 5. 65 Statistics: Unlocking the Power of Data Lock 5

Chi-Square Statistic �Observed (expected) No painkiller Aspirin Ibuprofen Acetaminophen TOTAL Miscarriage 103 (109. 5)

Chi-Square Statistic �Observed (expected) No painkiller Aspirin Ibuprofen Acetaminophen TOTAL Miscarriage 103 (109. 5) 5( ) 13 (7. 6) No Miscarriage 659 (652. 5) 17 (18. 8) 40 (45. 4) TOTAL 762 22 53 24 (24. 7) 145 148 (147. 3) 864 172 1009 Statistics: Unlocking the Power of Data Lock 5

Chi-Square Statistic No painkiller Aspirin Ibuprofen Acetaminophen Miscarriage 103 (109. 5) 5 (3. 16)

Chi-Square Statistic No painkiller Aspirin Ibuprofen Acetaminophen Miscarriage 103 (109. 5) 5 (3. 16) 13 (7. 6) No Miscarriage 659 (652. 5) 17 (18. 8) 40 (45. 4) 24 (24. 7) 148 (147. 3) Give the contribution to the χ2 statistic for the Aspirin, Miscarriage category. a) 0. 7 b) 1. 07 c) 1. 7 d) 2. 07 Statistics: Unlocking the Power of Data Lock 5

Stat. Key χ2 = 6. 168 Statistics: Unlocking the Power of Data Lock 5

Stat. Key χ2 = 6. 168 Statistics: Unlocking the Power of Data Lock 5

What Next? �χ2 = 6. 168 �What next? Statistics: Unlocking the Power of Data

What Next? �χ2 = 6. 168 �What next? Statistics: Unlocking the Power of Data Lock 5

Randomization Distribution Statistics: Unlocking the Power of Data Lock 5

Randomization Distribution Statistics: Unlocking the Power of Data Lock 5

Conclusion Can we conclude that type of painkiller taken is associated with having a

Conclusion Can we conclude that type of painkiller taken is associated with having a miscarriage? a) Yes b) No Statistics: Unlocking the Power of Data Lock 5

Conclusion Can we conclude that type of painkiller taken is not associated with having

Conclusion Can we conclude that type of painkiller taken is not associated with having a miscarriage? a) Yes b) No Statistics: Unlocking the Power of Data Lock 5

Chi-Square (χ2) Distribution • If each of the expected counts are at least 5,

Chi-Square (χ2) Distribution • If each of the expected counts are at least 5, AND if the null hypothesis is true, then the χ2 statistic follows a χ2 –distribution, with degrees of freedom equal to df = (number of rows – 1)(number of columns – 1) • Painkillers and Miscarriage: df = (4 – 1)(2 – 1) = 3 Statistics: Unlocking the Power of Data Lock 5

Theoretical Distribution No painkiller Aspirin Ibuprofen Acetaminophen Miscarriage No Miscarriage 103 (109. 5) 659

Theoretical Distribution No painkiller Aspirin Ibuprofen Acetaminophen Miscarriage No Miscarriage 103 (109. 5) 659 (652. 5) 5 (3. 16) 17 (18. 8) 13 (7. 6) 40 (45. 4) 24 (24. 7) 148 (147. 3) Can we also use theoretical χ2 distribution to get the p-value? a) Yes b) No Statistics: Unlocking the Power of Data Lock 5

NSAIDs? �Headline coming out of this paper: Use of NSAIDs in pregnancy increases risk

NSAIDs? �Headline coming out of this paper: Use of NSAIDs in pregnancy increases risk of miscarriage �NSAIDs (Nonsteroidal anti-inflammatory drugs) are a special class of painkillers that include aspirin and ibuprofen (but not acetaminophen) �Is taking NSAIDs or not associated with miscarriage? Statistics: Unlocking the Power of Data Lock 5

NSAIDs and Miscarriage No painkiller Aspirin Ibuprofen Miscarriage No Miscarriage 103 659 5 17

NSAIDs and Miscarriage No painkiller Aspirin Ibuprofen Miscarriage No Miscarriage 103 659 5 17 13 40 TOTAL 762 22 53 Acetaminophen 24 148 172 TOTAL 145 864 1009 No NSAIDs TOTAL Miscarriage No Miscarriage 127 807 18 57 145 864 Statistics: Unlocking the Power of Data TOTAL 934 75 1009 Lock 5

NSAIDs and Miscarriage No NSAIDs TOTAL Miscarriage No Miscarriage 127 807 18 57 145

NSAIDs and Miscarriage No NSAIDs TOTAL Miscarriage No Miscarriage 127 807 18 57 145 864 TOTAL 934 75 1009 How should we analyze this data? a) Test for difference in proportions using a randomization test b) Test for a difference in proportions using the zstatistic and normal distribution c) Chi-Square Test for Association d) Any of the above e) None of the above Statistics: Unlocking the Power of Data Lock 5

Two Categorical Variables with Two Categories �If you are testing for an association between

Two Categorical Variables with Two Categories �If you are testing for an association between two categorical variables each with two categories, test for a difference in proportions and chi-square test for association will give you identical p-values Statistics: Unlocking the Power of Data Lock 5

Hypotheses �H 0: taking NSAIDs around the time of conception or early in pregnancy

Hypotheses �H 0: taking NSAIDs around the time of conception or early in pregnancy is not associated with having a miscarriage �Ha: taking NSAIDs around the time of conception or early in pregnancy is associated with having a miscarriage Statistics: Unlocking the Power of Data Lock 5

Expected Counts No NSAIDs TOTAL Miscarriage 127 18 145 No Miscarriage 807 57 864

Expected Counts No NSAIDs TOTAL Miscarriage 127 18 145 No Miscarriage 807 57 864 TOTAL 934 75 1009 What is the expected count for the NSAIDs, Miscarriage cell? a) 10. 8 b) 12. 5 c) 15. 6 d) 16. 4 Statistics: Unlocking the Power of Data Lock 5

Expected Counts No NSAIDs TOTAL Miscarriage 127 18 (10. 8) 145 No Miscarriage 807

Expected Counts No NSAIDs TOTAL Miscarriage 127 18 (10. 8) 145 No Miscarriage 807 57 864 TOTAL 934 75 1009 What is the contribution to the chi-square statistic for the NSAIDs, Miscarriage cell? a) 3. 21 b) 4. 13 c) 4. 84 d) 5. 4 Statistics: Unlocking the Power of Data Lock 5

Stat. Key Statistics: Unlocking the Power of Data Lock 5

Stat. Key Statistics: Unlocking the Power of Data Lock 5

Conclusion Can we conclude that taking NSAIDs around the time of conception or in

Conclusion Can we conclude that taking NSAIDs around the time of conception or in early pregnancy is associated with having a miscarriage? a) Yes b) No Statistics: Unlocking the Power of Data Lock 5

Conclusion Can we conclude that taking NSAIDs around the time of conception or in

Conclusion Can we conclude that taking NSAIDs around the time of conception or in early pregnancy causes increased risk of miscarriage? a) Yes b) No Statistics: Unlocking the Power of Data Lock 5

That’s Not All! �A much more recent study (March 2014) reexamined this issue. Daniel,

That’s Not All! �A much more recent study (March 2014) reexamined this issue. Daniel, S. et. al. (2014). Fetal Exposure to nonsteroidal anti-inflammatory drugs and spontaneous abortions, Canadian Medical Association Journal, 186(5). Statistics: Unlocking the Power of Data Lock 5

NSAIDs and Miscarriage Statistics: Unlocking the Power of Data Lock 5

NSAIDs and Miscarriage Statistics: Unlocking the Power of Data Lock 5

NSAIDs and Miscarriage Statistics: Unlocking the Power of Data Lock 5

NSAIDs and Miscarriage Statistics: Unlocking the Power of Data Lock 5

Results Statistics: Unlocking the Power of Data Lock 5

Results Statistics: Unlocking the Power of Data Lock 5

Results Statistics: Unlocking the Power of Data Lock 5

Results Statistics: Unlocking the Power of Data Lock 5

Statistics: Unlocking the Power of Data Lock 5

Statistics: Unlocking the Power of Data Lock 5

? ? ? �The first study found a significant association between NSAIDs and miscarriage,

? ? ? �The first study found a significant association between NSAIDs and miscarriage, with those taking NSAIDS having significantly higher risk of miscarriage �The second study found a significant association between NSAIDs and miscarriage, with those taking NSAIDS having a significantly lower risk of miscarriage �WHAT’S GOING ON? ? Statistics: Unlocking the Power of Data Lock 5

To Do �Read Section 7. 2 �Do HW 7. 2 (due Friday, 4/17) Statistics:

To Do �Read Section 7. 2 �Do HW 7. 2 (due Friday, 4/17) Statistics: Unlocking the Power of Data Lock 5