This function simulates a 2x2 crossover trial across multiple iterations. It evaluates equivalence across multiple endpoints using the Difference of Means (DOM) test.

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 1 corresponds to a primary endpoint and 2 corresponds to a secondary endpoint.

adseq

Logical. If TRUE, applies sequential (hierarchical) testing.

k

Integer. Minimum number of endpoints required for equivalence.

arm_seed

Integer vector. Random seed for each simulation.

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.

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.

Author

Thomas Debray tdebray@fromdatatowisdom.com