
Rejection Region for Two-Arm Trials with a Single Binary Endpoint
Source:R/rr1Binary.R
rr1Binary.RdCalculates the rejection region for two-arm trials with a single binary endpoint using various exact statistical tests, as described in Homma and Yoshida (2025).
Arguments
- n1
Sample size for group 1 (test group)
- n2
Sample size for group 2 (control group)
- alpha
One-sided significance level (typically 0.025)
- Test
Type of statistical test. One of:
"Chisq": One-sided Pearson chi-squared test"Fisher": Fisher exact test"Fisher-midP": Fisher mid-p test"Z-pool": Z-pooled exact unconditional test"Boschloo": Boschloo exact unconditional test
- n_grid
Number of grid points used to maximize the null tail probability over the nuisance parameter in the two exact unconditional tests, that is
"Z-pool"and"Boschloo"(default is 100). The other three tests read their p-values off a distribution and ignore this argument. A finer grid locates the maximum more accurately at a proportionally higher computational cost, and the default reproduces the results of earlier versions of the package.
Value
A logical matrix of dimensions (n1+1) x (n2+1), where TRUE indicates rejection of the null hypothesis. Rows correspond to the number of responders in group 1 (0 to n1), and columns correspond to the number of responders in group 2 (0 to n2).
Details
This function computes the rejection region for five different one-sided tests:
Chi-squared test: Uses the asymptotic normal approximation of the chi-squared statistic.
Fisher exact test: Uses the hypergeometric distribution to calculate exact p-values conditional on the total number of successes.
Fisher mid-p test: Modification of Fisher's exact test that adds half the probability of the observed outcome to reduce conservatism.
Z-pooled test: Exact unconditional test that maximizes p-values over all possible values of the nuisance parameter (common success probability under H0).
Boschloo test: Exact unconditional test similar to Z-pooled but based on Fisher's exact p-values, maximizing over the nuisance parameter.
For the two exact unconditional tests the outcomes are ordered from the most extreme to the least extreme value of the ordering statistic, and the null tail probability is accumulated along that order before being maximized over the nuisance parameter. Outcomes that share the same value of the ordering statistic form a tie group, and since the tail event is the set of outcomes at least as extreme as the observed one, every member of a tie group receives the tail probability accumulated up to the last member of that group. This makes the p-value independent of the order in which tied outcomes happen to be sorted.
References
Homma, G., & Yoshida, T. (2025). Exact power and sample size in clinical trials with two co-primary binary endpoints. Statistical Methods in Medical Research, 34(11), 2183-2201.
Examples
# Simple example with small sample sizes
n1 <- 5
n2 <- 5
alpha <- 0.025
RR <- rr1Binary(n1, n2, alpha, Test = 'Chisq')
print(dim(RR)) # Should be (6, 6)
#> [1] 6 6
# Fisher exact test
RR_fisher <- rr1Binary(n1 = 10, n2 = 10, alpha = 0.025, Test = 'Fisher')
# \donttest{
# More computationally intensive: Boschloo test
n1 <- 20
n2 <- 10
alpha <- 0.025
RR <- rr1Binary(n1, n2, alpha, Test = 'Boschloo')
print(RR)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11]
#> [1,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [5,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [6,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [7,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [8,] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [9,] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [10,] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [11,] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [12,] TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [13,] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [14,] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [15,] TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [16,] TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
#> [17,] TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
#> [18,] TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
#> [19,] TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE
#> [20,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE
#> [21,] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE FALSE FALSE
# }