| power.prop.test {stats} | R Documentation |
Power Calculations for Two-Sample Test for Proportions
Description
Compute the power of the two-sample test for proportions, or determineparameters to obtain a target power.
Usage
power.prop.test(n = NULL, p1 = NULL, p2 = NULL, sig.level = 0.05, power = NULL, alternative = c("two.sided", "one.sided"), strict = FALSE, tol = .Machine$double.eps^0.25)Arguments
n | number of observations (per group) |
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) |
alternative | one- or two-sided test. Can be abbreviated. |
strict | use strict interpretation in two-sided case |
tol | numerical tolerance used in root finding, the defaultproviding (at least) four significant digits. |
Details
Exactly one of the parametersn,p1,p2,power, andsig.level must be passed as NULL, and thatparameter is determined from the others. Notice thatsig.levelhas a non-NULL default soNULL must be explicitly passed if youwant it computed.
Ifstrict = TRUE is used, the power will include the probability ofrejection in the opposite direction of the true effect, in the two-sidedcase. Without this the power will be half the significance level if thetrue difference is zero.
Note that not all conditions can be satisfied, e.g., for
power.prop.test(n=30, p1=0.90, p2=NULL, power=0.8, strict=TRUE)
there is no proportionp2 betweenp1 = 0.9 and 1, asyou'd need a sample size of at leastn = 74 to yield thedesired power for(p1,p2) = (0.9, 1).
For these impossible conditions, currently a warning(warning) is signalled which may become an error(stop) in the future.
Value
Object of class"power.htest", a list of the arguments(including the computed one) augmented withmethod andnote elements.
Note
uniroot is used to solve power equation for unknowns, soyou may see errors from it, notably about inability to bracket theroot when invalid arguments are given. If one ofp1 andp2 is computed, thenp1 < p2 is assumed and will hold,but if you specify both,p2 \le p1 is allowed.
Author(s)
Peter Dalgaard. Based on previous work by ClausEkstrøm
See Also
Examples
power.prop.test(n = 50, p1 = .50, p2 = .75) ## => power = 0.740power.prop.test(p1 = .50, p2 = .75, power = .90) ## => n = 76.7power.prop.test(n = 50, p1 = .5, power = .90) ## => p2 = 0.8026power.prop.test(n = 50, p1 = .5, p2 = 0.9, power = .90, sig.level=NULL) ## => sig.l = 0.00131power.prop.test(p1 = .5, p2 = 0.501, sig.level=.001, power=0.90) ## => n = 10451937try( power.prop.test(n=30, p1=0.90, p2=NULL, power=0.8)) # a warning (which may become an error)## Reason:power.prop.test( p1=0.90, p2= 1.0, power=0.8) ##-> n = 73.37