Last active
December 7, 2021 23:52
-
-
Save fauxneticien/391f1b8a593e29bbd7c6b2622f7bea4e to your computer and use it in GitHub Desktop.
Parametric bootstrap estimates for A/B test conditions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(boot) | |
library(purrr) | |
n_bootstraps <- 100 | |
sample_data <- read.csv("~/Desktop/sample-data.csv", stringsAsFactors = FALSE) | |
get_mean_pdiff <- function(data, indices) { | |
d <- data[indices,] | |
return(mean(d$prop_diff)) | |
} | |
cis_by_condition <- imap_dfr( | |
.x = split(sample_data, sample_data$condition), | |
.f = function(data, condition) { | |
results <- boot(data=data, statistic = get_mean_pdiff, R = n_bootstraps, parallel = "multicore") | |
conf_is <- boot.ci(results, type="bca") | |
data.frame( | |
condition = condition, | |
prop_diff = conf_is$t0, | |
ci_lower = conf_is$bca[4], | |
ci_upper = conf_is$bca[5] | |
) | |
} | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subject | condition | oct_total_spent | oct_hrm_spent | oct_spent_prop | nov_total_spent | oct_hrm_spent | nov_spent_prop | prop_diff | |
---|---|---|---|---|---|---|---|---|---|
C01 | control | 100 | 80 | 0.8 | 100 | 75 | 0.75 | -0.05 | |
C02 | control | 120 | 100 | 0.833333333 | 120 | 110 | 0.916666667 | 0.083333333 | |
C03 | control | 90 | 76 | 0.844444444 | 90 | 70 | 0.777777778 | -0.066666667 | |
C04 | control | 75 | 50 | 0.666666667 | 75 | 55 | 0.733333333 | 0.066666667 | |
I01 | intervention | 114 | 100 | 0.877192982 | 114 | 90 | 0.789473684 | -0.087719298 | |
I02 | intervention | 123 | 100 | 0.81300813 | 123 | 85 | 0.691056911 | -0.12195122 | |
I03 | intervention | 192 | 150 | 0.78125 | 192 | 100 | 0.520833333 | -0.260416667 | |
I04 | intervention | 210 | 150 | 0.714285714 | 210 | 160 | 0.761904762 | 0.047619048 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment