power.paired.test.RdCalculates the power of the design for known sample size and true probabilities.
power.paired.test(p12, p21, N, alternative = c("two.sided", "less", "greater"),
alpha = 0.05, npNumbers = 100, np.interval = FALSE, beta = 0.001,
method = c("uam", "ucm", "uamcc", "csm", "cm", "am", "amcc"),
tsmethod = c("square", "central"),
simulation = FALSE, nsim = 100,
delta = 0, convexity = TRUE, useStoredCSM = TRUE)The probability of success in first group and failure in second group. This is the probability of the discordant pair x12
The probability of failure in first group and success in second group. This is the probability of the discordant pair x21
The total sample size
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 the more extreme tables: must be either "UAM", "UCM", "UAMCC", "CSM", "CM", "AM", or "AMCC"
A character string describing the method to implement two-sided tests
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 paired samples. All possible tables can be represented by an (N+1) x (N+1) matrix. There are two ways to calculate the power: simulate the tables under a trinomial distribution or determine the rejection region for all possible tables and calculate the exact power. The power calculations can be determined for any unconditional exact test in paired.exact.test, the Conditional McNemar's (CM) exact test, the Asymptotic McNemar's (AM) test, or Asymptotic McNemar's test with Continuity Correction (AMCC) (note: asymptotic tests are not exact tests). The power calculations utilize the convexity property, which greatly speeds up computation time (see paired.reject.region documentation).
A list with class "power.htest" containing the following components:
The total sample size
The respective discordant 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.L. and Sidik, K. (2003) Exact unconditional tests for 2 x 2 matched-pairs design. Statistical Methods in Medical Research, 12, 91–108
McNemar's asymptotic tests are not exact test and may have inflated type 1 error rates. These options were added to compute the power efficiently when using asymptotic tests.
# Superiority power #
power.paired.test(p12=0.15, p21=0.45, N=40, method="UAM")
#>
#> Unconditional Asymptotic McNemar's Exact Test
#>
#> N = 40
#> p12, p21 = 0.15, 0.45
#> alpha = 0.05
#> power = 0.7004168
#> 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.paired.test(p12=0.15, p21=0.45, N=40, method="CSM")
}
} # }
# Non-inferiority power #
power.paired.test(p12=0.30, p21=0.30, N=80, method="UAM",
alternative="less", delta=0.2)
#>
#> Unconditional Asymptotic McNemar's Exact Test
#>
#> N = 80
#> p12, p21 = 0.3, 0.3
#> alpha = 0.05
#> power = 0.7444475
#> alternative = less
#> delta = 0.2
#>