power.exact.test.RdCalculates the power of the design for known sample sizes and true probabilities.
power.exact.test(p1, p2, n1, n2, alternative = c("two.sided", "less", "greater"),
alpha = 0.05, npNumbers = 100, np.interval = FALSE, beta = 0.001,
method = c("z-pooled", "z-unpooled", "boschloo", "santner and snell", "csm",
"fisher", "pearson chisq", "yates chisq"),
tsmethod = c("square", "central"), simulation = FALSE, nsim = 100,
delta = 0, convexity = TRUE, useStoredCSM = TRUE)The probability of success given in first group
The probability of success given in second group
The sample size in first group
The sample size in second group
Indicates the alternative hypothesis: must be either "two.sided", "less", or "greater"
Significance level
Number: The number of nuisance parameters considered
Logical: Indicates if a confidence interval on the nuisance parameter should be computed
Number: Confidence level for constructing the interval of nuisance parameters considered. Only used if np.interval=TRUE
Indicates the method for finding more extreme tables: must be either "Z-pooled", "Z-unpooled", "Santner and Snell", "Boschloo", "CSM", "Fisher", "Pearson Chisq", or "Yates Chisq"
Indicates two-sided method: must be either "square" or "central"
Logical: Indicates if the power calculation is exact or estimated by simulation
Number of simulations run. Only used if simulation=TRUE
Number: null hypothesis of the difference in proportion
Logical: assumes convexity for interval approach. Only used if np.interval=TRUE
Logical: uses stored CSM ordering matrix. Only used if method="csm"
The power calculations are for binomial models with independent samples. The design must know the fixed sample sizes in advance. There are (n1+1) x (n2+1) possible tables that could be produced. There are two ways to calculate the power: simulate the tables under two independent binomial distributions or determine the rejection region for all possible tables and calculate the exact power. The calculations can be done using any exact.test computation, Fisher's exact test, or chi-square tests (Yates' or Pearson's; note: these are not exact tests). The power calculations utilize the convexity property, which greatly speeds up computation time (see exact.reject.region documentation).
A list with class "power.htest" containing the following components:
The respective sample sizes
The respective success probabilities
Significance level
Power of the test
A character string describing the alternative hypothesis
Null hypothesis of the difference in proportion
A character string describing the method to determine more extreme tables
Berger, R. (1994) Power comparison of exact unconditional tests for comparing two binomial proportions. Institute of Statistics Mimeo Series No. 2266
Berger, R. (1996) More powerful tests from confidence interval p values. American Statistician, 50, 314-318
Boschloo, R. D. (1970), Raised Conditional Level of Significance for the 2x2-table when Testing the Equality of Two Probabilities. Statistica Neerlandica, 24, 1-35
Pearson's and Yates' chi-square tests are not exact tests, so the function name may be a misnomer. These tests may have inflated type 1 error rates. These options were added to compute the power efficiently when using asymptotic tests.
exact.reject.region and statmod
# Superiority power #
power.exact.test(p1=0.15, p2=0.60, n1=15, n2=30, method="Z-pooled")
#>
#> Z-pooled Exact Test
#>
#> n1, n2 = 15, 30
#> p1, p2 = 0.15, 0.60
#> alpha = 0.05
#> power = 0.8512212
#> alternative = two.sided
#> delta = 0
#>
power.exact.test(p1=0.15, p2=0.60, n1=15, n2=30, method="Fisher")
#>
#> Fisher's Exact Test
#>
#> n1, n2 = 15, 30
#> p1, p2 = 0.15, 0.60
#> alpha = 0.05
#> power = 0.8049468
#> alternative = two.sided
#> delta = 0
#>
power.exact.test(p1=0.15, p2=0.60, n1=15, n2=30, method="Boschloo",
np.interval=TRUE, beta=0.001)
#>
#> Boschloo's Exact Test with Interval Approach
#>
#> n1, n2 = 15, 30
#> p1, p2 = 0.15, 0.60
#> alpha = 0.05
#> power = 0.8588912
#> alternative = two.sided
#> delta = 0
#>
if (FALSE) { # \dontrun{
# Ensure that the ExactData R package is available before running the CSM test.
if (requireNamespace("ExactData", quietly = TRUE)) {
power.exact.test(p1=0.15, p2=0.60, n1=15, n2=30, method="CSM")
}
} # }
# Non-inferiority power #
power.exact.test(p1=0.30, p2=0.30, n1=65, n2=65, method="Z-pooled",
delta=0.2, alternative="less")
#>
#> Z-pooled Exact Test
#>
#> n1, n2 = 65, 65
#> p1, p2 = 0.3, 0.3
#> alpha = 0.05
#> power = 0.8005406
#> alternative = less
#> delta = 0.2
#>