Compute power of test, or determine parameters to obtain target power for equal and unequal sample sizes.

power_prop_test(n = NULL, p1 = NULL, p2 = NULL, sig.level = 0.05,
  power = NULL, ratio = 1, alternative = c("two.sided", "one.sided"),
  tol = .Machine$double.eps^0.25)

Arguments

n

Number of observations (in group 1)

p1

Probability in one group

p2

Probability in other group

sig.level

Significance level (Type I error probability)

power

Power of test (1 minus Type II error probability)

ratio

The ratio n2/n1 between the larger group and the smaller group. Should be a value equal to or greater than 1 since n2 is the larger group. Defaults to 1 (equal group sizes)

alternative

String. Can be one- or two-sided test. Can be abbreviated.

tol

Numerical tolerance used in root finding, the default providing (at least) four significant digits

Value

Object of class power.htest, a list of the arguments (including the computed one) augmented with method and note elements.

Details

Exactly one of the parameters n, delta, power, sd, sig.level, ratio sd.ratio must be passed as NULL, and that parameter is determined from the others. Notice that the last two have non-NULL defaults so NULL must be explicitly passed if you want to compute them.

Note

uniroot is used to solve power equation for unknowns, so you may see errors from it, notably about inability to bracket the root when invalid arguments are given.

See also

power.prop.test, power_t_test, power.t.test

Examples

power_prop_test(n=NULL, p1=.65, p2=.85, power=.8, ratio=2)
#> #> Two-sample comparison of proportions power calculation with unequal sample sizes #> #> n = 52.06539, 104.13078 #> p1 = 0.65 #> p2 = 0.85 #> sig.level = 0.05 #> power = 0.8 #> alternative = two.sided #> #> NOTE: n is vector of number in each group #>