Fisher's Exact test

A/B Testing ใน R

Lauryn Burleigh

Data Scientist

ข้อกำหนด

  • การทดสอบแบบไม่อิงพารามิเตอร์สำหรับข้อมูลเชิงหมวดหมู่
    • ว่าจะกินพิซซ่าชีสหรือเปปเปอโรนีอีกครั้งหรือไม่
  • ขนาดตัวอย่าง < 1000
  • ความถี่ < 5 สำหรับอย่างน้อย 20%
  • ใช้ Fisher's Exact test เพื่อคำนวณค่า p-value ที่แม่นยำ
  • ตารางความถี่แบบ 2x2

Hypergeometric Distribution

  • ความน่าจะเป็นของตารางความถี่
table(Pizza$Topping, Pizza$EatAgain)
              No Yes
  Cheese     140 360
  Pepperoni   80 420
A/B Testing ใน R

สมมติฐาน

  • สมมติฐานหลัก: ไม่มีความสัมพันธ์ระหว่างการกินพิซซ่าซ้ำกับกลุ่มท็อปปิ้ง

ภาพถ่ายชิ้นพิซซ่าที่ถูกหยิบขึ้นมาโดยมือของหลายคน

A/B Testing ใน R

ขนาดตัวอย่าง

library(pwr)
pwr.chisq.test(w = 0.1, df = 2, 
               power = 0.80, 
               sig.level = 0.05)
     Chi squared power calculation 
              w = 0.1
              N = 963.4689
             df = 2
      sig.level = 0.05
          power = 0.8
NOTE: N is the number of observations
table(Pizza$Topping, Pizza$EatAgain)
              No Yes
  Cheese     140 360
  Pepperoni   80 420
A/B Testing ใน R

การทดสอบ

freqtbl <- table(Pizza$Topping, 
                 Pizza$Time)
fisher.test(freqtbl) 
    Fisher's Exact Test for Count Data
data:  freqtbl
p-value = 0.001809
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.4569013 0.8417208
sample estimates:
odds ratio 
 0.6209987 
A/B Testing ใน R

ขนาดผลลัพธ์

freqtbl <- table(Pizza$Topping, 
                 Pizza$Time)
fisher.test(freqtbl) 
  • Small: 1.5
  • Medium: 2.5
  • Large: 4
  • พิซซ่าเปปเปอโรนี x 0.62 เมื่อเทียบกับพิซซ่าชีส
Fisher's Exact Test for Count Data
data:  freqtbl
p-value = 0.001809
alternative hypothesis: true odds 
ratio is not equal to 1
95 percent confidence interval:
 0.4569013 0.8417208
sample estimates:
odds ratio 
 0.6209987  
A/B Testing ใน R

กำลังทางสถิติ

library(pwr)
pwr.2p.test(h = 0.62, n = 500, 
            sig.level = 0.002) 
    Difference of proportion power 
 calculation for binomial distribution

              h = 0.62
              n = 500
      sig.level = 0.002
          power = 1
    alternative = two.sided

NOTE: same sample sizes
A/B Testing ใน R

มาฝึกกันเถอะ!

A/B Testing ใน R

Preparing Video For Download...