A/B Testing in R
Lauryn Burleigh
Data Scientist
library(ggplot2)
ggplot(pizza, aes(x = Time,
fill = Topping)) +
geom_histogram() +
facet_grid(Topping~.)
library(pwr)
pwr.2p2n.test(h = 0.40,
sig.level = 0.05,
power = 0.8, n1 = 100)
difference of proportion power
calculation for binomial distribution
h = 0.4
n1 = 100
n2 = 96.29156
sig.level = 0.05
power = 0.8
alternative = two.sided
NOTE: different sample sizes
pwr.2p2n.test(h = 0.40,
sig.level = 0.05,
power = 0.8, n1 = 110)
difference of proportion power
calculation for binomial distribution
h = 0.4
n1 = 110
n2 = 88.54092
sig.level = 0.05
power = 0.8
alternative = two.sided
NOTE: different sample sizes
h
: rank-biserial correlation rwilcox.test(Time ~ Topping,
data = Pizza)
Wilcoxon rank sum test with
continuity correction
data: Enjoyment by Topping
W = 6051, p-value = 0.01026
alternative hypothesis: true location
shift is not equal to 0
Effect size
library(effectsize)
rank_biserial(Time ~ Topping,
data = pizza)
r (rank biserial) | 95% CI
<----------------------------------
0.21 | [0.05, 0.36]
1 - 0.14 = 0.86 probability of Type II error
Power Analysis
library(pwr)
pwr.2p2n.test(h = 0.21, sig.level = 0.01,
n1 = 100, n2 = 100)
difference of proportion power calculation for binomial distribution
h = 0.21
n1 = 100
n2 = 100
sig.level = 0.01
power = 0.1376818
alternative = two.sided
NOTE: different sample sizes
A/B Testing in R