knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The explore package offers an easy way to do basic A/B testing.
For interactive A/B testing simply call abtest()
without any parameters.
{width=600px}
If you want to A/B test your own data, pass them into the ´abtest()´ function.
In this example we are using synthetic data using one of the create_data_()
functions of {explore}
library(dplyr) library(explore) data <- create_data_buy(obs = 1000)
data %>% describe()
Each observation is a customer. The ´buy´ variable contains 0/1 values (1 = the customer did buy a product)
We want to test the hypothesis, that customer with age > 50 have a different buying behavior.
data %>% explore(age, target = buy)
We see a clear pattern, that people who buy differ in age from people who don´t buy. But is this difference statistically significant?
data %>% abtest(age > 50, target = buy, sign_level = 0.05)
The A/B test shows a statistically significant difference!
We would like to test the hypothesis, that customer with a mobile voice product (mobilevoice_ind == 1) have different bbi_usg_gb (broadband usage in GB)
data %>% explore(mobilevoice_ind, target = bbi_usg_gb)
The boxplot shows a small difference in Broadband Usage between customers with/without Mobile Voice product. But is this difference statistically significant?
data %>% abtest(mobilevoice_ind == 1, target = bbi_usg_gb, sign_level = 0.05)
The A/B test shows a NOT statistically significant difference! The p-value is 0.09, but should be max. 0.05 (as we defined sign_level = 0.05)
In this example we are using the Titanic datasst. use_data_titanic()
is a functions of {explore}
that makes it easier to use popular example datasets.
library(dplyr) library(explore) data <- use_data_titanic(count = TRUE)
data %>% describe()
We want to test the hypothesis, that female passengers have a higher chance to survive.
data %>% explore(Sex, target = Survived, n = n)
We see a clear pattern, but is it difference statistically significant?
data %>% abtest(Sex == "Female", target = Survived, n = n, sign_level = 0.05)
The A/B test shows a statistically significant difference!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.