BinarySampleSize {bbssr} | R Documentation |
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)