sampleSize | R Documentation |
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
)
mu_list |
Named list of arithmetic means per treatment arm. Each element is a vector representing expected outcomes for all endpoints in that arm. |
varcov_list |
List of variance-covariance matrices, where each element corresponds to a comparator. Each matrix has dimensions: number of endpoints × number of endpoints. |
sigma_list |
List of standard deviation vectors, where each element corresponds to a comparator and contains one standard deviation per endpoint. |
cor_mat |
Matrix specifying the correlation structure between endpoints, used along with |
sigmaB |
Numeric. Between-subject variance for a 2×2 crossover design. |
Eper |
Optional numeric vector of length 2 specifying the period effect in a |
Eco |
Optional numeric vector of length 2 specifying the carry-over effect per arm in a |
rho |
Numeric. Correlation parameter applied uniformly across all endpoint pairs. Used with |
TAR |
Numeric vector specifying treatment allocation rates per arm. The order must match |
arm_names |
Optional character vector of treatment names. If not supplied, names are derived from |
ynames_list |
Optional list of vectors specifying endpoint names per arm. If names are missing, arbitrary names are assigned based on order. |
type_y |
Integer vector indicating endpoint types: |
list_comparator |
List of comparators. Each element is a vector of length 2 specifying the treatment names being compared. |
list_y_comparator |
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. |
power |
Numeric. Target power (default = 0.8). |
alpha |
Numeric. Significance level (default = 0.05). |
lequi.tol |
Numeric. Lower equivalence bounds (e.g., -0.5) applied uniformly across all endpoints and comparators. |
uequi.tol |
Numeric. Upper equivalence bounds (e.g., 0.5) applied uniformly across all endpoints and comparators. |
list_lequi.tol |
List of numeric vectors specifying lower equivalence bounds per comparator. |
list_uequi.tol |
List of numeric vectors specifying upper equivalence bounds per comparator. |
dtype |
Character. Trial design: |
ctype |
Character. Hypothesis test type: |
vareq |
Logical. Assumes equal variances across arms if |
lognorm |
Logical. Whether data follows a log-normal distribution ( |
k |
Integer vector. Minimum number of successful endpoints required for global bioequivalence per comparator. Defaults to all endpoints per comparator. |
adjust |
Character. Alpha adjustment method: |
dropout |
Numeric vector specifying dropout proportion per arm. |
nsim |
Integer. Number of simulated studies (default = 5000). |
seed |
Integer. Seed for reproducibility. |
ncores |
Integer. Number of processing cores for parallel computation. Defaults to |
optimization_method |
Character. Sample size optimization method: |
lower |
Integer. Minimum sample size for search range (default = 2). |
upper |
Integer. Maximum sample size for search range (default = 500). |
step.power |
Numeric. Initial step size for sample size search, defined as |
step.up |
Logical. If |
pos.side |
Logical. If |
maxiter |
Integer. Maximum iterations allowed for sample size estimation (default = 1000). Used when |
verbose |
Logical. If |
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.
Johanna Muñoz johanna.munoz@fromdatatowisdom.com
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.