A/B Testing in R
Lauryn Burleigh
Data Scientist
Ignoring groups
Each group
r
expected effect (found with cor()
)sig.level
at which we reject the nulllibrary(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
ggplot(pizza, aes(x = enjoyment,
y = time)) +
geom_point()
ggplot(pizza, aes(x = enjoyment,
y = time)) +
geom_point()
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
cor.test(~ time + enjoyment,
data = pizza,
method = "pearson")
Proportion of variance: 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
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
Pearson ignoring groups:
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
A/B Testing in R