Title: | Sample Size Estimation for Bio-Equivalence Trials Through Simulation |
Version: | 1.0.2 |
Description: | Sample size estimation for bio-equivalence trials is supported through a simulation-based approach that extends the Two One-Sided Tests (TOST) procedure. The methodology provides flexibility in hypothesis testing, accommodates multiple treatment comparisons, and accounts for correlated endpoints. Users can model complex trial scenarios, including parallel and crossover designs, intra-subject variability, and different equivalence margins. Monte Carlo simulations enable accurate estimation of power and type I error rates, ensuring well-calibrated study designs. The statistical framework builds on established methods for equivalence testing and multiple hypothesis testing in bio-equivalence studies, as described in Schuirmann (1987) <doi:10.1007/BF01068419>, Mielke et al. (2018) <doi:10.1080/19466315.2017.1371071>, Shieh (2022) <doi:10.1371/journal.pone.0269128>, and Sozu et al. (2015) <doi:10.1007/978-3-319-22005-5>. Comprehensive documentation and vignettes guide users through implementation and interpretation of results. |
License: | Apache License (≥ 2) |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Imports: | MASS, Rcpp (≥ 1.0.13), data.table, matrixcalc, parallel |
Suggests: | PowerTOST, ggplot2, kableExtra, knitr, rmarkdown, testthat (≥ 3.0.0), tibble, tinytest |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
LinkingTo: | Rcpp, RcppArmadillo |
URL: | https://smartdata-analysis-and-statistics.github.io/SimTOST/ |
NeedsCompilation: | yes |
Packaged: | 2025-02-18 16:16:14 UTC; Thomas |
Author: | Thomas Debray |
Maintainer: | Thomas Debray <tdebray@fromdatatowisdom.com> |
Repository: | CRAN |
Date/Publication: | 2025-02-18 23:40:08 UTC |
Sample Size Estimation via Simulation
Description
SimTOST: A Package for Sample Size Simulations
Details
The SimTOST package provides tools for simulating sample sizes, calculating power, and assessing type-I error for various statistical scenarios.
Author(s)
Maintainer: Thomas Debray tdebray@fromdatatowisdom.com (ORCID)
Authors:
Johanna Munoz johanna.munoz@fromdatatowisdom.com
Other contributors:
Dewi Amaliah dewi.amaliah@fromdatatowisdom.com [contributor]
Wei Wei wei.wei@biogen.com [contributor]
Marian Mitroiu marian.mitroiu@biogen.com [contributor]
Scott McDonald scott.mcdonald@fromdatatowisdom.com [contributor]
Biogen Inc [copyright holder, funder]
References
Mielke, J., Jones, B., Jilma, B. & König, F. Sample Size for Multiple Hypothesis Testing in Biosimilar Development. Statistics in Biopharmaceutical Research 10, 39–49 (2018).
See Also
Check Equivalence for Multiple Endpoints
Description
This function evaluates whether equivalence criteria are met based on a predefined set of endpoints. It first checks whether all primary endpoints satisfy equivalence (if sequential testing is enabled). Then, it determines whether the required number of endpoints (k
) meet the equivalence threshold. The function returns a binary decision indicating whether overall equivalence is established.
Usage
check_equivalence(typey, adseq, tbioq, k)
Arguments
typey |
An integer vector specifying the hierarchy of each endpoint, where |
adseq |
A boolean flag indicating whether sequential testing is enabled. If set to |
tbioq |
A matrix containing the equivalence test results for each endpoint, where |
k |
An integer specifying the minimum number of endpoints required for overall equivalence. |
Details
When sequential testing is enabled (adseq = TRUE
), all primary endpoints must meet equivalence before secondary endpoints are considered. If sequential testing is disabled (adseq = FALSE
), all endpoints are evaluated simultaneously without hierarchical constraints. The function then determines whether at least k
endpoints meet the equivalence criteria. If the conditions are satisfied, the final equivalence decision (totaly
) is 1
; otherwise, it is 0
.
Value
Returns a (1 × 1 matrix) containing a binary equivalence decision. A value of 1
indicates that equivalence is established, while 0
indicates that equivalence is not established.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Derive and Validate Treatment Allocation Rate (TAR)
Description
This function validates and adjusts the treatment allocation rate (TAR
) to ensure it is correctly specified
for the given number of treatment arms (n_arms
). If TAR
is missing or NULL, it is assigned a default
vector of ones, ensuring equal allocation across all arms. The function also handles cases where TAR
is shorter than n_arms
, contains NA values, or has invalid values.
Usage
derive_allocation_rate(TAR = NULL, arm_names, verbose = FALSE)
Arguments
TAR |
Optional numeric vector specifying the allocation rate for each treatment arm. If missing, a default equal allocation rate is assigned. |
arm_names |
Character vector specifying the names of the treatment arms. Used to name the elements of |
verbose |
Logical, if |
Value
A named list representing the treatment allocation rate for each arm.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Derive or Assign Arm Names
Description
This function checks if arm_names
is provided. If arm_names
is missing, it attempts to derive names
from mu_list
. If mu_list
does not contain names, it assigns default names ("A1", "A2", etc.) to each arm.
Informational messages are displayed if verbose
is set to TRUE
.
Usage
derive_arm_names(arm_names, mu_list, verbose = FALSE)
Arguments
arm_names |
Optional vector of arm names. |
mu_list |
Named list of means per treatment arm, from which arm names may be derived. |
verbose |
Logical, if |
Value
A vector of arm names.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Derive Endpoint Names
Description
Derive Endpoint Names
Usage
derive_endpoint_names(ynames_list, mu_list, verbose = FALSE)
Arguments
ynames_list |
Optional list of vectors with endpoint names for each arm. |
mu_list |
Named list of means per treatment arm, where names can be used as endpoint names. |
verbose |
Logical, if |
Value
A list of endpoint names for each arm.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
This function derives endpoint names (ynames_list
) from mu_list
if ynames_list
is missing. If ynames_list
is already provided, it confirms the names to the user when
verbose
is set to TRUE
.
Derive Variance-Covariance Matrix List
Description
Constructs a list of variance-covariance matrices for multiple treatment arms based on provided standard deviations, means, and correlation structures.
Usage
derive_varcov_list(
mu_list,
sigma_list,
ynames_list = NULL,
varcov_list = NULL,
cor_mat = NULL,
rho = 0
)
Arguments
mu_list |
A list of numeric vectors representing the means ( |
sigma_list |
A list of numeric vectors representing the standard deviations ( |
ynames_list |
A list of character vectors specifying the names of the endpoints for each arm. Each element corresponds to one arm. |
varcov_list |
(Optional) A pre-specified list of variance-covariance matrices for each arm. If provided, it will override the construction of variance-covariance matrices. |
cor_mat |
(Optional) A correlation matrix to be used for constructing the variance-covariance matrices when there are multiple endpoints. If dimensions do not match the number of endpoints, a warning is issued. |
rho |
(Optional) A numeric value specifying the constant correlation coefficient to be used between all pairs of endpoints if no correlation matrix is provided. Default is 0 (uncorrelated endpoints). |
Details
This function creates a list of variance-covariance matrices for multiple treatment arms. If the varcov_list
is not provided,
the function uses the sigma_list
to compute the matrices. For single endpoints, the variance is simply the square of the standard deviation.
For multiple endpoints, the function constructs the matrices using either a provided cor_mat
or the constant correlation coefficient rho
.
The function ensures that the lengths of mu_list
, sigma_list
, and ynames_list
match for each arm. If dimensions mismatch,
or if neither a variance-covariance matrix (varcov_list
) nor a standard deviation list (sigma_list
) is provided, an error is raised.
Value
A list of variance-covariance matrices, one for each treatment arm.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Parameter Configuration for Endpoints and Comparators
Description
Constructs and returns a list of key parameters (mean vectors, variance-covariance matrices, and allocation rates) required for input into the sampleSize
function. This function ensures that the parameters for each endpoint and comparator are consistent, properly named, and formatted.
Usage
get_par(
mu_list,
varcov_list,
TAR_list,
type_y = NA,
arm_names = NA,
y_names = NA
)
Arguments
mu_list |
A list of mean ( |
varcov_list |
A list of variance-covariance matrices. Each element corresponds to a comparator, with a matrix of size |
TAR_list |
A list of treatment allocation rates (TARs) for each comparator. Each element contains a numeric value (can be fractional or integer) representing the allocation rate for the respective comparator. |
type_y |
A numeric vector specifying the type of each endpoint. Use |
arm_names |
(Optional) A character vector containing names of the arms. If not provided, default names (e.g., T1, T2, ...) will be generated. |
y_names |
(Optional) A character vector containing names of the endpoints. If not provided, default names (e.g., y1, y2, ...) will be generated. |
Value
A named list with the following components:
mu
A list of mean vectors, named according to
arm_names
.varcov
A list of variance-covariance matrices, named according to
arm_names
.tar
A list of treatment allocation rates (TARs), named according to
arm_names
.type_y
A vector specifying the type of each endpoint.
weight_seq
A weight sequence calculated from
type_y
, used for endpoint weighting.y_names
A vector of names for the endpoints, named as per
y_names
.
#' @details
This function ensures that all input parameters (mu_list
, varcov_list
, and TAR_list
) are consistent across comparators and endpoints. It performs checks for positive semi-definiteness of variance-covariance matrices and automatically assigns default names for arms and endpoints if not provided.
Examples
mu_list <- list(c(0.1, 0.2), c(0.15, 0.25))
varcov_list <- list(matrix(c(1, 0.5, 0.5, 1), ncol = 2), matrix(c(1, 0.3, 0.3, 1), ncol = 2))
TAR_list <- list(0.5, 0.5)
get_par(mu_list, varcov_list, TAR_list, type_y = c(1, 2), arm_names = c("Arm1", "Arm2"))
Helper function for conditional messages
Description
This function displays a message if the verbose
parameter is set to TRUE
.
It is useful for providing optional feedback to users during function execution.
Usage
info_msg(message, verbose)
Arguments
message |
A character string containing the message to display. |
verbose |
Logical, if |
Value
NULL (invisible). This function is used for side effects (displaying messages).
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
mcsapply
Description
An mc-version of the sapply function. https://stackoverflow.com/questions/31050556/parallel-version-of-sapply
Usage
mcsapply(X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
Arguments
X |
vector of iterations |
FUN |
function |
... |
additional parameters to pass |
simplify |
simplify array |
USE.NAMES |
use names in array |
Value
vector output
Plot Power vs Sample Size for Simulation Results
Description
Generates a detailed plot showing the relationship between power and total sample size for each comparator and the overall combined comparators. The plot also includes confidence intervals for power estimates and highlights the target power with a dashed line for easy visual comparison.
Usage
## S3 method for class 'simss'
plot(x, ...)
Arguments
x |
An object of class |
... |
Additional arguments to be passed to the |
Details
The plot dynamically adjusts to exclude unnecessary components, such as redundant endpoints or comparators with insufficient data, ensuring clarity and simplicity.
The ggplot2
framework is used for visualizations, allowing further customization if needed.
Value
A ggplot
object illustrating:
Power (y-axis) vs. Total Sample Size (x-axis) for individual endpoints and comparators.
Error bars representing the 95% confidence interval of the power estimates.
A dashed horizontal line indicating the target power for comparison.
Faceted panels for each comparator, making it easy to compare results across different groups.
Author(s)
Johanna Muñoz johanna.munoz@fromdatatowisdom.com
Power Calculation for Hypothesis Testing in Equivalence Trials
Description
Estimates the power of hypothesis testing in equivalence trials using the method described by Mielke et al. This approach accounts for multiple endpoints, correlation structures, and multiplicity adjustments.
Usage
power_Mielke(
N,
m,
k,
R,
sigma,
true.diff,
equi.tol = log(1.25),
design,
alpha = 0.05,
adjust = "no",
nsim = 10000
)
Arguments
N |
Integer specifying the number of subjects per sequence. |
m |
Integer specifying the number of endpoints. |
k |
Integer specifying the number of endpoints that must meet equivalence to consider the test successful. |
R |
Matrix specifying the correlation structure between endpoints.
This should be an |
sigma |
Numeric specifying the standard deviation of endpoints.
Can be a vector of length |
true.diff |
Numeric specifying the assumed true difference between test and reference.
Can be a vector of length |
equi.tol |
Numeric specifying the equivalence margins, with the interval defined as
|
design |
Character specifying the study design.
Options are |
alpha |
Numeric specifying the significance level. Default is |
adjust |
Character specifying the method for multiplicity adjustment.
Options include |
nsim |
Integer specifying the number of simulations to perform. Default is |
Value
A numeric value representing the estimated power based on the simulations.
Calculate the power across all comparators
Description
Internal function to calculate the power across all comparators
Usage
power_cal(n, nsim, param, param.d, seed, ncores)
Arguments
n |
sample size |
nsim |
number of simulated studies |
param |
list of parameters (mean,sd,tar) |
param.d |
design parameters |
seed |
main seed |
ncores |
number of cores |
Value
power calculated from a global list of comparators
Power Calculation for Difference of Means (DOM) Hypothesis Test
Description
Computes the statistical power for testing the difference of means (DOM) between two groups using Monte Carlo simulations. The power is estimated based on specified sample sizes, means, standard deviations, and significance level.
Usage
power_dom(
seed,
mu_test,
mu_control,
sigma_test,
sigma_control,
N_test,
N_control,
lb,
ub,
alpha = 0.05,
nsim = 10000
)
Arguments
seed |
Integer. Seed for reproducibility. |
mu_test |
Numeric. Mean of the test group. |
mu_control |
Numeric. Mean of the control group. |
sigma_test |
Numeric. Standard deviation of the test group. |
sigma_control |
Numeric. Standard deviation of the control group. |
N_test |
Integer. Sample size of the test group. |
N_control |
Integer. Sample size of the control group. |
lb |
Numeric. Lower bound for the equivalence margin. |
ub |
Numeric. Upper bound for the equivalence margin. |
alpha |
Numeric. Significance level (default = 0.05). |
nsim |
Integer. Number of simulations (default = 10,000). |
Value
Numeric. Estimated power (probability between 0 and 1).
Print Summary of Sample Size Estimation
Description
Prints the summary results of the sample size estimation for bioequivalence trials, including achieved power, total sample size, and power confidence intervals. The function also details the study design, primary endpoint comparisons, and applied multiplicity corrections.
Usage
## S3 method for class 'simss'
print(x, ...)
Arguments
x |
An object of class |
... |
Optional arguments to be passed from or to other methods. |
Details
This function displays key metrics from a sample size estimation analysis. It provides an overview of the study design, treatment comparisons, tested endpoints, significance level adjustments, and estimated sample size. For studies with multiple primary endpoints, it describes the multiplicity correction applied.
Value
No return value, called for side effects. The function prints the summary results of the sample size estimation to the console in a structured format.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Compute p-values for a t-distribution with Fixed Degrees of Freedom
Description
Computes p-values for a given set of random variables under a t-distribution with fixed degrees of freedom.
Usage
ptv(x, df, lower)
Arguments
x |
A numeric matrix (or vector) representing the random variables. |
df |
A double specifying the degrees of freedom. |
lower |
A logical value indicating whether to compute the lower-tail probability ( |
Value
A numeric matrix containing the computed cumulative distribution function (CDF) values (p-values).
Calculate p-values using t-distribution with Variable Degrees of Freedom
Description
This function computes the cumulative distribution function (p-values) for a given random variable x
and corresponding degrees of freedom df
using the t-distribution. The function can compute the lower or upper tail probabilities depending on the value of the lower
argument.
Usage
ptvdf(x, df, lower)
Arguments
x |
arma::mat (vector) - A matrix or vector of random variable values for which the p-values will be calculated. |
df |
arma::mat (vector) - A matrix or vector of degrees of freedom for the t-distribution, matching the size of |
lower |
bool - If |
Value
arma::mat (vector) - A matrix containing the computed cumulative distribution function (p-values) for each element in x
. The result is returned as a 1xN matrix, where N is the number of elements in x
.
Run Simulations for a 2x2 Crossover Design with Difference of Means (DOM) test
Description
This function simulates a 2x2 crossover trial across multiple iterations. It evaluates equivalence across multiple endpoints using the Difference of Means (DOM) test.
Usage
run_simulations_2x2_dom(
nsim,
n,
muT,
muR,
SigmaW,
lequi_tol,
uequi_tol,
alpha,
sigmaB,
dropout,
Eper,
Eco,
typey,
adseq,
k,
arm_seed
)
Arguments
nsim |
Integer. The number of simulations to run. |
n |
Integer. The sample size per period. |
muT |
Numeric vector. Mean outcomes for the active treatment. |
muR |
Numeric vector. Mean outcomes for the reference treatment. |
SigmaW |
Numeric matrix. Within-subject covariance matrix for endpoints. |
lequi_tol |
Numeric vector. Lower equivalence thresholds for each endpoint. |
uequi_tol |
Numeric vector. Upper equivalence thresholds for each endpoint. |
alpha |
Numeric vector. Significance levels for hypothesis testing across endpoints. |
sigmaB |
Numeric. Between-subject variance for the crossover model. |
dropout |
Numeric vector of size 2. Dropout rates for each sequence. |
Eper |
Numeric vector. Expected period effects for each sequence. |
Eco |
Numeric vector. Expected carryover effects for each sequence. |
typey |
Integer vector indicating the classification of each endpoint, where |
adseq |
Logical. If |
k |
Integer. Minimum number of endpoints required for equivalence. |
arm_seed |
Integer vector. Random seed for each simulation. |
Details
This function evaluates equivalence using the Difference of Means (DOM) test.
Equivalence is determined based on predefined lower (lequi_tol
) and upper (uequi_tol
) equivalence thresholds,
and hypothesis testing is conducted at the specified significance level (alpha
).
If adseq
is TRUE
, primary endpoints must establish equivalence before secondary endpoints are evaluated.
The sample size per period is adjusted based on dropout rates, ensuring valid study conclusions.
The simulation incorporates within-subject correlation using SigmaW
and accounts for between-subject variance with sigmaB
.
Expected period effects (Eper
) and carryover effects (Eco
) are included in the model.
A fixed random seed (arm_seed
) is used to ensure reproducibility across simulations.
Value
A numeric matrix where each column stores simulation results:
The first row (totaly
) represents the overall equivalence decision (1 = success, 0 = failure).
Subsequent rows contain equivalence decisions per endpoint,
mean estimates for the treatment group, mean estimates for the reference group,
standard deviations for treatment, and standard deviations for reference.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Run Simulations for a 2x2 Crossover Design with Ratio of Means (ROM) test
Description
This function simulates a 2x2 crossover trial across multiple iterations. It evaluates equivalence across multiple endpoints using the Ratio of Means (ROM) test.
Usage
run_simulations_2x2_rom(
nsim,
n,
muT,
muR,
SigmaW,
lequi_tol,
uequi_tol,
alpha,
sigmaB,
dropout,
Eper,
Eco,
typey,
adseq,
k,
arm_seed
)
Arguments
nsim |
Integer. The number of simulations to run. |
n |
Integer. The sample size per period. |
muT |
Numeric vector. Mean outcomes for the active treatment. |
muR |
Numeric vector. Mean outcomes for the reference treatment. |
SigmaW |
Numeric matrix. Within-subject covariance matrix for endpoints. |
lequi_tol |
Numeric vector. Lower equivalence thresholds for each endpoint. |
uequi_tol |
Numeric vector. Upper equivalence thresholds for each endpoint. |
alpha |
Numeric vector. Significance levels for hypothesis testing across endpoints. |
sigmaB |
Numeric. Between-subject variance for the crossover model. |
dropout |
Numeric vector of size 2. Dropout rates for each sequence. |
Eper |
Numeric vector. Expected period effects for each sequence. |
Eco |
Numeric vector. Expected carryover effects for each sequence. |
typey |
Integer vector indicating the classification of each endpoint, where |
adseq |
Logical. If |
k |
Integer. Minimum number of endpoints required for equivalence. |
arm_seed |
Integer vector. Random seed for each simulation. |
Details
This function evaluates equivalence using the Ratio of Means (ROM) test.
Equivalence is determined based on predefined lower lequi_tol
and upper uequi_tol
equivalence thresholds,
and hypothesis testing is conducted at the specified significance level alpha
.
If adseq
is TRUE
, primary endpoints must establish equivalence before secondary endpoints are evaluated.
The sample size per period is adjusted based on dropout rates, ensuring valid study conclusions.
The simulation incorporates within-subject correlation using SigmaW
and accounts for between-subject variance with sigmaB
.
Expected period effects Eper
and carryover effects Eco
are included in the model.
A fixed random seed arm_seed
is used to ensure reproducibility across simulations.//'
Value
A numeric matrix where each column stores simulation results:
The first row (totaly
) represents the overall equivalence decision (1 = success, 0 = failure).
Subsequent rows contain equivalence decisions per endpoint,
mean estimates for the treatment group, mean estimates for the reference group,
standard deviations for treatment, and standard deviations for reference.
@author Thomas Debray tdebray@fromdatatowisdom.com
Run Simulations for a Parallel Design with Difference of Means (DOM) test
Description
This function simulates a parallel-group trial across multiple iterations. It evaluates equivalence across multiple endpoints using the Difference of Means (DOM) test.
Usage
run_simulations_par_dom(
nsim,
n,
muT,
muR,
SigmaT,
SigmaR,
lequi_tol,
uequi_tol,
alpha,
dropout,
typey,
adseq,
k,
arm_seed_T,
arm_seed_R,
TART,
TARR,
vareq
)
Arguments
nsim |
Integer. The number of simulations to run. |
n |
Integer. The sample size per arm (before dropout). |
muT |
arma::vec. Mean vector for the treatment arm. |
muR |
arma::vec. Mean vector for the reference arm. |
SigmaT |
arma::mat. Covariance matrix for the treatment arm. |
SigmaR |
arma::mat. Covariance matrix for the reference arm. |
lequi_tol |
arma::rowvec. Lower equivalence thresholds for each endpoint. |
uequi_tol |
arma::rowvec. Upper equivalence thresholds for each endpoint. |
alpha |
arma::rowvec. Significance level for each endpoint. |
dropout |
arma::vec. Dropout rates for each arm (T, R). |
typey |
Integer vector indicating the classification of each endpoint, where |
adseq |
Boolean. If |
k |
Integer. Minimum number of endpoints required for equivalence. |
arm_seed_T |
arma::ivec. Random seed vector for the treatment group (one per simulation). |
arm_seed_R |
arma::ivec. Random seed vector for the reference group (one per simulation). |
TART |
Double. Treatment allocation ratio (proportion of subjects in treatment arm). |
TARR |
Double. Reference allocation ratio (proportion of subjects in reference arm). |
vareq |
Boolean. If |
Details
Equivalence testing uses either the Difference of Means (DOM) test,
applying predefined equivalence thresholds and significance levels. When hierarchical testing (adseq
)
is enabled, all primary endpoints must demonstrate equivalence before secondary endpoints are evaluated.
Dropout rates are incorporated into the sample size calculation to ensure proper adjustment.
Randomization is controlled through separate random seeds for the treatment and reference groups,
enhancing reproducibility.
Value
The function returns an arma::mat storing simulation results row-wise for consistency
with R's output format. The first row (totaly
) contains the overall equivalence decision
(1 for success, 0 for failure). The subsequent rows include equivalence deicisons for each endpoint,
mean estimates for both treatment and reference groups, and corresponding standard deviations.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Run Simulations for a Parallel Design with Ratio of Means (ROM) test
Description
This function simulates a parallel-group trial across multiple iterations. It evaluates equivalence across multiple endpoints using the Ratio of Means (ROM) test.
Usage
run_simulations_par_rom(
nsim,
n,
muT,
muR,
SigmaT,
SigmaR,
lequi_tol,
uequi_tol,
alpha,
dropout,
typey,
adseq,
k,
arm_seed_T,
arm_seed_R,
TART,
TARR,
vareq
)
Arguments
nsim |
Integer. The number of simulations to run. |
n |
Integer. The sample size per arm (before dropout). |
muT |
arma::vec. Mean vector for the treatment arm. |
muR |
arma::vec. Mean vector for the reference arm. |
SigmaT |
arma::mat. Covariance matrix for the treatment arm. |
SigmaR |
arma::mat. Covariance matrix for the reference arm. |
lequi_tol |
arma::rowvec. Lower equivalence thresholds for each endpoint. |
uequi_tol |
arma::rowvec. Upper equivalence thresholds for each endpoint. |
alpha |
arma::rowvec. Significance level for each endpoint. |
dropout |
arma::vec. Dropout rates for each arm (T, R). |
typey |
Integer vector indicating the classification of each endpoint, where |
adseq |
Boolean. If |
k |
Integer. Minimum number of endpoints required for equivalence. |
arm_seed_T |
arma::ivec. Random seed vector for the treatment group (one per simulation). |
arm_seed_R |
arma::ivec. Random seed vector for the reference group (one per simulation). |
TART |
Double. Treatment allocation ratio (proportion of subjects in treatment arm). |
TARR |
Double. Reference allocation ratio (proportion of subjects in reference arm). |
vareq |
Boolean. If |
Details
Equivalence testing uses either the Ratio of Means (ROM) test,
applying predefined equivalence thresholds and significance levels. When hierarchical testing (adseq
)
is enabled, all primary endpoints must demonstrate equivalence before secondary endpoints are evaluated.
Dropout rates are incorporated into the sample size calculation to ensure proper adjustment.
Randomization is controlled through separate random seeds for the treatment and reference groups,
enhancing reproducibility.
Value
The function returns an arma::mat storing simulation results row-wise for consistency
with R's output format. The first row (totaly
) contains the overall equivalence decision
(1 for success, 0 for failure). The subsequent rows include equivalence decisions for each endpoint,
mean estimates for both treatment and reference groups, and corresponding standard deviations.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Sample Size Calculation for Bioequivalence and Multi-Endpoint Studies
Description
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.
Usage
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
)
Arguments
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 |
Value
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.
Author(s)
Johanna Muñoz johanna.munoz@fromdatatowisdom.com
References
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
Examples
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 Estimation for Multiple Hypothesis Testing Using Mielke's Method
Description
Estimates the required sample size to achieve a specified power level for multiple hypothesis testing, using the approach described by Mielke et al. (2018). This function is particularly useful for bioequivalence or biosimilar studies with multiple correlated endpoints, where a minimum number of endpoints must meet equivalence criteria.
Usage
sampleSize_Mielke(
power,
Nmax,
m,
k,
rho,
sigma,
true.diff,
equi.tol,
design,
alpha,
adjust = "no",
seed = NULL,
nsim = 10000
)
Arguments
power |
Numeric. Desired statistical power. |
Nmax |
Integer. Maximum allowable sample size. |
m |
Integer. Total number of endpoints. |
k |
Integer. Number of endpoints that must meet the success criteria for overall study success. |
rho |
Numeric. Constant correlation coefficient among endpoints. |
sigma |
Numeric or vector. Standard deviation of each endpoint. If a single value is provided, it is assumed to be constant across all endpoints. In a 2x2 crossover design, this is the within-subject standard deviation; in a parallel design, it represents the treatment group’s standard deviation, assumed to be the same for both test and reference. |
true.diff |
Numeric or vector. Assumed true difference between test and reference for each endpoint. If a single value is provided, it is applied uniformly across all endpoints. |
equi.tol |
Numeric. Equivalence margin; the equivalence interval is defined as (-equi.tol, +equi.tol). |
design |
Character. Study design, either "22co" for a 2x2 crossover design or "parallel" for a parallel groups design. |
alpha |
Numeric. Significance level for the hypothesis test. |
adjust |
Character. Method for multiplicity adjustment; options are "no" (no adjustment), "bon" (Bonferroni adjustment), and "k" (k-adjustment). |
seed |
Integer. Random seed for reproducibility. |
nsim |
Integer. Number of simulations to run for power estimation (default: 10,000). |
Details
This function uses the method proposed by Mielke et al. (2018) to estimate the sample size required to achieve the desired power level in studies with multiple correlated endpoints. The function iteratively increases sample size until the target power is reached or the maximum allowable sample size (Nmax) is exceeded. The approach accounts for endpoint correlation and supports adjustments for multiple testing using various correction methods.
Value
A named vector containing:
- "power.a"
Achieved power with the estimated sample size.
- "SS"
Required sample size per sequence to achieve the target power.
References
Mielke, J., Jones, B., Jilma, B. & König, F. Sample Size for Multiple Hypothesis Testing in Biosimilar Development. Statistics in Biopharmaceutical Research 10, 39–49 (2018).
Examples
# Example 1 from Mielke
sampleSize_Mielke(power = 0.8, Nmax = 1000, m = 5, k = 5, rho = 0,
sigma = 0.3, true.diff = log(1.05), equi.tol = log(1.25),
design = "parallel", alpha = 0.05, adjust = "no",
seed = 1234, nsim = 100)
Simulated Test Statistic for Noninferiority/Equivalence Trials
Description
Simulates test statistics for multiple hypothesis testing in biosimilar development, following the approach described by Mielke et al. (2018). It calculates the necessary sample size for meeting equivalence criteria across multiple endpoints while considering correlation structures and applying multiplicity adjustments.
Usage
sign_Mielke(
N,
m,
k,
R,
sigma,
true.diff,
equi.tol = log(1.25),
design,
alpha = 0.05,
adjust = "no"
)
Arguments
N |
Integer specifying the number of subjects per sequence. |
m |
Integer specifying the number of endpoints. |
k |
Integer specifying the number of endpoints that must meet equivalence to consider the test successful. |
R |
Matrix specifying the correlation structure between endpoints.
This should be an |
sigma |
Numeric specifying the standard deviation of endpoints.
Can be a vector of length |
true.diff |
Numeric specifying the assumed true difference between test and reference.
Can be a vector of length |
equi.tol |
Numeric specifying the equivalence margins.
The interval is defined as |
design |
Character specifying the study design.
Options are |
alpha |
Numeric specifying the significance level. |
adjust |
Character specifying the method for multiplicity adjustment.
Options include |
Details
This function is designed for multiple-endpoint clinical trials, where success is defined as meeting equivalence criteria for at least a subset of tests. Simulated test statistics are based on multivariate normal distribution assumptions, and the function supports k-out-of-m success criteria for regulatory approval.
Type I error control is achieved through multiplicity adjustments as proposed by Lehmann and Romano (2005) to ensure rigorous error rate management. This approach is particularly relevant for biosimilar studies, where sample size estimation must account for multiple comparisons across endpoints, doses, or populations.
Value
A numeric vector representing a realization of the simulated test statistic for the given setting.
References
Kong, L., Kohberger, R. C., & Koch, G. G. (2004). Type I Error and Power in Noninferiority/Equivalence Trials with Correlated Multiple Endpoints: An Example from Vaccine Development Trials. Journal of Biopharmaceutical Statistics, 14(4), 893–907.
Lehmann, E. L., & Romano, J. P. (2005). Generalizations of the Familywise Error Rate. The Annals of Statistics, 33(2), 1138–1154.
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.
Generate Simulated Endpoint Data for Parallel Group Design
Description
Generate simulated endpoint data for a parallel design, with options for normal and lognormal distributions.
Usage
simParallelEndpoints(
n,
mu.arithmetic,
mu.geometric = NULL,
Sigma,
CV = NULL,
seed,
dist = "normal"
)
Arguments
n |
Integer. The sample size for the generated data. |
mu.arithmetic |
Numeric vector. The arithmetic mean of the endpoints on the original scale. |
mu.geometric |
Numeric vector. The geometric mean of the endpoints on the original scale. Only used if |
Sigma |
Matrix. Variance-covariance matrix of the raw data on the original scale. If |
CV |
Numeric vector. Coefficient of variation (CV) of the raw data. Only used when |
seed |
Integer. Seed for random number generation, ensuring reproducibility. |
dist |
Character. Assumed distribution of the endpoints: either |
Value
A matrix of simulated endpoint values for a parallel design, with dimensions n
by the number of variables in mu.arithmetic
or mu.geometric
.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Simulate a 2x2 Crossover Design and Compute Difference of Means (DOM)
Description
Simulates a two-sequence, two-period (2x2) crossover design and evaluate equivalence for the difference of means (DOM).
Usage
test_2x2_dom(
n,
muT,
muR,
SigmaW,
lequi_tol,
uequi_tol,
alpha,
sigmaB,
dropout,
Eper,
Eco,
typey,
adseq,
k,
arm_seed
)
Arguments
n |
integer number of subjects per sequence |
muT |
vector mean of endpoints on treatment arm |
muR |
vector mean of endpoints on reference arm |
SigmaW |
matrix within subject covar-variance matrix across endpoints |
lequi_tol |
vector lower equivalence tolerance band across endpoints |
uequi_tol |
vector upper equivalence tolerance band across endpoints |
alpha |
vector alpha value across endpoints |
sigmaB |
double between subject variance (assumed same for all endpoints) |
dropout |
vector of size 2 with dropout proportion per sequence (0,1) |
Eper |
vector of size 2 with period effect on period (0,1) |
Eco |
vector of size 2 with carry over effect of arm c(Reference, Treatment). |
typey |
vector with positions of primary endpoints |
adseq |
boolean is used a sequential adjustment? |
k |
integer minimum number of equivalent endpoints |
arm_seed |
seed for the simulation |
Value
A numeric matrix containing the simulated hypothesis test results. The first column represents the overall equivalence decision, where 1 indicates success and 0 indicates failure. The subsequent columns contain the hypothesis test results for each endpoint, followed by mean estimates for the reference and treatment groups, and standard deviations for the reference and treatment groups.
Simulate a 2x2 Crossover Design and Compute Ratio of Means (ROM)
Description
Simulates a two-sequence, two-period (2x2) crossover design and evaluate equivalence for the ratio of means (ROM).
Usage
test_2x2_rom(
n,
muT,
muR,
SigmaW,
lequi_tol,
uequi_tol,
alpha,
sigmaB,
dropout,
Eper,
Eco,
typey,
adseq,
k,
arm_seed
)
Arguments
n |
integer number of subjects per sequence |
muT |
vector mean of endpoints on treatment arm |
muR |
vector mean of endpoints on reference arm |
SigmaW |
matrix within subject covar-variance matrix across endpoints |
lequi_tol |
vector lower equivalence tolerance band across endpoints |
uequi_tol |
vector upper equivalence tolerance band across endpoints |
alpha |
vector alpha value across endpoints |
sigmaB |
double between subject variance (assumed same for all endpoints) |
dropout |
vector of size 2 with dropout proportion per sequence (0,1) |
Eper |
vector of size 2 with period effect on period (0,1) |
Eco |
vector of size 2 with carry over effect of arm c(Reference, Treatment). |
typey |
vector with positions of primary endpoints |
adseq |
boolean is used a sequential adjustment? |
k |
integer minimum number of equivalent endpoints |
arm_seed |
seed for the simulation |
Value
A numeric matrix containing the simulated hypothesis test results. The first column represents the overall equivalence decision, where 1 indicates success and 0 indicates failure. The subsequent columns contain the hypothesis test results for each endpoint, followed by mean estimates for the reference and treatment groups, and standard deviations for the reference and treatment groups.
Simulate a Parallel Design and Test Difference of Means (DOM)
Description
Simulates a parallel-group design and performs equivalence testing using the difference of means (DOM) approach. This function evaluates whether the treatment and reference groups are equivalent based on predefined equivalence margins and hypothesis testing criteria.
Usage
test_par_dom(
n,
muT,
muR,
SigmaT,
SigmaR,
lequi_tol,
uequi_tol,
alpha,
dropout,
typey,
adseq,
k,
arm_seedT,
arm_seedR,
TART,
TARR,
vareq
)
Arguments
n |
integer number of subjects per arm |
muT |
vector mean of endpoints on treatment arm |
muR |
vector mean of endpoints on reference arm |
SigmaT |
matrix covar-variance matrix on treatment arm across endpoints |
SigmaR |
matrix covar-variance matrix on reference arm across endpoints |
lequi_tol |
vector lower equivalence tolerance band across endpoints |
uequi_tol |
vector upper equivalence tolerance band across endpoints |
alpha |
vector alpha value across endpoints |
dropout |
vector of size 2 with dropout proportion per arm (T,R) |
typey |
vector with positions of primary endpoints |
adseq |
boolean is used a sequential adjustment? |
k |
integer minimum number of equivalent endpoints |
arm_seedT |
integer seed for the simulation on treatment arm |
arm_seedR |
integer seed for the simulation on reference arm |
TART |
double treatment allocation rate for the treatment arm |
TARR |
double treatment allocation rate for the reference arm |
vareq |
boolean assumed equivalence variance between arms for the t-test |
Details
The function simulates a parallel-group study design and evaluates equivalence
using the difference of means (DOM) approach. It accounts for dropout rates and
treatment allocation proportions while generating simulated data based on the
specified covariance structure. The test statistics are computed, and a final
equivalence decision is made based on the predefined number of required significant
endpoints (k
). If sequential testing (adseq
) is enabled, primary endpoints
must establish equivalence before secondary endpoints are evaluated.
When vareq = TRUE
, the test assumes equal variances between groups and
applies Schuirmann's two one-sided tests (TOST).
Value
A numeric matrix containing the simulated hypothesis test results. The first column represents the overall equivalence decision, where 1 indicates success and 0 indicates failure. The subsequent columns contain the hypothesis test results for each endpoint, followed by mean estimates for the reference and treatment groups, and standard deviations for the reference and treatment groups.
Simulate a Parallel Design and Test Ratio of Means (ROM)
Description
Simulates a parallel-group design and performs equivalence testing using the ratio of means (ROM) approach. This function evaluates whether the treatment and reference groups are equivalent based on predefined equivalence margins and hypothesis testing criteria.
Usage
test_par_rom(
n,
muT,
muR,
SigmaT,
SigmaR,
lequi_tol,
uequi_tol,
alpha,
dropout,
typey,
adseq,
k,
arm_seedT,
arm_seedR,
TART,
TARR,
vareq
)
Arguments
n |
integer number of subjects per arm |
muT |
vector mean of endpoints on treatment arm |
muR |
vector mean of endpoints on reference arm |
SigmaT |
matrix covar-variance matrix on treatment arm across endpoints |
SigmaR |
matrix covar-variance matrix on reference arm across endpoints |
lequi_tol |
vector lower equivalence tolerance band across endpoints |
uequi_tol |
vector upper equivalence tolerance band across endpoints |
alpha |
vector alpha value across endpoints |
dropout |
vector of size 2 with dropout proportion per arm (T,R) |
typey |
vector with positions of primary endpoints |
adseq |
boolean is used a sequential adjustment? |
k |
integer minimum number of equivalent endpoints |
arm_seedT |
integer seed for the simulation on treatment arm |
arm_seedR |
integer seed for the simulation on reference arm |
TART |
double treatment allocation rate for the treatment arm |
TARR |
double treatment allocation rate for the reference arm |
vareq |
Boolean. If |
Details
The function simulates a parallel-group study design and evaluates equivalence
using the ratio of means (ROM) approach. It accounts for dropout rates and
treatment allocation proportions while generating simulated data based on the
specified covariance structure. The test statistics are computed, and a final
equivalence decision is made based on the predefined number of required significant
endpoints (k
). If sequential testing (adseq
) is enabled, primary endpoints
must establish equivalence before secondary endpoints are evaluated.
When vareq = TRUE
, the test assumes equal variances between groups and
applies Schuirmann's two one-sided tests (TOST).
Value
A numeric matrix containing the simulated hypothesis test results. The first column represents the overall equivalence decision, where 1 indicates success and 0 indicates failure. The subsequent columns contain the hypothesis test results for each endpoint, followed by mean estimates for the reference and treatment groups, and standard deviations for the reference and treatment groups.
test_studies
Description
Internal function to estimate the bioequivalence test for nsim simulated studies given a sample size n
Usage
test_studies(nsim, n, comp, param, param.d, arm_seed, ncores)
Arguments
nsim |
number of simulated studies |
n |
sample size |
comp |
index comparator |
param |
list of parameters (mean,sd,tar) |
param.d |
design parameters |
arm_seed |
seed for each endpoint to get consistent in simulations across all comparators |
ncores |
number of cores used for the calculation |
Value
a logical matrix of size (nsim) X (number of endpoints + 1) function only replicates test_bioq nsim times.
Optimizer for Uniroot Integer (Modified)
Description
A modified integer-based root-finding algorithm for determining the sample size required to achieve a target power. This function extends the uniroot integer search method to handle cases with stepwise power searches while considering constraints on search limits.
Usage
uniroot.integer.mod(
f,
power,
lower = lower,
upper = upper,
step.power = step.power,
step.up = step.up,
pos.side = pos.side,
maxiter = maxiter,
...
)
Arguments
f |
Function for which a root is needed. |
power |
Numeric. Target power value. |
lower |
Integer. Minimum allowable root value. |
upper |
Integer. Maximum allowable root value. |
step.power |
Numeric. Initial step size defined as |
step.up |
Logical. If |
pos.side |
Logical. If |
maxiter |
Integer. Maximum number of iterations allowed. |
... |
Additional arguments passed to |
Value
A list containing:
root
The integer value closest to the root on the correct side.
f.root
Value of
f
at the estimated root.iter
Number of function evaluations performed.
table.iter
A data frame showing estimated sample size (
N
) and corresponding power at each iteration.table.test
A data frame containing endpoint-level test results for each simulation and corresponding
N
.
Validate Positive Semi-Definite Matrices
Description
Validates that all matrices in a list are symmetric and positive semi-definite.
Usage
validate_positive_definite(varcov_list)
Arguments
varcov_list |
List of matrices. Each matrix is checked to ensure it is symmetric and positive semi-definite. |
Value
NULL. If all matrices pass, the function returns nothing. If any matrix fails, it stops with an error message.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com
Check Sample Size Limits
Description
Validates that the upper and lower limits are numeric and that the upper limit is greater than the lower limit.
Usage
validate_sample_size_limits(lower, upper)
Arguments
lower |
Numeric. The initial lower limit for the search range. |
upper |
Numeric. The initial upper limit for the search range. |
Value
NULL. If the checks pass, the function returns nothing. If the checks fail, it stops execution with an error message.
Author(s)
Thomas Debray tdebray@fromdatatowisdom.com