| Title: | Blinded Sample Size Re-Estimation for Binary Endpoints |
|---|---|
| Description: | Provides comprehensive tools for blinded sample size re-estimation (BSSR) in two-arm clinical trials with binary endpoints. Unlike traditional fixed-sample designs, BSSR allows adaptive sample size adjustments during trials while maintaining statistical integrity and study blinding. Implements five exact statistical tests: Pearson chi-squared, Fisher exact, Fisher mid-p, Z-pooled exact unconditional, and Boschloo exact unconditional tests. Supports restricted, unrestricted, and weighted BSSR approaches with exact Type I error control. Statistical methods based on Mehrotra et al. (2003) <doi:10.1111/1541-0420.00051> and Kieser (2020) <doi:10.1007/978-3-030-49528-2_21>. |
| Authors: | Gosuke Homma [aut, cre] |
| Maintainer: | Gosuke Homma <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.2 |
| Built: | 2026-05-19 08:13:11 UTC |
| Source: | https://github.com/gosukehommaex/bbssr |
Calculates power for two-arm trials with binary endpoints using exact statistical tests. The function supports five different one-sided tests and can handle vectors of probabilities.
BinaryPower(p1, p2, N1, N2, alpha, Test)BinaryPower(p1, p2, N1, N2, alpha, Test)
p1 |
True probability of responders for group 1 (can be a vector with different values) |
p2 |
True probability of responders for group 2 (can be a vector with different values) |
N1 |
Sample size for group 1 |
N2 |
Sample size for group 2 |
alpha |
One-sided level of significance |
Test |
Type of statistical test. Options: 'Chisq', 'Fisher', 'Fisher-midP', 'Z-pool', or 'Boschloo' |
The function supports the following five one-sided tests:
The one-sided Pearson chi-squared test (Chisq)
The Fisher exact test (Fisher)
The Fisher mid-p test (Fisher-midP)
The Z-pooled exact unconditional test (Z-pool)
The Boschloo exact unconditional test (Boschloo)
The power calculation is based on the exact distribution of the test statistic under the specified alternative hypothesis.
A numeric value or vector of power values. If vectors are provided for p1 and p2, a vector of powers corresponding to each combination will be returned.
Gosuke Homma ([email protected])
# Simple power calculation with fast Chi-squared test power1 <- BinaryPower(p1 = 0.5, p2 = 0.2, N1 = 5, N2 = 5, alpha = 0.025, Test = 'Chisq') print(power1) # More computationally intensive examples # Single power calculation with larger sample size power2 <- BinaryPower(p1 = 0.5, p2 = 0.2, N1 = 10, N2 = 40, alpha = 0.025, Test = 'Boschloo') print(power2) # Multiple power calculations p1_vec <- c(0.5, 0.6, 0.7, 0.8) p2_vec <- c(0.2, 0.2, 0.2, 0.2) powers <- BinaryPower(p1 = p1_vec, p2 = p2_vec, N1 = 10, N2 = 40, alpha = 0.025, Test = 'Fisher') print(powers)# Simple power calculation with fast Chi-squared test power1 <- BinaryPower(p1 = 0.5, p2 = 0.2, N1 = 5, N2 = 5, alpha = 0.025, Test = 'Chisq') print(power1) # More computationally intensive examples # Single power calculation with larger sample size power2 <- BinaryPower(p1 = 0.5, p2 = 0.2, N1 = 10, N2 = 40, alpha = 0.025, Test = 'Boschloo') print(power2) # Multiple power calculations p1_vec <- c(0.5, 0.6, 0.7, 0.8) p2_vec <- c(0.2, 0.2, 0.2, 0.2) powers <- BinaryPower(p1 = p1_vec, p2 = p2_vec, N1 = 10, N2 = 40, alpha = 0.025, Test = 'Fisher') print(powers)
Calculates the power for two-arm trials with binary endpoints when blinded sample size re-estimation (BSSR) is implemented. The function supports five different statistical tests and allows for both restricted and unrestricted designs with optional weighted approaches.
BinaryPowerBSSR( asmd.p1, asmd.p2, p, Delta.A, Delta.T, N1, N2, omega, r, alpha, tar.power, Test, restricted, weighted )BinaryPowerBSSR( asmd.p1, asmd.p2, p, Delta.A, Delta.T, N1, N2, omega, r, alpha, tar.power, Test, restricted, weighted )
asmd.p1 |
Assumed proportion of responders for group 1 |
asmd.p2 |
Assumed proportion of responders for group 2 |
p |
Vector of pooled proportions of responders from both groups (can specify multiple values) |
Delta.A |
Assumed treatment effect (risk difference) |
Delta.T |
True treatment effect (risk difference) |
N1 |
Initial sample size of group 1 |
N2 |
Initial sample size of group 2 |
omega |
Fraction of sample size used for interim analysis (i.e., for BSSR) |
r |
Allocation ratio to group 1 |
alpha |
One-sided level of significance |
tar.power |
Target power |
Test |
Type of statistical test. Options: 'Chisq', 'Fisher', 'Fisher-midP', 'Z-pool', or 'Boschloo' |
restricted |
Logical. If TRUE, restricted design is chosen |
weighted |
Logical. If TRUE, weighted approach is chosen |
The function supports the following five one-sided tests:
The one-sided Pearson chi-squared test (Chisq)
The Fisher exact test (Fisher)
The Fisher mid-p test (Fisher-midP)
The Z-pooled exact unconditional test (Z-pool)
The Boschloo exact unconditional test (Boschloo)
A data frame containing:
True probability of responders for group 1
True probability of responders for group 2
True probability of pooled responders from both groups
Power for BSSR design
Power for traditional design
Gosuke Homma ([email protected])
# Simple BSSR calculation with fast Chi-squared test result1 <- BinaryPowerBSSR( asmd.p1 = 0.6, asmd.p2 = 0.3, p = 0.45, Delta.A = 0.3, Delta.T = 0.3, N1 = 5, N2 = 5, omega = 0.5, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Chisq', restricted = FALSE, weighted = FALSE ) print(result1) # More computationally intensive BSSR examples result2 <- BinaryPowerBSSR( asmd.p1 = 0.45, asmd.p2 = 0.09, p = seq(0.14, 0.23, by = 0.01), Delta.A = 0.36, Delta.T = 0.36, N1 = 24, N2 = 24, omega = 0.5, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Z-pool', restricted = FALSE, weighted = TRUE ) print(result2)# Simple BSSR calculation with fast Chi-squared test result1 <- BinaryPowerBSSR( asmd.p1 = 0.6, asmd.p2 = 0.3, p = 0.45, Delta.A = 0.3, Delta.T = 0.3, N1 = 5, N2 = 5, omega = 0.5, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Chisq', restricted = FALSE, weighted = FALSE ) print(result1) # More computationally intensive BSSR examples result2 <- BinaryPowerBSSR( asmd.p1 = 0.45, asmd.p2 = 0.09, p = seq(0.14, 0.23, by = 0.01), Delta.A = 0.36, Delta.T = 0.36, N1 = 24, N2 = 24, omega = 0.5, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Z-pool', restricted = FALSE, weighted = TRUE ) print(result2)
Provides a rejection region (RR) for two-arm trials with binary endpoints using various exact statistical tests. The function supports five different one-sided tests.
BinaryRR(N1, N2, alpha, Test)BinaryRR(N1, N2, alpha, Test)
N1 |
Sample size for group 1 |
N2 |
Sample size for group 2 |
alpha |
One-sided level of significance |
Test |
Type of statistical test. Options: 'Chisq', 'Fisher', 'Fisher-midP', 'Z-pool', or 'Boschloo' |
The function supports the following five one-sided tests:
The one-sided Pearson chi-squared test (Chisq)
The Fisher exact test (Fisher)
The Fisher mid-p test (Fisher-midP)
The Z-pooled exact unconditional test (Z-pool)
The Boschloo exact unconditional test (Boschloo)
A logical matrix representing the rejection region (RR). Matrix dimensions are (N1+1) x (N2+1), where TRUE indicates rejection of the null hypothesis.
Gosuke Homma ([email protected])
# Simple example with small sample sizes (runs quickly) N1 <- 5 N2 <- 5 alpha <- 0.025 Test <- 'Chisq' RR <- BinaryRR(N1, N2, alpha, Test) print(dim(RR)) # Should be (6, 6) # More computationally intensive example N1 <- 20 N2 <- 10 alpha <- 0.025 Test <- 'Boschloo' RR <- BinaryRR(N1, N2, alpha, Test) print(RR)# Simple example with small sample sizes (runs quickly) N1 <- 5 N2 <- 5 alpha <- 0.025 Test <- 'Chisq' RR <- BinaryRR(N1, N2, alpha, Test) print(dim(RR)) # Should be (6, 6) # More computationally intensive example N1 <- 20 N2 <- 10 alpha <- 0.025 Test <- 'Boschloo' RR <- BinaryRR(N1, N2, alpha, Test) print(RR)
Calculates the required sample size for two-arm trials with binary endpoints using various exact statistical tests. The function supports five different one-sided tests.
BinarySampleSize(p1, p2, r, alpha, tar.power, Test)BinarySampleSize(p1, p2, r, alpha, tar.power, Test)
p1 |
True probability of responders for group 1 |
p2 |
True probability of responders for group 2 |
r |
Allocation ratio to group 1 (i.e., allocation ratio of group 1:group 2 = r:1, r > 0) |
alpha |
One-sided level of significance |
tar.power |
Target power |
Test |
Type of statistical test. Options: 'Chisq', 'Fisher', 'Fisher-midP', 'Z-pool', or 'Boschloo' |
The function supports the following five one-sided tests:
The one-sided Pearson chi-squared test (Chisq)
The Fisher exact test (Fisher)
The Fisher mid-p test (Fisher-midP)
The Z-pooled exact unconditional test (Z-pool)
The Boschloo exact unconditional test (Boschloo)
The calculation uses a three-step approach:
Calculate initial sample size using normal approximation for chi-squared test
Perform power calculation with the initial sample size
Use grid search algorithm to find the optimal sample size
A data frame containing:
True probability of responders for group 1
True probability of responders for group 2
Allocation ratio to group 1
One-sided level of significance
Target power
Name of the statistical test
Calculated power
Required sample size of group 1
Required sample size of group 2
Total required sample size
Gosuke Homma ([email protected])
# Simple sample size calculation with fast Chi-squared test result1 <- BinarySampleSize(p1 = 0.4, p2 = 0.2, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Chisq') print(result1) # More computationally intensive examples # Sample size for Fisher exact test result2 <- BinarySampleSize(p1 = 0.5, p2 = 0.2, r = 2, alpha = 0.025, tar.power = 0.9, Test = 'Fisher') print(result2) # Sample size for Boschloo test result3 <- BinarySampleSize(p1 = 0.6, p2 = 0.3, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Boschloo') print(result3)# Simple sample size calculation with fast Chi-squared test result1 <- BinarySampleSize(p1 = 0.4, p2 = 0.2, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Chisq') print(result1) # More computationally intensive examples # Sample size for Fisher exact test result2 <- BinarySampleSize(p1 = 0.5, p2 = 0.2, r = 2, alpha = 0.025, tar.power = 0.9, Test = 'Fisher') print(result2) # Sample size for Boschloo test result3 <- BinarySampleSize(p1 = 0.6, p2 = 0.3, r = 1, alpha = 0.025, tar.power = 0.8, Test = 'Boschloo') print(result3)