Type: | Package |
Title: | Blinded Sample Size Re-Estimation for Binary Endpoints |
Version: | 1.0.2 |
Date: | 2025-06-14 |
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>. |
License: | MIT + file LICENSE |
URL: | https://github.com/gosukehommaEX/bbssr |
BugReports: | https://github.com/gosukehommaEX/bbssr/issues |
Depends: | R (≥ 3.5.0) |
Imports: | fpCompare, stats |
Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown, dplyr, ggplot2, tibble, tidyr, Exact, exact2x2, microbenchmark |
VignetteBuilder: | knitr |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2025-06-17 15:59:41 UTC; i_lik |
Author: | Gosuke Homma [aut, cre] |
Maintainer: | Gosuke Homma <my.name.is.gosuke@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-18 12:00:06 UTC |
Power Calculation for Two-Arm Trials with Binary Endpoints
Description
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.
Usage
BinaryPower(p1, p2, N1, N2, alpha, Test)
Arguments
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' |
Details
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.
Value
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.
Author(s)
Gosuke Homma (my.name.is.gosuke@gmail.com)
Examples
# 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)
Power Calculation for Two-Arm Trials with Binary Endpoints Using Blinded Sample Size Re-estimation (BSSR)
Description
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.
Usage
BinaryPowerBSSR(
asmd.p1,
asmd.p2,
p,
Delta.A,
Delta.T,
N1,
N2,
omega,
r,
alpha,
tar.power,
Test,
restricted,
weighted
)
Arguments
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 |
Details
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)
Value
A data frame containing:
- p1
True probability of responders for group 1
- p2
True probability of responders for group 2
- p
True probability of pooled responders from both groups
- power.BSSR
Power for BSSR design
- power.TRAD
Power for traditional design
Author(s)
Gosuke Homma (my.name.is.gosuke@gmail.com)
Examples
# 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)
Rejection Region for Two-Arm Trials with Binary Endpoints
Description
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.
Usage
BinaryRR(N1, N2, alpha, Test)
Arguments
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' |
Details
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)
Value
A logical matrix representing the rejection region (RR). Matrix dimensions are (N1+1) x (N2+1), where TRUE indicates rejection of the null hypothesis.
Author(s)
Gosuke Homma (my.name.is.gosuke@gmail.com)
Examples
# 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)
Sample Size Calculation for Two-Arm Trials with Binary Endpoints
Description
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.
Usage
BinarySampleSize(p1, p2, r, alpha, tar.power, Test)
Arguments
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' |
Details
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
Value
A data frame containing:
- p1
True probability of responders for group 1
- p2
True probability of responders for group 2
- r
Allocation ratio to group 1
- alpha
One-sided level of significance
- tar.power
Target power
- Test
Name of the statistical test
- Power
Calculated power
- N1
Required sample size of group 1
- N2
Required sample size of group 2
- N
Total required sample size
Author(s)
Gosuke Homma (my.name.is.gosuke@gmail.com)
Examples
# 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)