피셔의 정확 검정

R로 배우는 A/B Testing

Lauryn Burleigh

Data Scientist

사양

  • 범주형 데이터의 비모수 검정
    • 치즈 vs 페퍼로니 피자를 또 먹을지 여부
  • 표본 < 1000
  • 빈도 < 5가 최소 20%
  • 정확한 p-값에는 Fisher's Exact test 사용
  • 2x2 빈도표

초등분포(Hypergeometric Distribution)

  • 빈도표의 가능도
table(Pizza$Topping, Pizza$EatAgain)
              No Yes
  Cheese     140 360
  Pepperoni   80 420
R로 배우는 A/B Testing

가설

  • 귀무가설: 재구매 여부와 토핑 그룹 간 관계 없음

여러 사람의 손이 피자 조각을 집는 사진.

R로 배우는 A/B Testing

표본

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
R로 배우는 A/B Testing

검정

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 
R로 배우는 A/B Testing

효과 크기

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  
R로 배우는 A/B Testing

검정력

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
R로 배우는 A/B Testing

연습해 봅시다!

R로 배우는 A/B Testing

Preparing Video For Download...