sampleSize.Rd
Computes the required sample size to achieve a target power in studies with multiple endpoints and treatment arms. The function employs modified root-finding algorithms to estimate sample size while accounting for correlation structures, variance assumptions, and equivalence bounds across endpoints. It is particularly useful for bioequivalence trials and multi-arm studies with complex endpoint structures.
sampleSize(
mu_list,
varcov_list = NA,
sigma_list = NA,
cor_mat = NA,
sigmaB = NA,
Eper,
Eco,
rho = 0,
TAR = rep(1, length(mu_list)),
arm_names = NA,
ynames_list = NA,
type_y = NA,
list_comparator = NA,
list_y_comparator = NA,
power = 0.8,
alpha = 0.05,
lequi.tol = NA,
uequi.tol = NA,
list_lequi.tol = NA,
list_uequi.tol = NA,
dtype = "parallel",
ctype = "ROM",
vareq = TRUE,
lognorm = TRUE,
k = NA,
adjust = "no",
dropout = NA,
nsim = 5000,
seed = 1234,
ncores = 1,
optimization_method = "fast",
lower = 2,
upper = 500,
step.power = 6,
step.up = TRUE,
pos.side = FALSE,
maxiter = 1000,
verbose = FALSE
)
Named list of arithmetic means per treatment arm. Each element is a vector representing expected outcomes for all endpoints in that arm.
List of variance-covariance matrices, where each element corresponds to a comparator. Each matrix has dimensions: number of endpoints × number of endpoints.
List of standard deviation vectors, where each element corresponds to a comparator and contains one standard deviation per endpoint.
Matrix specifying the correlation structure between endpoints, used along with sigma_list
to calculate varcov_list
if not provided.
Numeric. Between-subject variance for a 2×2 crossover design.
Optional numeric vector of length 2 specifying the period effect in a dtype = "2x2"
design, applied as c(Period 0, Period 1)
. Defaults to c(0, 0)
. Ignored for dtype = "parallel"
.
Optional numeric vector of length 2 specifying the carry-over effect per arm in a dtype = "2x2"
design, applied as c(Reference, Treatment)
. Defaults to c(0, 0)
. Ignored for dtype = "parallel"
.
Numeric. Correlation parameter applied uniformly across all endpoint pairs. Used with sigma_list
to compute varcov_list
when cor_mat
or varcov_list
are not provided.
Numeric vector specifying treatment allocation rates per arm. The order must match arm_names
. Defaults to equal allocation across arms if not provided.
Optional character vector of treatment names. If not supplied, names are derived from mu_list
.
Optional list of vectors specifying endpoint names per arm. If names are missing, arbitrary names are assigned based on order.
Integer vector indicating endpoint types: 1
for co-primary endpoints, 2
for secondary endpoints.
List of comparators. Each element is a vector of length 2 specifying the treatment names being compared.
List of endpoint sets per comparator. Each element is a vector containing endpoint names to compare. If not provided, all endpoints common to both comparator arms are used.
Numeric. Target power (default = 0.8).
Numeric. Significance level (default = 0.05).
Numeric. Lower equivalence bounds (e.g., -0.5) applied uniformly across all endpoints and comparators.
Numeric. Upper equivalence bounds (e.g., 0.5) applied uniformly across all endpoints and comparators.
List of numeric vectors specifying lower equivalence bounds per comparator.
List of numeric vectors specifying upper equivalence bounds per comparator.
Character. Trial design: "parallel"
(default) for parallel-group or "2x2"
for crossover (only for 2-arm studies).
Character. Hypothesis test type: "DOM"
(Difference of Means) or "ROM"
(Ratio of Means).
Logical. Assumes equal variances across arms if TRUE
(default = FALSE
).
Logical. Whether data follows a log-normal distribution (TRUE
or FALSE
).
Integer vector. Minimum number of successful endpoints required for global bioequivalence per comparator. Defaults to all endpoints per comparator.
Character. Alpha adjustment method: "k"
(K-fold), "bon"
(Bonferroni), "sid"
(Sidak), "no"
(default, no adjustment), or "seq"
(sequential).
Numeric vector specifying dropout proportion per arm.
Integer. Number of simulated studies (default = 5000).
Integer. Seed for reproducibility.
Integer. Number of processing cores for parallel computation. Defaults to 1
. Set to NA
for automatic detection (ncores - 1
).
Character. Sample size optimization method: "fast"
(default, root-finding algorithm) or "step-by-step"
.
Integer. Minimum sample size for search range (default = 2).
Integer. Maximum sample size for search range (default = 500).
Numeric. Initial step size for sample size search, defined as 2^step.power
. Used when optimization_method = "fast"
.
Logical. If TRUE
(default), search increments upward from lower
; if FALSE
, decrements downward from upper
. Used when optimization_method = "fast"
.
Logical. If TRUE
, finds the smallest integer i
closest to the root such that f(i) > 0
. Used when optimization_method = "fast"
.
Integer. Maximum iterations allowed for sample size estimation (default = 1000). Used when optimization_method = "fast"
.
Logical. If TRUE
, prints progress and messages during execution (default = FALSE
).
A list containing:
response
Array summarizing simulation results, including estimated sample sizes, achieved power, and confidence intervals.
table.iter
Data frame showing estimated sample sizes and calculated power at each iteration.
table.test
Data frame containing test results for all simulated trials.
param.u
Original input parameters.
param
Final adjusted parameters used in sample size calculation.
param.d
Trial design parameters used in the simulation.
Schuirmann, D. J. (1987). A comparison of the Two One-Sided Tests procedure and the Power approach for assessing the equivalence of average bioavailability. Journal of Pharmacokinetics and Biopharmaceutics, 15(6), 657-680. doi:10.1007/BF01068419
Mielke, J., Jones, B., Jilma, B., & König, F. (2018). Sample size for multiple hypothesis testing in biosimilar development. Statistics in Biopharmaceutical Research, 10(1), 39-49. doi:10.1080/19466315.2017.1371071
Berger, R. L., & Hsu, J. C. (1996). Bioequivalence trials, intersection-union tests, and equivalence confidence sets. Statistical Science, 283-302.
Sozu, T., Sugimoto, T., Hamasaki, T., & Evans, S. R. (2015). "Sample Size Determination in Clinical Trials with Multiple Endpoints." SpringerBriefs in Statistics. doi:10.1007/978-3-319-22005-5
mu_list <- list(SB2 = c(AUCinf = 38703, AUClast = 36862, Cmax = 127.0),
EUREF = c(AUCinf = 39360, AUClast = 37022, Cmax = 126.2),
USREF = c(AUCinf = 39270, AUClast = 37368, Cmax = 129.2))
sigma_list <- list(SB2 = c(AUCinf = 11114, AUClast = 9133, Cmax = 16.9),
EUREF = c(AUCinf = 12332, AUClast = 9398, Cmax = 17.9),
USREF = c(AUCinf = 10064, AUClast = 8332, Cmax = 18.8))
# Equivalent boundaries
lequi.tol <- c(AUCinf = 0.8, AUClast = 0.8, Cmax = 0.8)
uequi.tol <- c(AUCinf = 1.25, AUClast = 1.25, Cmax = 1.25)
# Arms to be compared
list_comparator <- list(EMA = c("SB2", "EUREF"),
FDA = c("SB2", "USREF"))
# Endpoints to be compared
list_y_comparator <- list(EMA = c("AUCinf", "Cmax"),
FDA = c("AUClast", "Cmax"))
# Equivalence boundaries for each comparison
lequi_lower <- c(AUCinf = 0.80, AUClast = 0.80, Cmax = 0.80)
lequi_upper <- c(AUCinf = 1.25, AUClast = 1.25, Cmax = 1.25)
# Run the simulation
sampleSize(power = 0.9, alpha = 0.05, mu_list = mu_list,
sigma_list = sigma_list, list_comparator = list_comparator,
list_y_comparator = list_y_comparator,
list_lequi.tol = list("EMA" = lequi_lower, "FDA" = lequi_lower),
list_uequi.tol = list("EMA" = lequi_upper, "FDA" = lequi_upper),
adjust = "no", dtype = "parallel", ctype = "ROM", vareq = FALSE,
lognorm = TRUE, ncores = 1, nsim = 50, seed = 1234)
#> Sample Size Calculation Results
#> -------------------------------------------------------------
#> Study Design: parallel trial targeting 90% power with a 5% type-I error.
#>
#> Comparisons:
#> SB2 vs. EUREF
#> - Endpoints Tested: AUCinf, Cmax
#> (multiple co-primary endpoints, m = 2 )
#> SB2 vs. USREF
#> - Endpoints Tested: AUClast, Cmax
#> (multiple co-primary endpoints, m = 2 )
#> -------------------------------------------------------------
#> Parameter Value
#> Total Sample Size 138
#> Achieved Power 90
#> Power Confidence Interval 77.4 - 96.3
#> -------------------------------------------------------------