피어슨 상관

R로 배우는 A/B Testing

Lauryn Burleigh

Data Scientist

피어슨 상관의 가정

  • 상관검정 선택: 데이터 특성
  • 피어슨 상관
    • 선형
    • 정규분포

왼쪽 아래에서 오른쪽 위로 증가하는 선형 추세선.

표준 정규분포 그래프.

R로 배우는 A/B Testing

피어슨 상관과 A/B 테스트

  • 그룹 A: 치즈 피자
  • 그룹 B: 페퍼로니 피자

 

  • 피자 먹는 시간과 만족도의 관계

그룹 무시

  • 귀무가설: 시간과 만족도 간 관계 없음

각 그룹

  • 귀무가설: 치즈 피자의 시간과 만족도 간 관계 없음
  • 귀무가설: 페퍼로니 피자의 시간과 만족도 간 관계 없음
R로 배우는 A/B Testing

표본크기 결정

  • r: 예상 효과(cor()로 확인)
  • sig.level: 귀무가설 기각 기준
library(pwr)
pwr.r.test(r = 0.3, power = 0.80, 
           sig.level = 0.05)
    approximate correlation power 
 calculation (arctangh transformation) 

              n = 84.07364
              r = 0.3
      sig.level = 0.05
          power = 0.8
    alternative = two.sided
R로 배우는 A/B Testing

선형성 평가

ggplot(pizza, aes(x = enjoyment, 
                  y = time)) + 
    geom_point()

x축 만족도, y축 시간에 양의 선형 관계 산점도.

ggplot(pizza, aes(x = enjoyment, 
                  y = time)) + 
    geom_point()

x축 만족도, y축 시간에 양의 선형 관계 산점도. 왼쪽 아래 군집과 오른쪽 위 다른 군집이 구분됨.

R로 배우는 A/B Testing

정규성 평가

shapiro.test(pizza$time)
    Shapiro-Wilk normality test
data:  pizza$time
W = 0.98686, p-value = 0.4282
  • 데이터는 정규분포임
shapiro.test(pizza$enjoyment)
    Shapiro-Wilk normality test
data:  pizza$enjoyment
W = 0.98916, p-value = 0.5971
  • 데이터는 정규분포임
R로 배우는 A/B Testing

그룹 무시한 피어슨

cor.test(~ time + enjoyment, 
         data = pizza, 
         method = "pearson")

 

분산 비율: cor^2

0.30^2
[1] 0.09
Pearson's product-moment correlation

data:  time and enjoyment
t = 22.304, df = 88, p-value = 0.0218
alternative hypothesis: true correlation
is not equal to 0
95 percent confidence interval:
 0.8833166 0.9479256
sample estimates:
      cor 
0.3021878
R로 배우는 A/B Testing

그룹 내 피어슨

cor.test(~ time + enjoyment, 
         data = pizza, 
         subset = 
             (Topping == "Cheese"),
         method = "pearson")
Pearson's product-moment correlation

data:  Time and Enjoy
t = 11.121, df = 98, p-value < 2.2e-16
alternative hypothesis: true correlation 
is not equal to 0
95 percent confidence interval:
 0.6451710 0.8226595
sample estimates:
     cor 
0.746935 
R로 배우는 A/B Testing

검정력 분석

그룹 무시 피어슨:

Pearson's product-moment correlation

data:  time and enjoyment
t = 22.304, df = 88, p-value = 0.0218
alternative hypothesis: true 
correlation is not equal to 0
95 percent confidence interval:
 0.8833166 0.9479256
sample estimates:
      cor 
0.3021878
library(pwr)
pwr.r.test(r = 0.302, n = 100, 
           sig.level = 0.022)
     approximate correlation power 
  calculation (arctangh transformation) 

              n = 100
              r = 0.302
      sig.level = 0.022
          power = 0.7853514
    alternative = two.sided
R로 배우는 A/B Testing

Ayo berlatih!

R로 배우는 A/B Testing

Preparing Video For Download...