
twoCoprimary provides comprehensive tools for sample
size and power calculation in clinical trials with two co-primary
endpoints. In co-primary endpoint trials, treatment success requires
demonstrating statistically significant effects on all
primary endpoints simultaneously. This package implements
state-of-the-art methodologies that properly account for correlation
between endpoints, leading to more efficient trial designs.
The package supports five combinations of co-primary endpoints:
All methods provide:
The exact methods for binary endpoints use a compiled kernel for the bivariate binomial distribution and evaluate the co-primary power as a matrix product, so a complete sample size search at a total sample size of several hundred takes about a second. The rejection regions of the Z-pooled and Boschloo exact unconditional tests agree with those of the Exact package.
See NEWS for what changed in version 1.1.0.
Install from CRAN:
install.packages("twoCoprimary")Or install the development version from GitHub:
# install.packages("pak")
pak::pak("gosukehommaEX/twoCoprimary")Calculate sample size for a trial with two continuous co-primary endpoints:
library(twoCoprimary)
# Sample size calculation
result <- ss2Continuous(
delta1 = 0.5, # Effect size for endpoint 1
delta2 = 0.5, # Effect size for endpoint 2
sd1 = 1, # Standard deviation for endpoint 1
sd2 = 1, # Standard deviation for endpoint 2
rho = 0.5, # Correlation between endpoints
r = 1, # Balanced allocation
alpha = 0.025, # One-sided significance level
beta = 0.2, # Type II error (80% power)
known_var = TRUE
)
print(result)
# Sample size calculation for two continuous co-primary endpoints
#
# n1 = 79
# n2 = 79
# N = 158
# delta = 0.5, 0.5
# sd = 1, 1
# rho = 0.5
# allocation = 1
# alpha = 0.025
# beta = 0.2
# known_var = TRUEFor small to medium sample sizes, use exact methods:
# Sample size with exact inference
result_exact <- ss2BinaryExact(
p11 = 0.50, p12 = 0.30, # Response rates for group 1
p21 = 0.30, p22 = 0.10, # Response rates for group 2
rho1 = 0.3, rho2 = 0.3, # Within-group correlations
alpha = 0.025, # One-sided significance level
beta = 0.2, # Type II error (80% power)
r = 1, # Allocation ratio
Test = "Fisher" # Exact test method
)
print(result_exact)
# Sample size calculation for two binary co-primary endpoints
#
# n1 = 111
# n2 = 111
# N = 222
# p (group 1) = 0.5, 0.3
# p (group 2) = 0.3, 0.1
# rho = 0.3, 0.3
# allocation = 1
# alpha = 0.025
# beta = 0.2
# Test = FisherFor COPD/asthma trials with exacerbation count and lung function:
# Sample size calculation
result <- ss2MixedCountContinuous(
r1 = 1.0, # Count rate in treatment group
r2 = 1.25, # Count rate in control group
nu = 0.8, # Dispersion parameter
t = 1, # Follow-up time
mu1 = -50, # Mean for treatment (negative = benefit)
mu2 = 0, # Mean for control
sd = 250, # Standard deviation
r = 1, # Balanced allocation
rho1 = 0.5, # Correlation in treatment group
rho2 = 0.5, # Correlation in control group
alpha = 0.025, # One-sided significance level
beta = 0.2 # Type II error (80% power)
)
print(result)
# Sample size calculation for mixed count and continuous co-primary endpoints
#
# n1 = 705
# n2 = 705
# N = 1410
# sd = 250
# rate = 1, 1.25
# nu = 0.8
# t = 1
# mu = -50, 0
# rho = 0.5, 0.5
# allocation = 1
# alpha = 0.025
# beta = 0.2Comprehensive vignettes are available:
Homma, G., & Yoshida, T. (2024). Sample size calculation in clinical trials with two co-primary endpoints including overdispersed count and continuous outcomes. Pharmaceutical Statistics, 23(1), 46-59. https://doi.org/10.1002/pst.2337
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. https://doi.org/10.1177/09622802251368697
Sozu, T., Sugimoto, T., & Hamasaki, T. (2010). Sample size determination in clinical trials with multiple co-primary binary endpoints. Statistics in Medicine, 29(21), 2169-2179. https://doi.org/10.1002/sim.3972
Sozu, T., Sugimoto, T., & Hamasaki, T. (2011). Sample size determination in superiority clinical trials with multiple co-primary correlated endpoints. Journal of Biopharmaceutical Statistics, 21(4), 650-668. https://doi.org/10.1080/10543406.2011.551329
Sozu, T., Sugimoto, T., & Hamasaki, T. (2012). Sample size determination in clinical trials with multiple co-primary endpoints including mixed continuous and binary variables. Biometrical Journal, 54(5), 716-729. https://doi.org/10.1002/bimj.201100221
citation("twoCoprimary")MIT © Gosuke Homma