Skip to content

Instantly share code, notes, and snippets.

@vladiim
Created May 17, 2016 00:37
Show Gist options
  • Select an option

  • Save vladiim/d3037453bb25fb6ce20df8c43e0783ab to your computer and use it in GitHub Desktop.

Select an option

Save vladiim/d3037453bb25fb6ce20df8c43e0783ab to your computer and use it in GitHub Desktop.
chiS <- function(control_non_convert, control_convert, test_non_convert, test_convert) {
control <- c(control_non_convert, control_convert)
test <- c(test_non_convert, test_convert)
d <- as.data.frame(rbind(control, test))
chisq.test(d)
}
diffReq <- function(control_non_convert, control_convert, confidence) {
control_non_convert_test <- control_non_convert / 2
control_convert_test <- control_convert / 2
for (i in 1:control_non_convert_test) {
test_non_convert <- control_non_convert_test - i
test_convert <- control_convert_test + i
pval <- chiS(control_non_convert_test, control_convert_test, test_non_convert, test_convert)$p.value
if ((1 - pval) >= confidence) return(paste0("You need to convert: ", test_convert, " conversions to be ", confidence, " confident with your test result."))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment