| Title: | Sample Size and Power Calculation for Two Co-Primary Endpoints |
|---|---|
| Description: | Comprehensive functions to calculate sample size and power for clinical trials with two co-primary endpoints. The package supports five endpoint combinations: two continuous endpoints (Sozu et al. 2011 <doi:10.1080/10543406.2011.551329>), two binary endpoints using asymptotic methods (Sozu et al. 2010 <doi:10.1002/sim.3972>) and exact methods (Homma and Yoshida 2025 <doi:10.1177/09622802251368697>), mixed continuous and binary endpoints (Sozu et al. 2012 <doi:10.1002/bimj.201100221>), and mixed count and continuous endpoints (Homma and Yoshida 2024 <doi:10.1002/pst.2337>). All methods appropriately account for correlation between endpoints and provide both sample size and power calculation capabilities. |
| Authors: | Gosuke Homma [aut, cre] (ORCID: <https://orcid.org/0000-0002-6854-5627>) |
| Maintainer: | Gosuke Homma <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.1 |
| Built: | 2026-10-09 12:50:10 UTC |
| Source: | https://github.com/gosukehommaex/twocoprimary |
Computes the lower and upper bounds of the correlation coefficient between two binary outcomes based on their marginal probabilities, as described in Prentice (1988).
corrbound2Binary(p1, p2)corrbound2Binary(p1, p2)
p1 |
True probability of responders for the first outcome (0 < p1 < 1) |
p2 |
True probability of responders for the second outcome (0 < p2 < 1) |
For two binary outcomes with marginal probabilities p1 and p2, the correlation coefficient rho is bounded by:
where
A named numeric vector with two elements:
L_bound |
Lower bound of the correlation |
U_bound |
Upper bound of the correlation |
Prentice, R. L. (1988). Correlated binary regression with covariates specific to each binary observation. Biometrics, 44(4), 1033-1048.
# Calculate correlation bounds for two binary outcomes corrbound2Binary(p1 = 0.3, p2 = 0.5) # When probabilities are equal, upper bound is 1 corrbound2Binary(p1 = 0.4, p2 = 0.4) # When p1 + p2 = 1, lower bound is -1 corrbound2Binary(p1 = 0.3, p2 = 0.7)# Calculate correlation bounds for two binary outcomes corrbound2Binary(p1 = 0.3, p2 = 0.5) # When probabilities are equal, upper bound is 1 corrbound2Binary(p1 = 0.4, p2 = 0.4) # When p1 + p2 = 1, lower bound is -1 corrbound2Binary(p1 = 0.3, p2 = 0.7)
Computes the lower and upper bounds of the correlation coefficient between an overdispersed count outcome (negative binomial) and a continuous outcome (normal), as described in Homma and Yoshida (2024).
corrbound2MixedCountContinuous(lambda, nu, mu, sd)corrbound2MixedCountContinuous(lambda, nu, mu, sd)
lambda |
Mean parameter for the negative binomial distribution (lambda > 0) |
nu |
Dispersion parameter for the negative binomial distribution (nu > 0) |
mu |
Mean for the continuous outcome |
sd |
Standard deviation for the continuous outcome (sd > 0) |
The correlation bounds are calculated using the Frechet-Hoeffding bounds for copulas, as described in Trivedi and Zimmer (2007). The negative binomial distribution has mean lambda and variance:
The variance of the negative binomial distribution is: Var(Y1) = lambda + lambda^2/nu
A named numeric vector with two elements:
L_bound |
Lower bound of the correlation |
U_bound |
Upper bound of the correlation |
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.
Trivedi, P. K., & Zimmer, D. M. (2007). Copula modeling: an introduction for practitioners. Foundations and Trends in Econometrics, 1(1), 1-111.
# Calculate correlation bounds for NB(1.25, 0.8) and N(0, 250) corrbound2MixedCountContinuous(lambda = 1.25, nu = 0.8, mu = 0, sd = 250) # Higher dispersion parameter corrbound2MixedCountContinuous(lambda = 2.0, nu = 2.0, mu = 50, sd = 200) # Different follow-up time corrbound2MixedCountContinuous(lambda = 1.0 * 2, nu = 1.0, mu = 0, sd = 300)# Calculate correlation bounds for NB(1.25, 0.8) and N(0, 250) corrbound2MixedCountContinuous(lambda = 1.25, nu = 0.8, mu = 0, sd = 250) # Higher dispersion parameter corrbound2MixedCountContinuous(lambda = 2.0, nu = 2.0, mu = 50, sd = 200) # Different follow-up time corrbound2MixedCountContinuous(lambda = 1.0 * 2, nu = 1.0, mu = 0, sd = 300)
Calculates the probability mass function of the bivariate binomial distribution for given parameters, as described in Homma and Yoshida (2025).
dbibinom(N, y1, y2, p1, p2, rho)dbibinom(N, y1, y2, p1, p2, rho)
N |
Sample size (number of trials) |
y1 |
Observed value(s) of the first random variable (0 to N) |
y2 |
Observed value(s) of the second random variable (0 to N) |
p1 |
True probability of responders for the first outcome (0 < p1 < 1) |
p2 |
True probability of responders for the second outcome (0 < p2 < 1) |
rho |
Correlation coefficient between the two binary outcomes |
The bivariate binomial distribution BiBin(N, p1, p2, gamma) has probability mass function given by equation (3) in Homma and Yoshida (2025):
where
with and
.
Probability mass function value(s) for the bivariate binomial distribution. If y1 and y2 are vectors, returns a vector of probabilities.
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.
# Calculate single probability mass dbibinom(N = 100, y1 = 30, y2 = 50, p1 = 0.3, p2 = 0.5, rho = 0.5) # Verify that probabilities sum to 1 N <- 20 p1 <- 0.3 p2 <- 0.5 rho <- 0.5 sum(outer(0:N, 0:N, function(x, y) dbibinom(N, x, y, p1, p2, rho)))# Calculate single probability mass dbibinom(N = 100, y1 = 30, y2 = 50, p1 = 0.3, p2 = 0.5, rho = 0.5) # Verify that probabilities sum to 1 N <- 20 p1 <- 0.3 p2 <- 0.5 rho <- 0.5 sum(outer(0:N, 0:N, function(x, y) dbibinom(N, x, y, p1, p2, rho)))
Generates a comprehensive table comparing sample sizes or power across different parameter combinations and correlation values. This function is useful for sensitivity analyses and exploring how design parameters affect statistical properties.
design_table( param_grid, rho_values = c(0, 0.3, 0.5, 0.8), r = 1, alpha = 0.025, beta = 0.2, endpoint_type = c("continuous", "binary", "mixed_cont_binary", "mixed_count_cont"), Test = "AN", known_var = TRUE, nMC = 1000, output_var = NULL, n_grid = 100 )design_table( param_grid, rho_values = c(0, 0.3, 0.5, 0.8), r = 1, alpha = 0.025, beta = 0.2, endpoint_type = c("continuous", "binary", "mixed_cont_binary", "mixed_count_cont"), Test = "AN", known_var = TRUE, nMC = 1000, output_var = NULL, n_grid = 100 )
param_grid |
A data.frame containing parameter combinations. Required columns depend on endpoint_type and calculation_mode:
|
rho_values |
Numeric vector of correlation values to evaluate. Default is c(0, 0.3, 0.5, 0.8). |
r |
Allocation ratio (n1/n2). Required for sample size calculation. Default is 1. |
alpha |
One-sided significance level. Default is 0.025. |
beta |
Type II error rate (1 - power). Required for sample size calculation. Default is 0.2 (power = 0.8). |
endpoint_type |
Character string specifying endpoint type: "continuous", "binary", "mixed_cont_binary", or "mixed_count_cont". |
Test |
Test method. For |
known_var |
Logical indicating whether variance is known for continuous endpoints. Default is TRUE. |
nMC |
Number of Monte Carlo simulations for certain calculations. Default is 1000. |
output_var |
Character string specifying which variable to output in the result columns: "N" (total sample size, default for sample size calculation) or "powerCoprimary" (co-primary power, default for power calculation). |
n_grid |
Number of grid points used to maximize the null tail probability
over the nuisance parameter in the two exact unconditional tests, that is
|
This function performs systematic calculations across all combinations of parameters specified in param_grid and correlation values in rho_values.
The calculation mode (sample size vs power) is automatically determined:
If param_grid contains n1 and n2: calculates power
Otherwise: calculates sample size (requires r, alpha, beta)
For binary endpoints with two correlations (rho1, rho2), both are set to the same value from rho_values for each calculation.
The output format follows the style of Sozu et al. (2011), with parameters displayed in the leftmost columns and results for each correlation in subsequent columns.
A data.frame of class "twoCoprimary_table" with:
Parameter columns (from param_grid)
Result columns for each correlation value (rho_0.0, rho_0.3, etc.)
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.
# Sample size calculation for continuous endpoints param_grid <- expand.grid( delta1 = c(0.3, 0.5), delta2 = c(0.1, 0.2, 0.3), sd1 = c(1.0, 1.5), sd2 = c(1.0, 1.5) ) result <- design_table( param_grid = param_grid, rho_values = c(0, 0.3, 0.5, 0.8), r = 1, alpha = 0.025, beta = 0.2, endpoint_type = "continuous" ) print(result) # Power calculation for continuous endpoints param_grid_power <- expand.grid( n1 = c(50, 100), n2 = c(50, 100), delta1 = 0.5, delta2 = 0.5, sd1 = 1.0, sd2 = 1.0 ) result_power <- design_table( param_grid = param_grid_power, rho_values = c(0, 0.3, 0.5, 0.8), alpha = 0.025, endpoint_type = "continuous" ) print(result_power) # Binary endpoints param_grid_binary <- expand.grid( p11 = c(0.6, 0.7), p12 = c(0.4, 0.5), p21 = c(0.4, 0.5), p22 = c(0.2, 0.3) ) result_binary <- design_table( param_grid = param_grid_binary, rho_values = c(0.3, 0.5, 0.7), r = 1, alpha = 0.025, beta = 0.2, endpoint_type = "binary", Test = "AN" ) print(result_binary)# Sample size calculation for continuous endpoints param_grid <- expand.grid( delta1 = c(0.3, 0.5), delta2 = c(0.1, 0.2, 0.3), sd1 = c(1.0, 1.5), sd2 = c(1.0, 1.5) ) result <- design_table( param_grid = param_grid, rho_values = c(0, 0.3, 0.5, 0.8), r = 1, alpha = 0.025, beta = 0.2, endpoint_type = "continuous" ) print(result) # Power calculation for continuous endpoints param_grid_power <- expand.grid( n1 = c(50, 100), n2 = c(50, 100), delta1 = 0.5, delta2 = 0.5, sd1 = 1.0, sd2 = 1.0 ) result_power <- design_table( param_grid = param_grid_power, rho_values = c(0, 0.3, 0.5, 0.8), alpha = 0.025, endpoint_type = "continuous" ) print(result_power) # Binary endpoints param_grid_binary <- expand.grid( p11 = c(0.6, 0.7), p12 = c(0.4, 0.5), p21 = c(0.4, 0.5), p22 = c(0.2, 0.3) ) result_binary <- design_table( param_grid = param_grid_binary, rho_values = c(0.3, 0.5, 0.7), r = 1, alpha = 0.025, beta = 0.2, endpoint_type = "binary", Test = "AN" ) print(result_binary)
Visualizes power or sample size relationships for two co-primary endpoints designs. The function automatically determines the appropriate plot based on the input object.
## S3 method for class 'twoCoprimary' plot( x, type = NULL, n_points = 50, n_range = NULL, rho_range = NULL, col = "steelblue", lwd = 2, main = NULL, xlab = NULL, ylab = NULL, show_reference = TRUE, ... )## S3 method for class 'twoCoprimary' plot( x, type = NULL, n_points = 50, n_range = NULL, rho_range = NULL, col = "steelblue", lwd = 2, main = NULL, xlab = NULL, ylab = NULL, show_reference = TRUE, ... )
x |
An object of class "twoCoprimary" from power or sample size calculation functions |
type |
Type of plot to generate:
|
n_points |
Number of points to compute for the curve. Default is 50. Each point runs a full calculation, so a smaller value is advisable for objects produced with an exact binary test or with Monte Carlo integration. |
n_range |
Sample size range for power_curve plot. If NULL, automatically determined from the object. |
rho_range |
Correlation range for sample_size_rho plot. If NULL, the range is seq(0, 0.9, length.out = n_points) for continuous and mixed continuous-binary endpoints, and is derived from the Frechet-Hoeffding bounds of the supplied marginal parameters for binary and mixed count-continuous endpoints. |
col |
Line color. Default is "steelblue". |
lwd |
Line width. Default is 2. |
main |
Plot title. If NULL, automatically generated. |
xlab |
X-axis label. If NULL, automatically generated. |
ylab |
Y-axis label. If NULL, automatically generated. |
show_reference |
Logical. If TRUE, shows reference lines (e.g., target power, current values). Default is TRUE. |
... |
Additional graphical parameters passed to plot() |
The function creates publication-quality plots to visualize the relationship
between design parameters and statistical properties. The plot type is
automatically selected based on the input object, but can be overridden
using the type argument.
For power calculation results (when n1 and n2 are specified), the default is to show how power changes with sample size.
For sample size calculation results (when power is specified), the default is to show how required sample size changes with correlation.
The function works with all endpoint types (continuous, binary, mixed) by automatically detecting the appropriate parameters from the input object.
Invisibly returns the data used to create the plot as a data frame.
# Power calculation result result_power <- power2Continuous( n1 = 100, n2 = 100, delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.5, alpha = 0.025, known_var = TRUE ) plot(result_power) # Shows power curve # Sample size calculation result result_ss <- ss2Continuous( delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.5, r = 1, alpha = 0.025, beta = 0.2, known_var = TRUE ) plot(result_ss) # Shows sample size vs correlation # Custom plot with specified type plot(result_power, type = "power_curve", n_range = c(50, 200))# Power calculation result result_power <- power2Continuous( n1 = 100, n2 = 100, delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.5, alpha = 0.025, known_var = TRUE ) plot(result_power) # Shows power curve # Sample size calculation result result_ss <- ss2Continuous( delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.5, r = 1, alpha = 0.025, beta = 0.2, known_var = TRUE ) plot(result_ss) # Shows sample size vs correlation # Custom plot with specified type plot(result_power, type = "power_curve", n_range = c(50, 200))
Calculates the power for a two-arm superiority trial with two co-primary binary endpoints using various asymptotic normal approximation methods, as described in Sozu et al. (2010).
power2BinaryApprox(n1, n2, p11, p12, p21, p22, rho1, rho2, alpha, Test)power2BinaryApprox(n1, n2, p11, p12, p21, p22, rho1, rho2, alpha, Test)
n1 |
Sample size for group 1 (test group) |
n2 |
Sample size for group 2 (control group) |
p11 |
True probability of responders in group 1 for the first outcome (0 < p11 < 1) |
p12 |
True probability of responders in group 1 for the second outcome (0 < p12 < 1) |
p21 |
True probability of responders in group 2 for the first outcome (0 < p21 < 1) |
p22 |
True probability of responders in group 2 for the second outcome (0 < p22 < 1) |
rho1 |
Correlation between the two outcomes for group 1 |
rho2 |
Correlation between the two outcomes for group 2 |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
Test |
Statistical testing method. One of:
|
This function implements four approximate power calculation methods:
Asymptotic Normal (AN): Uses the standard normal approximation without continuity correction (equations 3-4 in Sozu et al. 2010).
Asymptotic Normal with Continuity Correction (ANc): Includes Yates's continuity correction (equation 5 in Sozu et al. 2010).
Arcsine (AS): Uses arcsine transformation without continuity correction (equation 6 in Sozu et al. 2010).
Arcsine with Continuity Correction (ASc): Arcsine method with continuity correction (equation 7 in Sozu et al. 2010).
The correlation between test statistics for the two endpoints depends on the method:
For AN and ANc methods:
where .
For AS method:
This is the weighted average of the correlations from both groups.
For ASc method:
where ,
, and .
The correlation bounds are automatically checked using corrbound2Binary.
A data frame with the following columns:
n1 |
Sample size for group 1 |
n2 |
Sample size for group 2 |
p11, p12, p21, p22
|
Response probabilities |
rho1, rho2
|
Correlations |
alpha |
One-sided significance level |
Test |
Testing method used |
power1 |
Power for the first endpoint alone |
power2 |
Power for the second endpoint alone |
powerCoprimary |
Power for both co-primary endpoints |
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.
# Power calculation using asymptotic normal method power2BinaryApprox( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = 'AN' ) # Power calculation with continuity correction power2BinaryApprox( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = 'ANc' ) # Power calculation using arcsine method power2BinaryApprox( n1 = 150, n2 = 150, p11 = 0.6, p12 = 0.5, p21 = 0.4, p22 = 0.3, rho1 = 0.5, rho2 = 0.5, alpha = 0.025, Test = 'AS' )# Power calculation using asymptotic normal method power2BinaryApprox( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = 'AN' ) # Power calculation with continuity correction power2BinaryApprox( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = 'ANc' ) # Power calculation using arcsine method power2BinaryApprox( n1 = 150, n2 = 150, p11 = 0.6, p12 = 0.5, p21 = 0.4, p22 = 0.3, rho1 = 0.5, rho2 = 0.5, alpha = 0.025, Test = 'AS' )
Calculates the exact power for a two-arm superiority trial with two co-primary binary endpoints using the bivariate binomial distribution, as described in Homma and Yoshida (2025).
power2BinaryExact( n1, n2, p11, p12, p21, p22, rho1, rho2, alpha, Test, n_grid = 100 )power2BinaryExact( n1, n2, p11, p12, p21, p22, rho1, rho2, alpha, Test, n_grid = 100 )
n1 |
Sample size for group 1 (test group) |
n2 |
Sample size for group 2 (control group) |
p11 |
True probability of responders in group 1 for the first outcome (0 < p11 < 1) |
p12 |
True probability of responders in group 1 for the second outcome (0 < p12 < 1) |
p21 |
True probability of responders in group 2 for the first outcome (0 < p21 < 1) |
p22 |
True probability of responders in group 2 for the second outcome (0 < p22 < 1) |
rho1 |
Correlation between the two outcomes for group 1 |
rho2 |
Correlation between the two outcomes for group 2 |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
Test |
Statistical testing method. One of:
|
n_grid |
Number of grid points used to maximize the null tail probability
over the nuisance parameter in the two exact unconditional tests, that is
|
This function calculates exact power using equation (9) in Homma and Yoshida (2025):
where is the rejection region for endpoint k, and
follows
the bivariate binomial distribution.
The correlation bounds are automatically checked using corrbound2Binary.
A data frame with the following columns:
n1 |
Sample size for group 1 |
n2 |
Sample size for group 2 |
p11, p12, p21, p22
|
Response probabilities |
rho1, rho2
|
Correlations |
alpha |
One-sided significance level |
Test |
Testing method used |
power1 |
Power for the first endpoint alone |
power2 |
Power for the second endpoint alone |
powerCoprimary |
Exact power for both co-primary endpoints |
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.
# Exact power calculation using Boschloo test power2BinaryExact( n1 = 100, n2 = 50, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = 'Boschloo' ) # Exact power with Fisher exact test power2BinaryExact( n1 = 80, n2 = 80, p11 = 0.6, p12 = 0.5, p21 = 0.4, p22 = 0.3, rho1 = 0.5, rho2 = 0.5, alpha = 0.025, Test = 'Fisher' ) # Larger sample sizes (computationally intensive) power2BinaryExact( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.6, rho2 = 0.6, alpha = 0.025, Test = 'Chisq' )# Exact power calculation using Boschloo test power2BinaryExact( n1 = 100, n2 = 50, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = 'Boschloo' ) # Exact power with Fisher exact test power2BinaryExact( n1 = 80, n2 = 80, p11 = 0.6, p12 = 0.5, p21 = 0.4, p22 = 0.3, rho1 = 0.5, rho2 = 0.5, alpha = 0.025, Test = 'Fisher' ) # Larger sample sizes (computationally intensive) power2BinaryExact( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.6, rho2 = 0.6, alpha = 0.025, Test = 'Chisq' )
Calculates the power for a two-arm superiority trial with two co-primary continuous endpoints, as described in Sozu et al. (2011).
power2Continuous( n1, n2, delta1, delta2, sd1, sd2, rho, alpha, known_var = TRUE, nMC = 10000 )power2Continuous( n1, n2, delta1, delta2, sd1, sd2, rho, alpha, known_var = TRUE, nMC = 10000 )
n1 |
Sample size for group 1 (test group) |
n2 |
Sample size for group 2 (control group) |
delta1 |
Mean difference for the first endpoint |
delta2 |
Mean difference for the second endpoint |
sd1 |
Common standard deviation for the first endpoint |
sd2 |
Common standard deviation for the second endpoint |
rho |
Common correlation between the two outcomes |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
known_var |
Logical value indicating whether variance is known (TRUE) or unknown (FALSE). If TRUE, power is calculated analytically; otherwise, Monte Carlo simulation is used for unknown variance |
nMC |
Number of Monte Carlo simulations when known_var = FALSE (default is 10000) |
For known variance, the power is calculated using the bivariate normal distribution as described in Sozu et al. (2011). The test statistics are:
for k = 1, 2. The co-primary power is:
where is the cumulative distribution function of the bivariate
standard normal distribution.
For unknown variance, Monte Carlo simulation is used with Wishart-distributed correlation matrices of the standardized endpoints to account for variance estimation uncertainty, following equation (6) in Sozu et al. (2011):
where and
follows a Wishart distribution with degrees of
freedom and the correlation matrix of the standardized endpoints as its scale
matrix, so that is the ratio of the estimated to the
true standard deviation of endpoint k.
The Monte Carlo step draws random numbers, so results for
known_var = FALSE vary between calls unless a seed is set with
set.seed beforehand.
A data frame with the following columns:
n1 |
Sample size for group 1 |
n2 |
Sample size for group 2 |
delta1 |
Mean difference for endpoint 1 |
delta2 |
Mean difference for endpoint 2 |
sd1 |
Standard deviation for endpoint 1 |
sd2 |
Standard deviation for endpoint 2 |
rho |
Correlation between endpoints |
alpha |
One-sided significance level |
known_var |
Variance assumption |
nMC |
Number of Monte Carlo simulations (NA if known_var = TRUE) |
power1 |
Power for the first endpoint alone |
power2 |
Power for the second endpoint alone |
powerCoprimary |
Power for both co-primary endpoints |
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.
# Example parameters for comparison across methods n1_ex <- 100 n2_ex <- 100 delta1_ex <- 0.5 delta2_ex <- 0.5 sd1_ex <- 1 sd2_ex <- 1 rho_ex <- 0.3 alpha_ex <- 0.025 # Power calculation with known variance power2Continuous( n1 = n1_ex, n2 = n2_ex, delta1 = delta1_ex, delta2 = delta2_ex, sd1 = sd1_ex, sd2 = sd2_ex, rho = rho_ex, alpha = alpha_ex, known_var = TRUE ) # Power calculation with unknown variance (Monte Carlo) power2Continuous( n1 = n1_ex, n2 = n2_ex, delta1 = delta1_ex, delta2 = delta2_ex, sd1 = sd1_ex, sd2 = sd2_ex, rho = rho_ex, alpha = alpha_ex, known_var = FALSE, nMC = 10000 )# Example parameters for comparison across methods n1_ex <- 100 n2_ex <- 100 delta1_ex <- 0.5 delta2_ex <- 0.5 sd1_ex <- 1 sd2_ex <- 1 rho_ex <- 0.3 alpha_ex <- 0.025 # Power calculation with known variance power2Continuous( n1 = n1_ex, n2 = n2_ex, delta1 = delta1_ex, delta2 = delta2_ex, sd1 = sd1_ex, sd2 = sd2_ex, rho = rho_ex, alpha = alpha_ex, known_var = TRUE ) # Power calculation with unknown variance (Monte Carlo) power2Continuous( n1 = n1_ex, n2 = n2_ex, delta1 = delta1_ex, delta2 = delta2_ex, sd1 = sd1_ex, sd2 = sd2_ex, rho = rho_ex, alpha = alpha_ex, known_var = FALSE, nMC = 10000 )
Calculates the power for a two-arm superiority trial with two co-primary endpoints where one is continuous and one is binary, as described in Sozu et al. (2012).
power2MixedContinuousBinary( n1, n2, delta, sd, p1, p2, rho, alpha, Test, nMC = 10000 )power2MixedContinuousBinary( n1, n2, delta, sd, p1, p2, rho, alpha, Test, nMC = 10000 )
n1 |
Sample size for group 1 (test group) |
n2 |
Sample size for group 2 (control group) |
delta |
Mean difference for the continuous endpoint (group 1 - group 2) |
sd |
Common standard deviation for the continuous endpoint |
p1 |
Probability of response in group 1 for the binary endpoint (0 < p1 < 1) |
p2 |
Probability of response in group 2 for the binary endpoint (0 < p2 < 1) |
rho |
Biserial correlation between the latent continuous variable underlying the binary endpoint and the observed continuous endpoint |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
Test |
Statistical testing method for the binary endpoint. One of:
|
nMC |
Number of Monte Carlo replications when Test = "Fisher" (default: 10000) |
This function implements the power calculation for mixed endpoints (one continuous and one binary) as described in Sozu et al. (2012). The method assumes that the binary variable is derived from a latent continuous variable via dichotomization at a threshold point.
For Fisher's exact test, Monte Carlo simulation is used because exact calculation is computationally intensive. The continuous endpoint is analyzed using t-test, and the binary endpoint uses Fisher's exact test.
For asymptotic methods (AN, ANc, AS, ASc), analytical formulas are used based on bivariate normal approximation. The correlation between test statistics depends on the biserial correlation rho and the specific testing method.
Biserial Correlation: The biserial correlation rho represents the correlation between the latent continuous variable underlying the binary endpoint and the observed continuous endpoint. This is not the same as the point-biserial correlation observed in the data.
The Monte Carlo step of Test = "Fisher" draws random numbers, so
results vary between calls unless a seed is set with set.seed
beforehand. The sequential search for the sample size compares a simulated
power against the target, so the returned sample size can differ by a subject
or two between runs; increasing nMC reduces that variation.
A data frame with the following columns:
n1 |
Sample size for group 1 |
n2 |
Sample size for group 2 |
delta |
Mean difference for continuous endpoint |
sd |
Standard deviation for continuous endpoint |
p1 |
Response probability in group 1 for binary endpoint |
p2 |
Response probability in group 2 for binary endpoint |
rho |
Biserial correlation |
alpha |
One-sided significance level |
Test |
Testing method used for binary endpoint |
nMC |
Number of Monte Carlo replications (NA if Test != "Fisher") |
powerCont |
Power for the continuous endpoint alone |
powerBin |
Power for the binary endpoint alone |
powerCoprimary |
Power for both co-primary endpoints |
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.
# Power calculation using asymptotic normal method power2MixedContinuousBinary( n1 = 100, n2 = 100, delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, alpha = 0.025, Test = 'AN' ) # Power calculation with Fisher's exact test (computationally intensive) power2MixedContinuousBinary( n1 = 50, n2 = 50, delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, alpha = 0.025, Test = 'Fisher', nMC = 5000 )# Power calculation using asymptotic normal method power2MixedContinuousBinary( n1 = 100, n2 = 100, delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, alpha = 0.025, Test = 'AN' ) # Power calculation with Fisher's exact test (computationally intensive) power2MixedContinuousBinary( n1 = 50, n2 = 50, delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, alpha = 0.025, Test = 'Fisher', nMC = 5000 )
Calculates the power for a two-arm superiority trial with one overdispersed count co-primary endpoint and one continuous co-primary endpoint, as described in Homma and Yoshida (2024).
power2MixedCountContinuous( n1, n2, r1, r2, nu, t, mu1, mu2, sd, rho1, rho2, alpha )power2MixedCountContinuous( n1, n2, r1, r2, nu, t, mu1, mu2, sd, rho1, rho2, alpha )
n1 |
Sample size for group 1 (test group) |
n2 |
Sample size for group 2 (control group) |
r1 |
Mean rate (events per unit time) for the treatment group (count endpoint) |
r2 |
Mean rate (events per unit time) for the control group (count endpoint) |
nu |
Common dispersion parameter for the negative binomial distribution (nu > 0) |
t |
Common follow-up time period |
mu1 |
Mean for group 1 (continuous endpoint) |
mu2 |
Mean for group 2 (continuous endpoint) |
sd |
Common standard deviation for the continuous endpoint |
rho1 |
Correlation between count and continuous outcomes for treatment group |
rho2 |
Correlation between count and continuous outcomes for control group |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
The formulas below are those of Homma and Yoshida (2024), written in the
indexing used throughout this package: group 1 is the treatment group and
group 2 is the control group, and is the argument
r. The source article indexes the control group by 0 instead.
The test statistics are (equation 7 in Homma and Yoshida 2024):
The joint distribution of (Z1, Z2) follows an asymptotic bivariate normal distribution with correlation gamma (equation 11):
where is the mean count in group j,
is the event rate per unit time, which is distinct from the
allocation ratio r, and is the variance component of
equation 8, ,
so that .
The correlation bounds are automatically checked using corrbound2MixedCountContinuous.
A data frame with the following columns:
n1 |
Sample size for group 1 |
n2 |
Sample size for group 2 |
r1 |
Mean rate in group 1 for count endpoint |
r2 |
Mean rate in group 2 for count endpoint |
nu |
Dispersion parameter |
t |
Follow-up time |
mu1 |
Mean in group 1 for continuous endpoint |
mu2 |
Mean in group 2 for continuous endpoint |
sd |
Standard deviation for continuous endpoint |
rho1 |
Correlation for group 1 |
rho2 |
Correlation for group 2 |
alpha |
One-sided significance level |
powerCount |
Power for the count endpoint alone |
powerCont |
Power for the continuous endpoint alone |
powerCoprimary |
Power for both co-primary endpoints |
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.
# Power calculation with moderate correlation power2MixedCountContinuous( n1 = 300, n2 = 300, r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.5, rho2 = 0.5, alpha = 0.025 ) # Power calculation with no correlation power2MixedCountContinuous( n1 = 350, n2 = 350, r1 = 1.0, r2 = 1.5, nu = 1, t = 1, mu1 = -40, mu2 = 0, sd = 200, rho1 = 0, rho2 = 0, alpha = 0.025 ) # Unbalanced design power2MixedCountContinuous( n1 = 400, n2 = 200, r1 = 1, r2 = 1.25, nu = 1, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.6, rho2 = 0.6, alpha = 0.025 )# Power calculation with moderate correlation power2MixedCountContinuous( n1 = 300, n2 = 300, r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.5, rho2 = 0.5, alpha = 0.025 ) # Power calculation with no correlation power2MixedCountContinuous( n1 = 350, n2 = 350, r1 = 1.0, r2 = 1.5, nu = 1, t = 1, mu1 = -40, mu2 = 0, sd = 200, rho1 = 0, rho2 = 0, alpha = 0.025 ) # Unbalanced design power2MixedCountContinuous( n1 = 400, n2 = 200, r1 = 1, r2 = 1.25, nu = 1, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.6, rho2 = 0.6, alpha = 0.025 )
Provides a clean, formatted display of sample size and power calculation results from the twoCoprimary package.
## S3 method for class 'twoCoprimary' print(x, ...)## S3 method for class 'twoCoprimary' print(x, ...)
x |
An object of class "twoCoprimary" |
... |
Additional arguments (currently unused) |
This print method provides a formatted output that displays key parameters and results in an easy-to-read format. The specific format adapts to the type of calculation (sample size vs power) and the type of endpoints involved.
Invisibly returns the original object
Provides a clean display of design comparison tables
## S3 method for class 'twoCoprimary_table' print(x, ...)## S3 method for class 'twoCoprimary_table' print(x, ...)
x |
An object of class "twoCoprimary_table" |
... |
Additional arguments passed to print.data.frame |
Invisibly returns the original object
Calculates the rejection region for two-arm trials with a single binary endpoint using various exact statistical tests, as described in Homma and Yoshida (2025).
rr1Binary(n1, n2, alpha, Test, n_grid = 100)rr1Binary(n1, n2, alpha, Test, n_grid = 100)
n1 |
Sample size for group 1 (test group) |
n2 |
Sample size for group 2 (control group) |
alpha |
One-sided significance level (typically 0.025) |
Test |
Type of statistical test. One of:
|
n_grid |
Number of grid points used to maximize the null tail probability
over the nuisance parameter in the two exact unconditional tests, that is
|
This function computes the rejection region for five different one-sided tests:
Chi-squared test: Uses the asymptotic normal approximation of the chi-squared statistic.
Fisher exact test: Uses the hypergeometric distribution to calculate exact p-values conditional on the total number of successes.
Fisher mid-p test: Modification of Fisher's exact test that adds half the probability of the observed outcome to reduce conservatism.
Z-pooled test: Exact unconditional test that maximizes p-values over all possible values of the nuisance parameter (common success probability under H0).
Boschloo test: Exact unconditional test similar to Z-pooled but based on Fisher's exact p-values, maximizing over the nuisance parameter.
For the two exact unconditional tests the outcomes are ordered from the most extreme to the least extreme value of the ordering statistic, and the null tail probability is accumulated along that order before being maximized over the nuisance parameter. Outcomes that share the same value of the ordering statistic form a tie group, and since the tail event is the set of outcomes at least as extreme as the observed one, every member of a tie group receives the tail probability accumulated up to the last member of that group. This makes the p-value independent of the order in which tied outcomes happen to be sorted.
A logical matrix of dimensions (n1+1) x (n2+1), where TRUE indicates rejection of the null hypothesis. Rows correspond to the number of responders in group 1 (0 to n1), and columns correspond to the number of responders in group 2 (0 to n2).
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.
# Simple example with small sample sizes n1 <- 5 n2 <- 5 alpha <- 0.025 RR <- rr1Binary(n1, n2, alpha, Test = 'Chisq') print(dim(RR)) # Should be (6, 6) # Fisher exact test RR_fisher <- rr1Binary(n1 = 10, n2 = 10, alpha = 0.025, Test = 'Fisher') # More computationally intensive: Boschloo test n1 <- 20 n2 <- 10 alpha <- 0.025 RR <- rr1Binary(n1, n2, alpha, Test = 'Boschloo') print(RR)# Simple example with small sample sizes n1 <- 5 n2 <- 5 alpha <- 0.025 RR <- rr1Binary(n1, n2, alpha, Test = 'Chisq') print(dim(RR)) # Should be (6, 6) # Fisher exact test RR_fisher <- rr1Binary(n1 = 10, n2 = 10, alpha = 0.025, Test = 'Fisher') # More computationally intensive: Boschloo test n1 <- 20 n2 <- 10 alpha <- 0.025 RR <- rr1Binary(n1, n2, alpha, Test = 'Boschloo') print(RR)
Calculates the required sample size for a two-arm superiority trial with a single binary endpoint using various statistical testing methods.
ss1BinaryApprox(p1, p2, r, alpha, beta, Test = "AN")ss1BinaryApprox(p1, p2, r, alpha, beta, Test = "AN")
p1 |
True probability of responders in group 1 (0 < p1 < 1). Must be
greater than |
p2 |
True probability of responders in group 2 (0 < p2 < 1) |
r |
Allocation ratio of group 1 to group 2 (group 1:group 2 = r:1, where r > 0) |
alpha |
One-sided significance level (typically 0.025) |
beta |
Target type II error rate (typically 0.1 or 0.2) |
Test |
Statistical testing method. One of:
|
This function implements sample size calculations for single binary endpoint trials using five different methods.
Important: This function is designed for a single binary endpoint.
For co-primary endpoints, use ss2BinaryApprox (for approximate
methods) or ss2BinaryExact (for exact methods).
Notation:
r = n1/n2: allocation ratio (group 1 to group 2)
kappa = 1/r = n2/n1: inverse allocation ratio
p1, p2: response probabilities
theta1 = 1 - p1, theta2 = 1 - p2: non-response probabilities
delta = p1 - p2: treatment effect
All four asymptotic methods return the smallest whose realized
group sizes reach the target power under power2BinaryApprox
with both endpoints set to the same marginal. The closed forms below give the
starting value of that search. They are not used as the answer, because they
assume that is exactly , whereas is rounded
up to an integer, and because for the two continuity corrected methods the
correction depends on the sample size being solved for.
AN (Asymptotic Normal) Method: Uses the standard normal approximation with pooled variance under H0:
where is the pooled proportion.
ANc Method: Adds Yates's continuity correction to the AN method.
AS (Arcsine) Method: Uses the variance-stabilizing arcsine transformation:
ASc Method: Applies continuity correction to the arcsine method. The correction moves the two arms toward each other, and the variance is adjusted for the corrected proportions following Sozu et al. (2010).
Fisher Method: Fisher's exact test does not have a closed-form sample size formula. This method:
Starts with the AN method's sample size as initial value
Incrementally increases n2 by 1
Calculates exact power by summing the binomial probabilities over the rejection region
Stops when power is greater than or equal to 1 - beta
Steps back down while the target is still met, so that a starting value that already reached the target does not hide a smaller one
Note: Due to the saw-tooth nature of exact power (power does not increase monotonically with sample size), a sequential search approach is used. The incremental approach ensures the minimum sample size that achieves the target power.
A data frame with the following columns:
p1 |
Probability of responders in group 1 |
p2 |
Probability of responders in group 2 |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
Test |
Testing method used |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
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.
# Balanced design with 1:1 allocation (AN method) ss1BinaryApprox(p1 = 0.6, p2 = 0.4, r = 1, alpha = 0.025, beta = 0.1, Test = "AN") # Unbalanced design with 2:1 allocation (ANc method) ss1BinaryApprox(p1 = 0.5, p2 = 0.3, r = 2, alpha = 0.025, beta = 0.2, Test = "ANc") # Arcsine transformation method ss1BinaryApprox(p1 = 0.55, p2 = 0.35, r = 1, alpha = 0.025, beta = 0.1, Test = "AS") # Arcsine with continuity correction ss1BinaryApprox(p1 = 0.65, p2 = 0.45, r = 1, alpha = 0.025, beta = 0.1, Test = "ASc") # Fisher's exact test ss1BinaryApprox(p1 = 0.6, p2 = 0.4, r = 2, alpha = 0.025, beta = 0.1, Test = "Fisher")# Balanced design with 1:1 allocation (AN method) ss1BinaryApprox(p1 = 0.6, p2 = 0.4, r = 1, alpha = 0.025, beta = 0.1, Test = "AN") # Unbalanced design with 2:1 allocation (ANc method) ss1BinaryApprox(p1 = 0.5, p2 = 0.3, r = 2, alpha = 0.025, beta = 0.2, Test = "ANc") # Arcsine transformation method ss1BinaryApprox(p1 = 0.55, p2 = 0.35, r = 1, alpha = 0.025, beta = 0.1, Test = "AS") # Arcsine with continuity correction ss1BinaryApprox(p1 = 0.65, p2 = 0.45, r = 1, alpha = 0.025, beta = 0.1, Test = "ASc") # Fisher's exact test ss1BinaryApprox(p1 = 0.6, p2 = 0.4, r = 2, alpha = 0.025, beta = 0.1, Test = "Fisher")
Calculates the required sample size for a two-arm superiority trial with a single continuous endpoint using the standard formula for normally distributed outcomes.
ss1Continuous(delta, sd, r, alpha, beta)ss1Continuous(delta, sd, r, alpha, beta)
delta |
Mean difference between treatment groups (treatment effect) |
sd |
Common standard deviation for the continuous endpoint |
r |
Allocation ratio of group 1 to group 2 (group 1:group 2 = r:1, where r > 0) |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Target type II error rate (typically 0.1 or 0.2) |
The required sample size for group 2 is calculated using the standard formula:
where and are the quantiles of the standard normal
distribution corresponding to the one-sided significance level and
type II error rate , respectively. The sample size for group 1 is
.
A data frame with the following columns:
delta |
Mean difference (treatment effect) |
sd |
Common standard deviation |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
# Balanced design with 1:1 allocation ss1Continuous(delta = 0.4, sd = 1, r = 1, alpha = 0.025, beta = 0.1) # Unbalanced design with 2:1 allocation ss1Continuous(delta = 0.5, sd = 1.2, r = 2, alpha = 0.025, beta = 0.2) # Large treatment effect ss1Continuous(delta = 0.8, sd = 1, r = 1, alpha = 0.025, beta = 0.1)# Balanced design with 1:1 allocation ss1Continuous(delta = 0.4, sd = 1, r = 1, alpha = 0.025, beta = 0.1) # Unbalanced design with 2:1 allocation ss1Continuous(delta = 0.5, sd = 1.2, r = 2, alpha = 0.025, beta = 0.2) # Large treatment effect ss1Continuous(delta = 0.8, sd = 1, r = 1, alpha = 0.025, beta = 0.1)
Calculates the required sample size for a two-arm superiority trial with a single overdispersed count endpoint following a negative binomial distribution, as described in Homma and Yoshida (2024).
ss1Count(r1, r2, nu, t, r, alpha, beta)ss1Count(r1, r2, nu, t, r, alpha, beta)
r1 |
Mean rate (events per unit time) for the treatment group, which
must be less than |
r2 |
Mean rate (events per unit time) for the control group |
nu |
Common dispersion parameter for the negative binomial distribution (nu > 0) |
t |
Common follow-up time period |
r |
Allocation ratio (treatment:control = r:1, where r > 0) |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Target type II error rate (typically 0.1 or 0.2) |
The test statistic for the negative binomial rate ratio is:
where and the variance is:
This is equation (8) in Homma and Yoshida (2024).
A data frame with the following columns:
r1 |
Mean rate for treatment group |
r2 |
Mean rate for control group |
nu |
Dispersion parameter |
t |
Follow-up time |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
n1 |
Required sample size for treatment group |
n2 |
Required sample size for control group |
N |
Total sample size (n2 + n1) |
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.
# Sample size for count endpoint with nu = 0.8 ss1Count(r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, r = 1, alpha = 0.025, beta = 0.1) # Unbalanced design with 2:1 allocation ss1Count(r1 = 1.0, r2 = 1.5, nu = 1.0, t = 1, r = 2, alpha = 0.025, beta = 0.2) # Higher dispersion ss1Count(r1 = 1.5, r2 = 2.0, nu = 3.0, t = 1, r = 1, alpha = 0.025, beta = 0.1)# Sample size for count endpoint with nu = 0.8 ss1Count(r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, r = 1, alpha = 0.025, beta = 0.1) # Unbalanced design with 2:1 allocation ss1Count(r1 = 1.0, r2 = 1.5, nu = 1.0, t = 1, r = 2, alpha = 0.025, beta = 0.2) # Higher dispersion ss1Count(r1 = 1.5, r2 = 2.0, nu = 3.0, t = 1, r = 1, alpha = 0.025, beta = 0.1)
Calculates the required sample size for a two-arm superiority trial with two co-primary binary endpoints using asymptotic normal approximation or arcsine transformation, as described in Sozu et al. (2010).
ss2BinaryApprox(p11, p12, p21, p22, rho1, rho2, r, alpha, beta, Test)ss2BinaryApprox(p11, p12, p21, p22, rho1, rho2, r, alpha, beta, Test)
p11 |
True probability of responders in group 1 for the first outcome (0 < p11 < 1) |
p12 |
True probability of responders in group 1 for the second outcome (0 < p12 < 1) |
p21 |
True probability of responders in group 2 for the first outcome (0 < p21 < 1) |
p22 |
True probability of responders in group 2 for the second outcome (0 < p22 < 1) |
rho1 |
Correlation between the two outcomes for group 1 |
rho2 |
Correlation between the two outcomes for group 2 |
r |
Allocation ratio of group 1 to group 2 (group 1:group 2 = r:1, where r > 0) |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Target type II error rate (typically 0.1 or 0.2) |
Test |
Statistical testing method. One of:
|
This function uses a sequential search algorithm (Homma and Yoshida 2025, Algorithm 1) to find the minimum sample size:
Step 1: Initialize with sample sizes from single endpoint formulas.
Step 2: Use sequential search:
Calculate power at initial sample size
If power >= target: decrease n2 until power < target, then add 1 back
If power < target: increase n2 until power >= target
Step 3: Return final sample sizes.
The asymptotic normal (AN) and arcsine (AS) methods use normal approximation
with or without continuity correction. For small sample sizes or extreme
probabilities, consider using exact methods via ss2BinaryExact.
A data frame with the following columns:
p11, p12, p21, p22
|
Response probabilities |
rho1, rho2
|
Correlations |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
Test |
Testing method used |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
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.
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.
# Sample size calculation using asymptotic normal method ss2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = 'AN' ) # With continuity correction ss2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = 'ANc' ) # Using arcsine transformation ss2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = 'AS' )# Sample size calculation using asymptotic normal method ss2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = 'AN' ) # With continuity correction ss2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = 'ANc' ) # Using arcsine transformation ss2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = 'AS' )
Calculates the required sample size for a two-arm superiority trial with two co-primary binary endpoints using exact methods, as described in Homma and Yoshida (2025).
ss2BinaryExact( p11, p12, p21, p22, rho1, rho2, r, alpha, beta, Test, n_grid = 100 )ss2BinaryExact( p11, p12, p21, p22, rho1, rho2, r, alpha, beta, Test, n_grid = 100 )
p11 |
True probability of responders in group 1 for the first outcome (0 < p11 < 1) |
p12 |
True probability of responders in group 1 for the second outcome (0 < p12 < 1) |
p21 |
True probability of responders in group 2 for the first outcome (0 < p21 < 1) |
p22 |
True probability of responders in group 2 for the second outcome (0 < p22 < 1) |
rho1 |
Correlation between the two outcomes for group 1 |
rho2 |
Correlation between the two outcomes for group 2 |
r |
Allocation ratio of group 1 to group 2 (group 1:group 2 = r:1, where r > 0) |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Target type II error rate (typically 0.1 or 0.2) |
Test |
Statistical testing method. One of:
|
n_grid |
Number of grid points used to maximize the null tail probability
over the nuisance parameter in the two exact unconditional tests, that is
|
This function uses a sequential search algorithm to find the minimum sample size that achieves the target power:
Step 1: Initialize with sample size from approximate method (AN). This provides a good starting point for the exact calculation.
Step 2: Use sequential search algorithm (Homma and Yoshida 2025, Algorithm 1):
Calculate power at initial sample size
If power >= target: decrease n2 until power < target, then add 1 back
If power < target: increase n2 until power >= target
Step 3: Return final sample sizes.
Note: Due to the saw-tooth nature of exact power (power does not increase monotonically with sample size), this sequential search ensures the minimum sample size that achieves the target power.
A data frame with the following columns:
p11, p12, p21, p22
|
Response probabilities |
rho1, rho2
|
Correlations |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
Test |
Testing method used |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
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.
# Quick example with Chi-squared test (faster) ss2BinaryExact( p11 = 0.6, p12 = 0.5, p21 = 0.4, p22 = 0.3, rho1 = 0.3, rho2 = 0.3, r = 1, alpha = 0.025, beta = 0.2, Test = "Chisq" ) # More computationally intensive example with Fisher test ss2BinaryExact( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = "Fisher" )# Quick example with Chi-squared test (faster) ss2BinaryExact( p11 = 0.6, p12 = 0.5, p21 = 0.4, p22 = 0.3, rho1 = 0.3, rho2 = 0.3, r = 1, alpha = 0.025, beta = 0.2, Test = "Chisq" ) # More computationally intensive example with Fisher test ss2BinaryExact( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, r = 1, alpha = 0.025, beta = 0.2, Test = "Fisher" )
Calculates the required sample size for a two-arm superiority trial with two co-primary continuous endpoints using sequential search algorithm.
ss2Continuous( delta1, delta2, sd1, sd2, rho, r, alpha, beta, known_var = TRUE, nMC = 10000 )ss2Continuous( delta1, delta2, sd1, sd2, rho, r, alpha, beta, known_var = TRUE, nMC = 10000 )
delta1 |
Mean difference for the first endpoint |
delta2 |
Mean difference for the second endpoint |
sd1 |
Common standard deviation for the first endpoint |
sd2 |
Common standard deviation for the second endpoint |
rho |
Common correlation between the two outcomes |
r |
Allocation ratio of group 1 to group 2 (group 1:group 2 = r:1, where r > 0) |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Target type II error rate (typically 0.1 or 0.2) |
known_var |
Logical value indicating whether variance is known (TRUE) or unknown (FALSE). If TRUE, power is calculated analytically; if FALSE, Monte Carlo simulation is used |
nMC |
Number of Monte Carlo simulations when known_var = FALSE (default is 10000) |
This function uses a sequential search algorithm (Homma and Yoshida 2025, Algorithm 1) for both known and unknown variance cases:
Step 1: Initialize with sample sizes from single endpoint formulas.
Step 2: Use sequential search:
Calculate power at initial sample size
If power >= target: decrease n2 until power < target, then add 1 back
If power < target: increase n2 until power >= target
Step 3: Return final sample sizes.
For known variance, the standardized test statistics are:
For unknown variance, t-statistics with degrees of
freedom are used, and power is calculated using Monte Carlo simulation following
Sozu et al. (2011).
A data frame with the following columns:
delta1, delta2
|
Mean differences |
sd1, sd2
|
Standard deviations |
rho |
Correlation |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
known_var |
Variance assumption |
nMC |
Number of Monte Carlo simulations (NA if known_var = TRUE) |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
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.
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.
# Sample size calculation with known variance ss2Continuous( delta1 = 0.2, delta2 = 0.2, sd1 = 1, sd2 = 1, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, known_var = TRUE ) # Sample size calculation with unequal allocation ss2Continuous( delta1 = 0.3, delta2 = 0.25, sd1 = 1, sd2 = 1, rho = 0.3, r = 2, alpha = 0.025, beta = 0.2, known_var = TRUE ) # Sample size calculation with unknown variance (uses sequential search) ss2Continuous( delta1 = 0.5, delta2 = 0.4, sd1 = 1, sd2 = 1, rho = 0.4, r = 1, alpha = 0.025, beta = 0.1, known_var = FALSE, nMC = 10000 )# Sample size calculation with known variance ss2Continuous( delta1 = 0.2, delta2 = 0.2, sd1 = 1, sd2 = 1, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, known_var = TRUE ) # Sample size calculation with unequal allocation ss2Continuous( delta1 = 0.3, delta2 = 0.25, sd1 = 1, sd2 = 1, rho = 0.3, r = 2, alpha = 0.025, beta = 0.2, known_var = TRUE ) # Sample size calculation with unknown variance (uses sequential search) ss2Continuous( delta1 = 0.5, delta2 = 0.4, sd1 = 1, sd2 = 1, rho = 0.4, r = 1, alpha = 0.025, beta = 0.1, known_var = FALSE, nMC = 10000 )
Determines the sample size for a two-arm superiority trial with two co-primary endpoints where one is continuous and one is binary, to achieve a specified power at a given significance level.
ss2MixedContinuousBinary( delta, sd, p1, p2, rho, r, alpha, beta, Test, nMC = 10000 )ss2MixedContinuousBinary( delta, sd, p1, p2, rho, r, alpha, beta, Test, nMC = 10000 )
delta |
Mean difference for the continuous endpoint (group 1 - group 2) |
sd |
Common standard deviation for the continuous endpoint |
p1 |
Probability of response in group 1 for the binary endpoint (0 < p1 < 1) |
p2 |
Probability of response in group 2 for the binary endpoint (0 < p2 < 1) |
rho |
Biserial correlation between the latent continuous variable underlying the binary endpoint and the observed continuous endpoint |
r |
Allocation ratio n1/n2 where n1 is sample size for group 1 |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Type II error rate (typically 0.1 or 0.2). Power = 1 - beta |
Test |
Statistical testing method for the binary endpoint. One of:
|
nMC |
Number of Monte Carlo replications when Test = "Fisher" (default: 10000) |
This function implements the sample size calculation for mixed continuous-binary co-primary endpoints following the methodology in Sozu et al. (2012).
The sequential search algorithm (Homma and Yoshida 2025, Algorithm 1) is used for all testing methods:
Step 1: Initialize with sample sizes from single endpoint formulas.
Step 2: Use sequential search:
Calculate power at initial sample size
If power >= target: decrease n2 until power < target, then add 1 back
If power < target: increase n2 until power >= target
Step 3: Return final sample sizes.
Biserial Correlation: The biserial correlation rho represents the correlation between the latent continuous variable underlying the binary endpoint and the observed continuous endpoint. This is not the same as the point-biserial correlation observed in the data.
The Monte Carlo step of Test = "Fisher" draws random numbers, so
results vary between calls unless a seed is set with set.seed
beforehand. The sequential search for the sample size compares a simulated
power against the target, so the returned sample size can differ by a subject
or two between runs; increasing nMC reduces that variation.
A data frame with the following columns:
delta |
Mean difference for continuous endpoint |
sd |
Standard deviation for continuous endpoint |
p1 |
Response probability in group 1 for binary endpoint |
p2 |
Response probability in group 2 for binary endpoint |
rho |
Biserial correlation |
r |
Allocation ratio |
alpha |
One-sided significance level |
beta |
Type II error rate |
Test |
Testing method used for binary endpoint |
nMC |
Number of Monte Carlo replications (NA if Test != "Fisher") |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
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.
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.
# Sample size calculation using asymptotic normal method ss2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, Test = 'AN' ) # With continuity correction ss2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, Test = 'ANc' ) # Fisher's exact test (computationally intensive) ss2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, Test = 'Fisher', nMC = 5000 )# Sample size calculation using asymptotic normal method ss2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, Test = 'AN' ) # With continuity correction ss2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, Test = 'ANc' ) # Fisher's exact test (computationally intensive) ss2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, r = 1, alpha = 0.025, beta = 0.1, Test = 'Fisher', nMC = 5000 )
Determines the sample size for a two-arm superiority trial with two co-primary endpoints where one is a count (negative binomial) and one is continuous (normal), to achieve a specified power at a given significance level.
ss2MixedCountContinuous( r1, r2, nu, t, mu1, mu2, sd, r, rho1, rho2, alpha, beta )ss2MixedCountContinuous( r1, r2, nu, t, mu1, mu2, sd, r, rho1, rho2, alpha, beta )
r1 |
Mean count rate in group 1 for the count endpoint |
r2 |
Mean count rate in group 2 for the count endpoint |
nu |
Dispersion parameter for the negative binomial distribution (nu > 0). Smaller values indicate greater overdispersion |
t |
Follow-up time period |
mu1 |
Mean for group 1 for the continuous endpoint |
mu2 |
Mean for group 2 for the continuous endpoint |
sd |
Common standard deviation for the continuous endpoint |
r |
Allocation ratio n1/n2 where n1 is sample size for group 1 |
rho1 |
Correlation between count and continuous endpoints in group 1 |
rho2 |
Correlation between count and continuous endpoints in group 2 |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
beta |
Type II error rate (typically 0.1 or 0.2). Power = 1 - beta |
This function implements the sample size calculation for mixed count-continuous co-primary endpoints following the methodology in Homma and Yoshida (2024).
The sequential search algorithm (Homma and Yoshida 2025, Algorithm 1) is used:
Step 1: Initialize with sample sizes from single endpoint formulas.
Step 2: Use sequential search:
Calculate power at initial sample size
If power >= target: decrease n2 until power < target, then add 1 back
If power < target: increase n2 until power >= target
Step 3: Return final sample sizes.
Negative Binomial Distribution: The count endpoint follows a negative binomial distribution NB(lambda, nu) where:
lambda_j = r_j * t is the mean count in group j, where r_j is the event rate per unit time and t the follow-up period. Note that r_j is distinct from the allocation ratio r = n1/n2
nu is the dispersion parameter
Variance = lambda + lambda^2 / nu
Correlation:
The correlations rho1 and rho2 must satisfy feasibility constraints that depend
on the parameters. Use corrbound2MixedCountContinuous to check
valid correlation bounds.
A data frame with the following columns:
r1, r2
|
Count rates |
nu |
Dispersion parameter |
t |
Follow-up time |
mu1, mu2
|
Means for continuous endpoint |
sd |
Standard deviation for continuous endpoint |
r |
Allocation ratio |
rho1, rho2
|
Correlations |
alpha |
One-sided significance level |
beta |
Type II error rate |
n1 |
Required sample size for group 1 |
n2 |
Required sample size for group 2 |
N |
Total sample size (n1 + n2) |
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.
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.
# Sample size calculation for count and continuous endpoints ss2MixedCountContinuous( r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, r = 1, rho1 = 0.4, rho2 = 0.4, alpha = 0.025, beta = 0.2 ) # With different dispersion parameter (more overdispersion). The sequential # search reaches several hundred subjects per group, so this is kept out of # the routinely executed examples. ss2MixedCountContinuous( r1 = 1.0, r2 = 1.25, nu = 0.5, t = 1, mu1 = -50, mu2 = 0, sd = 250, r = 1, rho1 = 0.4, rho2 = 0.4, alpha = 0.025, beta = 0.2 )# Sample size calculation for count and continuous endpoints ss2MixedCountContinuous( r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, r = 1, rho1 = 0.4, rho2 = 0.4, alpha = 0.025, beta = 0.2 ) # With different dispersion parameter (more overdispersion). The sequential # search reaches several hundred subjects per group, so this is kept out of # the routinely executed examples. ss2MixedCountContinuous( r1 = 1.0, r2 = 1.25, nu = 0.5, t = 1, mu1 = -50, mu2 = 0, sd = 250, r = 1, rho1 = 0.4, rho2 = 0.4, alpha = 0.025, beta = 0.2 )
This function provides a unified interface for both power calculation and sample size determination for two co-primary binary endpoints using asymptotic normal approximation methods.
twoCoprimary2BinaryApprox( n1 = NULL, n2 = NULL, p11, p12, p21, p22, rho1, rho2, power = NULL, r = NULL, alpha = 0.025, Test = "AN" )twoCoprimary2BinaryApprox( n1 = NULL, n2 = NULL, p11, p12, p21, p22, rho1, rho2, power = NULL, r = NULL, alpha = 0.025, Test = "AN" )
n1 |
Sample size for group 1 (treatment group). If NULL, will be calculated. |
n2 |
Sample size for group 2 (control group). If NULL, will be calculated. |
p11 |
True response probability for endpoint 1 in group 1 |
p12 |
True response probability for endpoint 2 in group 1 |
p21 |
True response probability for endpoint 1 in group 2 |
p22 |
True response probability for endpoint 2 in group 2 |
rho1 |
Correlation between endpoints 1 and 2 in group 1 |
rho2 |
Correlation between endpoints 1 and 2 in group 2 |
power |
Target power (1 - beta). If NULL, will be calculated. |
r |
Allocation ratio (n1/n2). Required when calculating sample size. |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
Test |
Test method: "AN" (asymptotic normal), "ANc" (with continuity correction), "AS" (arcsine), or "ASc" (arcsine with continuity correction) |
This function serves as a unified interface similar to power.prop.test().
The function determines the operation mode based on which parameters are NULL.
Exactly one of {(n1, n2), (power, r)} must be NULL.
An object of class "twoCoprimary" containing either:
Power calculation results (when n1 and n2 are specified)
Sample size calculation results (when power and r are specified)
# Calculate power given sample sizes twoCoprimary2BinaryApprox( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = "AN" ) # Calculate sample size given target power twoCoprimary2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, power = 0.8, r = 1, alpha = 0.025, Test = "AN" )# Calculate power given sample sizes twoCoprimary2BinaryApprox( n1 = 200, n2 = 100, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, alpha = 0.025, Test = "AN" ) # Calculate sample size given target power twoCoprimary2BinaryApprox( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.7, rho2 = 0.7, power = 0.8, r = 1, alpha = 0.025, Test = "AN" )
This function provides a unified interface for both power calculation and sample size determination for two co-primary binary endpoints using exact inference methods.
twoCoprimary2BinaryExact( n1 = NULL, n2 = NULL, p11, p12, p21, p22, rho1, rho2, power = NULL, r = NULL, alpha = 0.025, Test = "Fisher", n_grid = 100 )twoCoprimary2BinaryExact( n1 = NULL, n2 = NULL, p11, p12, p21, p22, rho1, rho2, power = NULL, r = NULL, alpha = 0.025, Test = "Fisher", n_grid = 100 )
n1 |
Sample size for group 1 (treatment group). If NULL, will be calculated. |
n2 |
Sample size for group 2 (control group). If NULL, will be calculated. |
p11 |
True response probability for endpoint 1 in group 1 |
p12 |
True response probability for endpoint 2 in group 1 |
p21 |
True response probability for endpoint 1 in group 2 |
p22 |
True response probability for endpoint 2 in group 2 |
rho1 |
Correlation between endpoints 1 and 2 in group 1 |
rho2 |
Correlation between endpoints 1 and 2 in group 2 |
power |
Target power (1 - beta). If NULL, will be calculated. |
r |
Allocation ratio (n1/n2). Required when calculating sample size. |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
Test |
Test method: "Chisq" (one-sided Pearson chi-squared test), "Fisher" (Fisher's exact test), "Fisher-midP" (Fisher's mid-p test), "Z-pool" (Z-pooled exact unconditional test), or "Boschloo" (Boschloo's exact unconditional test) |
n_grid |
Number of grid points used to maximize the null tail probability
over the nuisance parameter in the two exact unconditional tests, that is
|
This function serves as a unified interface similar to power.prop.test().
The function determines the operation mode based on which parameters are NULL.
Exactly one of {(n1, n2), (power, r)} must be NULL.
Note: Exact methods are computationally intensive and may take considerable time, especially for large sample sizes.
An object of class "twoCoprimary" containing either:
Power calculation results (when n1 and n2 are specified)
Sample size calculation results (when power and r are specified)
# Calculate power given sample sizes twoCoprimary2BinaryExact( n1 = 50, n2 = 50, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, alpha = 0.025, Test = "Fisher" ) # Calculate sample size given target power twoCoprimary2BinaryExact( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, power = 0.8, r = 1, alpha = 0.025, Test = "Chisq" )# Calculate power given sample sizes twoCoprimary2BinaryExact( n1 = 50, n2 = 50, p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, alpha = 0.025, Test = "Fisher" ) # Calculate sample size given target power twoCoprimary2BinaryExact( p11 = 0.5, p12 = 0.4, p21 = 0.3, p22 = 0.2, rho1 = 0.5, rho2 = 0.5, power = 0.8, r = 1, alpha = 0.025, Test = "Chisq" )
This function provides a unified interface for both power calculation and sample size determination for two co-primary continuous endpoints. Depending on which parameters are provided (sample sizes or power), the function automatically determines whether to calculate power or sample size.
twoCoprimary2Continuous( n1 = NULL, n2 = NULL, delta1, delta2, sd1, sd2, rho, power = NULL, r = NULL, alpha = 0.025, known_var = TRUE, nMC = 10000 )twoCoprimary2Continuous( n1 = NULL, n2 = NULL, delta1, delta2, sd1, sd2, rho, power = NULL, r = NULL, alpha = 0.025, known_var = TRUE, nMC = 10000 )
n1 |
Sample size for group 1 (treatment group). If NULL, will be calculated. |
n2 |
Sample size for group 2 (control group). If NULL, will be calculated. |
delta1 |
Mean difference for the first endpoint |
delta2 |
Mean difference for the second endpoint |
sd1 |
Common standard deviation for the first endpoint |
sd2 |
Common standard deviation for the second endpoint |
rho |
Common correlation between the two outcomes |
power |
Target power (1 - beta). If NULL, will be calculated. |
r |
Allocation ratio (n1/n2). Required when calculating sample size. |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
known_var |
Logical indicating whether variance is known (TRUE) or unknown (FALSE). Default is TRUE. |
nMC |
Number of Monte Carlo simulations when known_var = FALSE. Default is 10000. |
This function serves as a unified interface similar to power.prop.test().
The function determines the operation mode based on which parameters are NULL:
If n1 and n2 are provided and power is NULL: calculates power
If power and r are provided and n1/n2 are NULL: calculates sample size
Exactly one of {(n1, n2), (power, r)} must be NULL.
An object of class "twoCoprimary" containing either:
Power calculation results (when n1 and n2 are specified)
Sample size calculation results (when power and r are specified)
# Calculate power given sample sizes twoCoprimary2Continuous( n1 = 100, n2 = 100, delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.3, alpha = 0.025, known_var = TRUE ) # Calculate sample size given target power twoCoprimary2Continuous( delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.3, power = 0.8, r = 1, alpha = 0.025, known_var = TRUE )# Calculate power given sample sizes twoCoprimary2Continuous( n1 = 100, n2 = 100, delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.3, alpha = 0.025, known_var = TRUE ) # Calculate sample size given target power twoCoprimary2Continuous( delta1 = 0.5, delta2 = 0.5, sd1 = 1, sd2 = 1, rho = 0.3, power = 0.8, r = 1, alpha = 0.025, known_var = TRUE )
This function provides a unified interface for both power calculation and sample size determination for trials with one continuous and one binary co-primary endpoint.
twoCoprimary2MixedContinuousBinary( n1 = NULL, n2 = NULL, delta, sd, p1, p2, rho, power = NULL, r = NULL, alpha = 0.025, Test = "AN", nMC = 10000 )twoCoprimary2MixedContinuousBinary( n1 = NULL, n2 = NULL, delta, sd, p1, p2, rho, power = NULL, r = NULL, alpha = 0.025, Test = "AN", nMC = 10000 )
n1 |
Sample size for group 1 (treatment group). If NULL, will be calculated. |
n2 |
Sample size for group 2 (control group). If NULL, will be calculated. |
delta |
Mean difference for the continuous endpoint |
sd |
Common standard deviation for the continuous endpoint |
p1 |
True response probability for the binary endpoint in group 1 |
p2 |
True response probability for the binary endpoint in group 2 |
rho |
Biserial correlation between the continuous endpoint and the latent continuous variable underlying the binary endpoint |
power |
Target power (1 - beta). If NULL, will be calculated. |
r |
Allocation ratio (n1/n2). Required when calculating sample size. |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
Test |
Test method for the binary endpoint: "AN" (asymptotic normal), "ANc" (with continuity correction), "AS" (arcsine), "ASc" (arcsine with continuity correction), or "Fisher" (Fisher's exact test) |
nMC |
Number of Monte Carlo simulations when Test = "Fisher". Default is 10000. |
This function serves as a unified interface similar to power.prop.test().
The function determines the operation mode based on which parameters are NULL.
Exactly one of {(n1, n2), (power, r)} must be NULL.
The biserial correlation rho represents the correlation between the observed continuous endpoint and the latent continuous variable underlying the binary endpoint.
An object of class "twoCoprimary" containing either:
Power calculation results (when n1 and n2 are specified)
Sample size calculation results (when power and r are specified)
# Calculate power given sample sizes twoCoprimary2MixedContinuousBinary( n1 = 100, n2 = 100, delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, alpha = 0.025, Test = "AN" ) # Calculate sample size given target power twoCoprimary2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, power = 0.8, r = 1, alpha = 0.025, Test = "AN" )# Calculate power given sample sizes twoCoprimary2MixedContinuousBinary( n1 = 100, n2 = 100, delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, alpha = 0.025, Test = "AN" ) # Calculate sample size given target power twoCoprimary2MixedContinuousBinary( delta = 0.5, sd = 1, p1 = 0.6, p2 = 0.4, rho = 0.5, power = 0.8, r = 1, alpha = 0.025, Test = "AN" )
This function provides a unified interface for both power calculation and sample size determination for trials with one count endpoint (modeled by negative binomial distribution) and one continuous endpoint.
twoCoprimary2MixedCountContinuous( n1 = NULL, n2 = NULL, r1, r2, nu, t, mu1, mu2, sd, rho1, rho2, power = NULL, r = NULL, alpha = 0.025 )twoCoprimary2MixedCountContinuous( n1 = NULL, n2 = NULL, r1, r2, nu, t, mu1, mu2, sd, rho1, rho2, power = NULL, r = NULL, alpha = 0.025 )
n1 |
Sample size for group 1 (treatment group). If NULL, will be calculated. |
n2 |
Sample size for group 2 (control group). If NULL, will be calculated. |
r1 |
Event rate per unit time for the count endpoint in group 1 |
r2 |
Event rate per unit time for the count endpoint in group 2 |
nu |
Dispersion parameter for the negative binomial distribution (nu > 0). When nu approaches infinity, the distribution converges to Poisson. |
t |
Follow-up period (time unit) |
mu1 |
Mean for the continuous endpoint in group 1 |
mu2 |
Mean for the continuous endpoint in group 2 |
sd |
Common standard deviation for the continuous endpoint |
rho1 |
Correlation between count and continuous endpoints in group 1 |
rho2 |
Correlation between count and continuous endpoints in group 2 |
power |
Target power (1 - beta). If NULL, will be calculated. |
r |
Allocation ratio (n1/n2). Required when calculating sample size. |
alpha |
One-sided significance level (typically 0.025 or 0.05) |
This function serves as a unified interface similar to power.prop.test().
The function determines the operation mode based on which parameters are NULL.
Exactly one of {(n1, n2), (power, r)} must be NULL.
The count endpoint is modeled using a negative binomial distribution to account for overdispersion. The dispersion parameter nu controls the variance: Var = lambda + lambda^2/nu.
An object of class "twoCoprimary" containing either:
Power calculation results (when n1 and n2 are specified)
Sample size calculation results (when power and r are specified)
# Calculate power given sample sizes twoCoprimary2MixedCountContinuous( n1 = 300, n2 = 300, r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.5, rho2 = 0.5, alpha = 0.025 ) # Calculate sample size given target power twoCoprimary2MixedCountContinuous( r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.5, rho2 = 0.5, power = 0.8, r = 1, alpha = 0.025 )# Calculate power given sample sizes twoCoprimary2MixedCountContinuous( n1 = 300, n2 = 300, r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.5, rho2 = 0.5, alpha = 0.025 ) # Calculate sample size given target power twoCoprimary2MixedCountContinuous( r1 = 1.0, r2 = 1.25, nu = 0.8, t = 1, mu1 = -50, mu2 = 0, sd = 250, rho1 = 0.5, rho2 = 0.5, power = 0.8, r = 1, alpha = 0.025 )