Compute power of test, or determine parameters to obtain target power.
power_binom_test(n = NULL, p0 = NULL, pa = NULL, sig.level = 0.05, power = NULL, alternative = c("two.sided", "less", "greater"))
n | Number of observations |
---|---|
p0 | Probability under the null |
pa | Probability under the alternative |
sig.level | Significance level (Type I error probability) |
power | Power of test (1 minus Type II error probability) |
alternative | One- or two-sided test |
Object of class power.htest
, a list of the arguments
(including the computed one) augmented with method and note elements.
The procedure uses uniroot to find the root of a discontinuous function so some errors may pop up due to the given setup that causes the root-finding procedure to fail. Also, since exact binomial tests are used we have discontinuities in the function that we use to find the root of but despite this the function is usually quite stable.
binom.test
power_binom_test(n = 50, p0 = .50, pa = .75) ## => power = 0.971#> #> One-sample exact binomial power calculation #> #> n = 50 #> p0 = 0.5 #> pa = 0.75 #> sig.level = 0.05 #> power = 0.9712668 #> alternative = two.sided #>power_binom_test(p0 = .50, pa = .75, power = .90) ## => n = 41#> #> One-sample exact binomial power calculation #> #> n = 40.99995 #> p0 = 0.5 #> pa = 0.75 #> sig.level = 0.05 #> power = 0.9 #> alternative = two.sided #>power_binom_test(n = 50, p0 = .25, power = .90, alternative="less") ## => pa = 0.0954#> #> One-sample exact binomial power calculation #> #> n = 50 #> p0 = 0.25 #> pa = 0.09543121 #> sig.level = 0.05 #> power = 0.9 #> alternative = less #>