Description Usage Arguments Value Author(s) Examples
View source: R/calculate_sample_size.R
Calculates needed sample size in AB test for a given baseline, improvement, statistical significance and statistical power. Calculations are based on Center Limit Theorem and sample size is found using binary search over lower_n, upper_n.
1 2 3 4 5 6 7 8 9 10 | calculate_sample_size(
baseline,
improvement,
significance,
wanted_power,
improvement_type = "relative",
tolerance = 1e-04,
upper_n = 1e+07,
lower_n = 1
)
|
baseline |
Base rate of success for the control group in range <0,1> |
improvement |
Relative increase of baseline or absolute number that we want our test to pick up, recognize with given statistical power |
significance |
Statistical significance, probability of rejecting H0 when it is actually true |
wanted_power |
Statistical power we want our test to have, probability of rejecting H0 when it is false and H1 is given by baseline and improvement |
improvement_type |
'relative' or 'absolute'. Is given improvement relative to baseline or given in absolute number. |
tolerance |
When searching wanted_power using binary search, how close we need to get in order to finish searching. Defaults to 0.00001 = 0.001%. |
upper_n |
Upper limit for sample size when searching using binary search. If solution is above upper_n we will get a message to increase it. Default value is 1e7 = 10 million. |
lower_n |
Lower limit for sample size when searching using binary search. Default value is 1. |
Integer, estimated sample size needed in order to achieve wanted statistical power.
Elio Bartoš
1 2 3 4 5 6 7 8 | calculate_sample_size(
baseline = 0.3,
improvement = 0.02,
significance = 0.05,
wanted_power = 0.90,
improvement_type = "absolute")
# [1] 11232
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.