Description Usage Arguments Details Value Examples
View source: R/min_sample_size.R
this function calculates the minimum required sample size (equal for both treatment groups) which acheives a desired MDE and power provided alpha, s, h and gamma.
1 | min_sample_size(mde, p_0, alpha, s, h, gamma, power)
|
mde |
minimum detectable effect |
p_0 |
assumed population 0 p parameter |
alpha |
test significance level |
s |
either 1 (for one sided test) or 2 (for two sided test) |
h |
number of hypothesis tested in the same experiment (for Bonferroni correction) |
gamma |
minimum required lift |
power |
desired test power (inverse of type 2 error) |
In 2 sided tests each usually represents a different treatment. When doing one-sided tests it's usually the case that population 1 is considered the treatment and population 0 serves as the control. At any rate, one sided tests are always of the form p_1 - p_0 > C. For that reason for 1 sided tests one must set: mde > gamma >= 0
minimum requires sample size per treatment group
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(hype)
# For a thorugh simulation validation see
# https://github.com/IyarLin/hype/blob/master/inst/variuos_results_for_hypothesis_testing.pdf
# below we'll calculate minimum requires sample size per group
# for 2 hypothesis tests performed
# in the same experiemnt
# note that h is set to 2 in order to reflect that
## hypothesis test number 1
min_sample_size(
mde = 0.025, p_0 = 0.2,
alpha = 0.05, s = 1, h = 2, gamma = 0.01,
power = 0.8
)
## hypothesis test number 2
min_sample_size(
mde = 0.018, p_0 = 0.1,
alpha = 0.05, s = 2, h = 2, gamma = 0,
power = 0.8
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.