Overview
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.
Key Features
The package supports five combinations of co-primary endpoints:
- Two continuous endpoints - Normal distribution with correlation (Sozu et al., 2011)
- Two binary endpoints (asymptotic) - Large sample approximation methods (Sozu et al., 2010)
- Two binary endpoints (exact) - Exact inference for small to medium samples (Homma & Yoshida, 2025)
- Mixed continuous and binary - Biserial correlation structure (Sozu et al., 2012)
- Mixed count and continuous - Negative binomial for overdispersed counts (Homma & Yoshida, 2024)
All methods provide: - ✅ Sample size calculation given target power - ✅ Power calculation given sample size - ✅ Proper Type I error control without multiplicity adjustment - ✅ Accounting for correlation between endpoints - ✅ Support for unbalanced allocation ratios
Installation
Install from CRAN:
install.packages("twoCoprimary")Or install the development version from GitHub:
# install.packages("pak")
pak::pak("gosukehommaEX/twoCoprimary")Quick Start
Example 1: Two Continuous Endpoints
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 = TRUEExample 2: Two Binary Endpoints (Exact Method)
For 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 = FisherExample 3: Mixed Count and Continuous Endpoints
For 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.2References
Homma, G., & Yoshida, T. (2024). Sample size calculation for clinical trials with co‐primary outcomes: Negative binomial and continuous outcomes. Pharmaceutical Statistics, 23(3), 368-392. 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(1). https://doi.org/10.1177/09622802251368697
Sozu, T., Sugimoto, T., Hamasaki, T., & Evans, S. R. (2010). Sample size determination in superiority clinical trials with multiple co-primary correlated endpoints. Statistics in Medicine, 29(21), 2219-2227. 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., & Evans, S. R. (2012). Sample size determination in clinical trials with multiple co-primary binary endpoints including mixed binary and continuous endpoints. Biometrical Journal, 54(5), 716-729. https://doi.org/10.1002/bimj.201100221
Citation
citation("twoCoprimary")Getting Help
- For bug reports and feature requests, please use the GitHub issue tracker
- For questions about usage, see the documentation website
