Type: Package
Title: Sample Size and Power Calculation for Two Co-Primary Endpoints
Version: 1.0.0
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.
License: MIT + file LICENSE
Encoding: UTF-8
Depends: R (≥ 3.5.0)
Imports: mvtnorm, pbivnorm, fpCompare, stats
Suggests: dplyr, knitr, rmarkdown, testthat (≥ 3.0.0), tibble, tidyr, readr
VignetteBuilder: knitr
RoxygenNote: 7.3.3
URL: https://gosukehommaex.github.io/twoCoprimary/, https://github.com/gosukehommaEX/twoCoprimary
BugReports: https://github.com/gosukehommaEX/twoCoprimary/issues
Language: en-US
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-11-18 10:18:05 UTC; i_lik
Author: Gosuke Homma ORCID iD [aut, cre]
Maintainer: Gosuke Homma <my.name.is.gosuke@gmail.com>
Repository: CRAN
Date/Publication: 2025-11-21 14:50:02 UTC

Calculate Correlation Bounds Between Two Binary Outcomes

Description

Computes the lower and upper bounds of the correlation coefficient between two binary outcomes based on their marginal probabilities, as described in Prentice (1988).

Usage

corrbound2Binary(p1, p2)

Arguments

p1

True probability of responders for the first outcome (0 < p1 < 1)

p2

True probability of responders for the second outcome (0 < p2 < 1)

Details

For two binary outcomes with marginal probabilities p1 and p2, the correlation coefficient rho is bounded by:

\rho \in [L(p_1, p_2), U(p_1, p_2)]

where

L(p_1, p_2) = \max\left\{-\sqrt{\frac{p_1 p_2}{(1-p_1)(1-p_2)}}, -\sqrt{\frac{(1-p_1)(1-p_2)}{p_1 p_2}}\right\}

U(p_1, p_2) = \min\left\{\sqrt{\frac{p_1(1-p_2)}{p_2(1-p_1)}}, \sqrt{\frac{p_2(1-p_1)}{p_1(1-p_2)}}\right\}

Value

A named numeric vector with two elements:

L_bound

Lower bound of the correlation

U_bound

Upper bound of the correlation

References

Prentice, R. L. (1988). Correlated binary regression with covariates specific to each binary observation. Biometrics, 44(4), 1033-1048.

Examples

# 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 Between Count and Continuous Outcomes

Description

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).

Usage

corrbound2MixedCountContinuous(lambda, nu, mu, sd)

Arguments

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)

Details

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:

Var(Y_1) = \lambda + \frac{\lambda^2}{\nu}

The variance of the negative binomial distribution is: Var(Y1) = lambda + lambda^2/nu

Value

A named numeric vector with two elements:

L_bound

Lower bound of the correlation

U_bound

Upper bound of the correlation

References

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.

Examples

# 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)


Probability Mass Function of Bivariate Binomial Distribution

Description

Calculates the probability mass function of the bivariate binomial distribution for given parameters, as described in Homma and Yoshida (2025).

Usage

dbibinom(N, y1, y2, p1, p2, rho)

Arguments

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

Details

The bivariate binomial distribution BiBin(N, p1, p2, gamma) has probability mass function given by equation (3) in Homma and Yoshida (2025):

P(Y_1 = y_1, Y_2 = y_2) = f(y_1|N, p_1) \times g(y_2|y_1, N, p_1, p_2, \gamma)

where

g(y_2|y_1, N, p_1, p_2, \gamma) = \frac{1}{(1+\gamma)^N} \sum_{m \in \mathcal{M}} \binom{y_1}{m} \binom{N-y_1}{y_2-m} (\xi+\gamma)^m (1-\xi)^{y_1-m} \xi^{y_2-m} (1-\xi+\gamma)^{N-y_1-(y_2-m)}

with \xi = p_2 + \gamma(p_2 - p_1) and \mathcal{M} = \{m : m = \max(0, y_2-(N-y_1)), \ldots, \min(y_1, y_2)\}.

Value

Probability mass function value(s) for the bivariate binomial distribution. If y1 and y2 are vectors, returns a vector of probabilities.

References

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), 1-19.

Examples

# 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)))


Create Design Comparison Table for Two Co-Primary Endpoints

Description

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.

Usage

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
)

Arguments

param_grid

A data.frame containing parameter combinations. Required columns depend on endpoint_type and calculation_mode:

  • For continuous endpoints (sample size): delta1, delta2, sd1, sd2

  • For continuous endpoints (power): n1, n2, delta1, delta2, sd1, sd2

  • For binary endpoints (sample size): p11, p12, p21, p22

  • For binary endpoints (power): n1, n2, p11, p12, p21, p22

  • For mixed continuous-binary (sample size): delta, sd, p1, p2

  • For mixed continuous-binary (power): n1, n2, delta, sd, p1, p2

  • For mixed count-continuous (sample size): r1, r2, nu, t, mu1, mu2, sd

  • For mixed count-continuous (power): n1, n2, r1, r2, nu, t, mu1, mu2, sd

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 binary endpoints: "AN" (asymptotic normal), "ANc" (with continuity correction), "AS" (arcsine), or "ASc". Default is "AN". Only used for binary and mixed_cont_binary endpoints.

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).

Details

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:

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.

Value

A data.frame of class "twoCoprimary_table" with:

References

Sozu, T., Kanou, T., Hamada, C., & Yoshimura, I. (2011). Power and sample size calculations in clinical trials with multiple primary variables. Japanese Journal of Biometrics, 27, 83-96.

Examples

# 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)


Plot Method for twoCoprimary Objects

Description

Visualizes power or sample size relationships for two co-primary endpoints designs. The function automatically determines the appropriate plot based on the input object.

Usage

## 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,
  ...
)

Arguments

x

An object of class "twoCoprimary" from power or sample size calculation functions

type

Type of plot to generate:

"power_curve"

Power as a function of sample size (default for power calculation results)

"sample_size_rho"

Sample size as a function of correlation (default for sample size calculation results)

"effect_contour"

Contour plot showing combinations of effect sizes achieving target power

n_points

Number of points to compute for the curve. Default is 50.

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. Default is seq(0, 0.9, length.out = n_points).

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()

Details

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.

Value

Invisibly returns the data used to create the plot as a data frame.

Examples

# 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 for Two Co-Primary Binary Endpoints (Approximate)

Description

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).

Usage

power2BinaryApprox(n1, n2, p11, p12, p21, p22, rho1, rho2, alpha, Test)

Arguments

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:

  • "AN": Asymptotic normal method without continuity correction

  • "ANc": Asymptotic normal method with continuity correction

  • "AS": Arcsine method without continuity correction

  • "ASc": Arcsine method with continuity correction

Details

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:

\rho_{nml} = \frac{\sum_{j=1}^{2} \rho_j \sqrt{\nu_{j1}\nu_{j2}}/n_j} {se_1 \times se_2}

where \nu_{jk} = p_{jk}(1-p_{jk}).

For AS method:

\rho_{arc} = \frac{n_2 \rho_1 + n_1 \rho_2}{n_1 + n_2}

This is the weighted average of the correlations from both groups.

For ASc method:

\rho_{arc,c} = \frac{1}{se_1 \times se_2} \left(\frac{\rho_1 \sqrt{\nu_{11}\nu_{12}}}{4n_1\sqrt{\nu_{11,c}\nu_{12,c}}} + \frac{\rho_2 \sqrt{\nu_{21}\nu_{22}}}{4n_2\sqrt{\nu_{21,c}\nu_{22,c}}}\right)

where \nu_{jk,c} = (p_{jk} + c_j)(1 - p_{jk} - c_j), c_1 = -1/(2n_1), and c_2 = 1/(2n_2).

The correlation bounds are automatically checked using corrbound2Binary.

Value

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

References

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.

Examples

# 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'
)


Exact Power Calculation for Two Co-Primary Binary Endpoints

Description

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).

Usage

power2BinaryExact(n1, n2, p11, p12, p21, p22, rho1, rho2, alpha, Test)

Arguments

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:

  • "Chisq": One-sided Pearson chi-squared test

  • "Fisher": Fisher exact test

  • "Fisher-midP": Fisher mid-p test

  • "Z-pool": Z-pooled exact unconditional test

  • "Boschloo": Boschloo exact unconditional test

Details

This function calculates exact power using equation (9) in Homma and Yoshida (2025):

power_A(\theta) = \sum_{(a_{1,1},a_{2,1})\in\mathcal{A}_1} \sum_{(a_{1,2},a_{2,2})\in\mathcal{A}_2} f(a_{1,1}|N_1,p_{1,1}) \times f(a_{2,1}|N_2,p_{2,1}) \times g(a_{1,2}|a_{1,1},N_1,p_{1,1},p_{1,2},\gamma_1) \times g(a_{2,2}|a_{2,1},N_2,p_{2,1},p_{2,2},\gamma_2)

where \mathcal{A}_k is the rejection region for endpoint k, and (Y_{j,1}, Y_{j,2}) \sim BiBin(N_j, p_{j,1}, p_{j,2}, \gamma_j) follows the bivariate binomial distribution.

The correlation bounds are automatically checked using corrbound2Binary.

Value

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

References

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), 1-19.

Examples

# 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'
)



Power Calculation for Two Co-Primary Continuous Endpoints

Description

Calculates the power for a two-arm superiority trial with two co-primary continuous endpoints, as described in Sozu et al. (2011).

Usage

power2Continuous(
  n1,
  n2,
  delta1,
  delta2,
  sd1,
  sd2,
  rho,
  alpha,
  known_var = TRUE,
  nMC = 10000
)

Arguments

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)

Details

For known variance, the power is calculated using the bivariate normal distribution as described in Sozu et al. (2011). The test statistics are:

Z_k = \frac{\delta_k}{\sigma_k \sqrt{1/n_1 + 1/n_2}}

for k = 1, 2. The co-primary power is:

1 - \beta = \Phi_2\left(-z_{1-\alpha} + Z_1, -z_{1-\alpha} + Z_2 \mid \rho\right)

where \Phi_2 is the cumulative distribution function of the bivariate standard normal distribution.

For unknown variance, Monte Carlo simulation is used with Wishart-distributed variance-covariance matrices to account for variance estimation uncertainty, following equation (6) in Sozu et al. (2011):

\text{Power} = E_W\left[\Phi_2(-c_1^*\sqrt{w_{11}}, -c_2^*\sqrt{w_{22}} | \rho)\right]

where c_k^* = t_{\alpha,\nu}\sqrt{\frac{1}{\nu}} - \frac{Z_k}{\sqrt{w_{kk}}} and W follows a Wishart distribution with \nu = n_1 + n_2 - 2 degrees of freedom.

Value

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

References

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.

Examples

# 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
)



Power Calculation for Two Co-Primary Mixed Endpoints

Description

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).

Usage

power2MixedContinuousBinary(
  n1,
  n2,
  delta,
  sd,
  p1,
  p2,
  rho,
  alpha,
  Test,
  nMC = 10000
)

Arguments

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:

  • "AN": Asymptotic normal method without continuity correction

  • "ANc": Asymptotic normal method with continuity correction

  • "AS": Arcsine method without continuity correction

  • "ASc": Arcsine method with continuity correction

  • "Fisher": Fisher's exact test (Monte Carlo simulation required)

nMC

Number of Monte Carlo replications when Test = "Fisher" (default: 10000)

Details

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.

Value

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

powerCont

Power for the continuous endpoint alone

powerBin

Power for the binary endpoint alone

powerCoprimary

Power for both co-primary endpoints

References

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.

Examples

# 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 for Two Co-Primary Endpoints (Count and Continuous)

Description

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).

Usage

power2MixedCountContinuous(
  n1,
  n2,
  r1,
  r2,
  nu,
  t,
  mu1,
  mu2,
  sd,
  rho1,
  rho2,
  alpha
)

Arguments

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)

Details

The test statistics are (equation 7 in Homma and Yoshida 2024):

Z_1 = \frac{\hat{\beta}_1}{\sqrt{Var(\hat{\beta}_1)}}, \quad Z_2 = \frac{\hat{\delta}}{\sigma\sqrt{(1+\kappa)/(\kappa n_0)}}

The joint distribution of (Z1, Z2) follows an asymptotic bivariate normal distribution with correlation gamma (equation 11):

\gamma = \sum_{j=0,1} \frac{n_0 \rho_j \sqrt{1+\lambda_j/\nu}} {n_j \sqrt{\lambda_j V_a} \sqrt{(1+\kappa)/\kappa}}

where \lambda_j = r_j \times t.

The correlation bounds are automatically checked using corrbound2MixedCountContinuous.

Value

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

References

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.

Examples

# 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
)


Print Method for twoCoprimary Objects

Description

Provides a clean, formatted display of sample size and power calculation results from the twoCoprimary package.

Usage

## S3 method for class 'twoCoprimary'
print(x, ...)

Arguments

x

An object of class "twoCoprimary"

...

Additional arguments (currently unused)

Details

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.

Value

Invisibly returns the original object


Print Method for twoCoprimary_table Objects

Description

Provides a clean display of design comparison tables

Usage

## S3 method for class 'twoCoprimary_table'
print(x, ...)

Arguments

x

An object of class "twoCoprimary_table"

...

Additional arguments passed to print.data.frame

Value

Invisibly returns the original object


Rejection Region for Two-Arm Trials with a Single Binary Endpoint

Description

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).

Usage

rr1Binary(n1, n2, alpha, Test)

Arguments

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:

  • "Chisq": One-sided Pearson chi-squared test

  • "Fisher": Fisher exact test

  • "Fisher-midP": Fisher mid-p test

  • "Z-pool": Z-pooled exact unconditional test

  • "Boschloo": Boschloo exact unconditional test

Details

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.

Value

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).

References

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), 1-19.

Examples

# 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)



Sample Size Calculation for a Single Binary Endpoint

Description

Calculates the required sample size for a two-arm superiority trial with a single binary endpoint using various statistical testing methods.

Usage

ss1BinaryApprox(p1, p2, r, alpha, beta, Test = "AN")

Arguments

p1

True probability of responders in group 1 (0 < p1 < 1)

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:

  • "AN": Asymptotic normal method without continuity correction (default)

  • "ANc": Asymptotic normal method with continuity correction

  • "AS": Arcsine transformation without continuity correction

  • "ASc": Arcsine transformation with continuity correction

  • "Fisher": Fisher's exact test with iterative sample size determination

Details

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:

AN (Asymptotic Normal) Method: Uses the standard normal approximation with pooled variance under H0:

n_2 = \left\lceil \frac{(1 + \kappa)}{(\pi_1 - \pi_2)^2} \left(z_{1-\alpha} \sqrt{\bar{\pi}(1-\bar{\pi})} + z_{1-\beta} \sqrt{\kappa\pi_1\theta_1 + \pi_2\theta_2}\right)^2 / \kappa \right\rceil

where \bar{\pi} = (r\pi_1 + \pi_2)/(1 + r) is the pooled proportion.

ANc Method: Adds continuity correction to the AN method. Uses iterative calculation because the correction term depends on sample size. Converges when the difference between successive iterations is less than or equal to 1.

AS (Arcsine) Method: Uses the variance-stabilizing arcsine transformation:

n_2 = \left\lceil \frac{(z_{1-\alpha} + z_{1-\beta})^2}{4(\sin^{-1}\sqrt{\pi_1} - \sin^{-1}\sqrt{\pi_2})^2} \times \frac{1 + \kappa}{\kappa} \right\rceil

ASc Method: Applies continuity correction to the arcsine method. Uses iterative procedure with convergence criterion.

Fisher Method: Fisher's exact test does not have a closed-form sample size formula. This method:

  1. Starts with the AN method's sample size as initial value

  2. Incrementally increases n2 by 1

  3. Calculates exact power using hypergeometric distribution

  4. Stops when power is greater than or equal to 1 - beta

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.

Value

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)

References

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.

Examples

# 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")


Sample Size Calculation for a Single Continuous Endpoint

Description

Calculates the required sample size for a two-arm superiority trial with a single continuous endpoint using the standard formula for normally distributed outcomes.

Usage

ss1Continuous(delta, sd, r, alpha, beta)

Arguments

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)

Details

The required sample size for group 2 is calculated using the standard formula:

n_2 = \left\lceil \frac{(1 + 1/r) \sigma^2 (z_\alpha + z_\beta)^2}{\delta^2} \right\rceil

where z_\alpha and z_\beta are the quantiles of the standard normal distribution corresponding to the one-sided significance level \alpha and type II error rate \beta, respectively. The sample size for group 1 is n_1 = \lceil r \times n_2 \rceil.

Value

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)

Examples

# 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)


Sample Size Calculation for a Single Count Endpoint (Negative Binomial)

Description

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).

Usage

ss1Count(r1, r2, nu, t, r, alpha, beta)

Arguments

r1

Mean rate (events per unit time) for the treatment group

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)

Details

The test statistic for the negative binomial rate ratio is:

Z_1 = \frac{\hat{\beta}_1}{\sqrt{Var(\hat{\beta}_1)}}

where \hat{\beta}_1 = \log(\bar{Y}_1) - \log(\bar{Y}_2) and the variance is:

Var(\hat{\beta}_1) = \frac{1}{n_2}\left[\frac{1}{t}\left(\frac{1}{r_2} + \frac{1}{r \cdot r_1}\right) + \frac{1+r}{\nu \cdot r}\right]

This is equation (8) in Homma and Yoshida (2024).

Value

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)

References

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.

Examples

# 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 Calculation for Two Co-Primary Binary Endpoints (Asymptotic Approximation)

Description

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).

Usage

ss2BinaryApprox(p11, p12, p21, p22, rho1, rho2, r, alpha, beta, Test)

Arguments

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:

  • "AN": Asymptotic normal method without continuity correction

  • "ANc": Asymptotic normal method with continuity correction

  • "AS": Arcsine method without continuity correction

  • "ASc": Arcsine method with continuity correction

Details

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:

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.

Value

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)

References

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(1), 1-19.

Examples

# 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'
)


Exact Sample Size Calculation for Two Co-Primary Binary Endpoints

Description

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).

Usage

ss2BinaryExact(p11, p12, p21, p22, rho1, rho2, r, alpha, beta, Test)

Arguments

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:

  • "Chisq": One-sided Pearson chi-squared test

  • "Fisher": Fisher exact test

  • "Fisher-midP": Fisher mid-p test

  • "Z-pool": Z-pooled exact unconditional test

  • "Boschloo": Boschloo exact unconditional test

Details

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):

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.

Value

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)

References

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), 1-19.

Examples

# 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"
)



Sample Size Calculation for Two Co-Primary Continuous Endpoints (Approximate)

Description

Calculates the required sample size for a two-arm superiority trial with two co-primary continuous endpoints using sequential search algorithm.

Usage

ss2Continuous(
  delta1,
  delta2,
  sd1,
  sd2,
  rho,
  r,
  alpha,
  beta,
  known_var = TRUE,
  nMC = 10000
)

Arguments

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)

Details

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:

Step 3: Return final sample sizes.

For known variance, the standardized test statistics are:

Z_k = \frac{\delta_k}{\sigma_k \sqrt{1/n_1 + 1/n_2}}

For unknown variance, t-statistics with \nu = n_1 + n_2 - 2 degrees of freedom are used, and power is calculated using Monte Carlo simulation following Sozu et al. (2011).

Value

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)

References

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(1), 1-19.

Examples

# 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 for Two Co-Primary Endpoints: One Continuous and One Binary

Description

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.

Usage

ss2MixedContinuousBinary(
  delta,
  sd,
  p1,
  p2,
  rho,
  r,
  alpha,
  beta,
  Test,
  nMC = 10000
)

Arguments

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:

  • "AN": Asymptotic normal method without continuity correction

  • "ANc": Asymptotic normal method with continuity correction

  • "AS": Arcsine method without continuity correction

  • "ASc": Arcsine method with continuity correction

  • "Fisher": Fisher's exact test (uses sequential search)

nMC

Number of Monte Carlo replications when Test = "Fisher" (default: 10000)

Details

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:

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.

Value

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)

References

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(1), 1-19.

Examples

# 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 for Two Co-Primary Endpoints: One Count and One Continuous

Description

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.

Usage

ss2MixedCountContinuous(
  r1,
  r2,
  nu,
  t,
  mu1,
  mu2,
  sd,
  r,
  rho1,
  rho2,
  alpha,
  beta
)

Arguments

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

Details

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:

Step 3: Return final sample sizes.

Negative Binomial Distribution: The count endpoint follows a negative binomial distribution NB(lambda, nu) where:

Correlation: The correlations rho1 and rho2 must satisfy feasibility constraints that depend on the parameters. Use corrbound2MixedCountContinuous to check valid correlation bounds.

Value

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)

References

Homma, G., & Yoshida, T. (2024). Sample size calculation for count and continuous multiple co-primary endpoints. Pharmaceutical Statistics, 23(3), 372-388.

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), 1-19.

Examples

# 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)
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
)


Unified Interface for Two Co-Primary Binary Endpoints (Approximate Methods)

Description

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.

Usage

twoCoprimary2BinaryApprox(
  n1 = NULL,
  n2 = NULL,
  p11,
  p12,
  p21,
  p22,
  rho1,
  rho2,
  power = NULL,
  r = NULL,
  alpha = 0.025,
  Test = "AN"
)

Arguments

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)

Details

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.

Value

An object of class "twoCoprimary" containing either:

Examples

# 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"
)


Unified Interface for Two Co-Primary Binary Endpoints (Exact Methods)

Description

This function provides a unified interface for both power calculation and sample size determination for two co-primary binary endpoints using exact inference methods.

Usage

twoCoprimary2BinaryExact(
  n1 = NULL,
  n2 = NULL,
  p11,
  p12,
  p21,
  p22,
  rho1,
  rho2,
  power = NULL,
  r = NULL,
  alpha = 0.025,
  Test = "Fisher"
)

Arguments

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: "Fisher" (Fisher's exact test), "Chisq" (Chi-squared test), "Z-pooled" (Z-pooled exact unconditional test), or "Boschloo" (Boschloo's exact unconditional test)

Details

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.

Value

An object of class "twoCoprimary" containing either:

Examples


# 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"
)



Unified Interface for Two Co-Primary Continuous Endpoints

Description

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.

Usage

twoCoprimary2Continuous(
  n1 = NULL,
  n2 = NULL,
  delta1,
  delta2,
  sd1,
  sd2,
  rho,
  power = NULL,
  r = NULL,
  alpha = 0.025,
  known_var = TRUE,
  nMC = 10000
)

Arguments

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.

Details

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.

Value

An object of class "twoCoprimary" containing either:

Examples

# 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
)


Unified Interface for Mixed Continuous and Binary Co-Primary Endpoints

Description

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.

Usage

twoCoprimary2MixedContinuousBinary(
  n1 = NULL,
  n2 = NULL,
  delta,
  sd,
  p1,
  p2,
  rho,
  power = NULL,
  r = NULL,
  alpha = 0.025,
  Test = "AN",
  nMC = 10000
)

Arguments

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.

Details

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.

Value

An object of class "twoCoprimary" containing either:

Examples

# 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"
)


Unified Interface for Mixed Count and Continuous Co-Primary Endpoints

Description

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.

Usage

twoCoprimary2MixedCountContinuous(
  n1 = NULL,
  n2 = NULL,
  r1,
  r2,
  nu,
  t,
  mu1,
  mu2,
  sd,
  rho1,
  rho2,
  power = NULL,
  r = NULL,
  alpha = 0.025
)

Arguments

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)

Details

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.

Value

An object of class "twoCoprimary" containing either:

Examples

# 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
)