A/B Testing in R
Lauryn Burleigh
Data Scientist
Spearman correlation (rho) - monotonic relationship
Monotonic less restrictive than linear
ggplot(data, aes(x = drownings,
y = icecream)) +
geom_point()
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
cor.test(~ enjoyment + time,
data = pizza,
method = "spearman",
exact = FALSE)
Spearman's rank correlation rho
data: time and enjoyment
S = 2, p-value = .003245
alternative hypothesis: true rho is
not equal to 0
sample estimates:
rho
0.9984962
samp <- length(pizza$time)
[1] 90
cor.test(~ enjoyment + time,
data = pizza,
subset =
(Topping == "Cheese"),
method = "spearman",
exact = FALSE)
Spearman's rank correlation rho
data: time and enjoyment
S = 1.2434e-14, p-value = 0.0003968
alternative hypothesis: true rho is
not equal to 0
sample estimates:
rho
1
ggplot(pizza, aes(x = enjoyment,
y = time,
color = Topping)) +
geom_point()
library(pwr)
pwr.r.test(r = 0.998, n = 90,
sig.level = 0.003)
approximate correlation power
calculation (arctangh transformation)
n = 90
r = 0.998
sig.level = 0.003
power = 1
alternative = two.sided
rhotest <- cor.test(~ enjoyment + time,
data = pizza,
method = "spearman")
samp <- length(pizza$time)
library(pwr)
pwr.r.test(r = rhotest$estimate,
sig.level = rhotest$p.value,
n = samp)
approximate correlation power
calculation (arctangh transformation)
n = 90
r = 0.998
sig.level = 0.003
power = 1
alternative = two.sided
A/B Testing in R