You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' @title Run Simulations for a 2x2 Crossover Design
296
+
#' @title Run Simulations for a Parallel Design with Difference of Means (DOM) test
297
297
#'
298
298
#' @description
299
-
#' This function simulates a 2x2 crossover study design across multiple iterations (`nsim`).
300
-
#' It evaluates equivalence testing for multiple endpoints using either the
301
-
#' Difference of Means (DOM) or Ratio of Means (ROM) approach.
299
+
#' This function simulates a parallel-group trial across multiple iterations.
300
+
#' It evaluates equivalence across multiple endpoints using the
301
+
#' Difference of Means (DOM) test.
302
+
#'
303
+
#' @param nsim Integer. The number of simulations to run.
304
+
#' @param n Integer. The sample size per arm (before dropout).
305
+
#' @param muT arma::vec. Mean vector for the treatment arm.
306
+
#' @param muR arma::vec. Mean vector for the reference arm.
307
+
#' @param SigmaT arma::mat. Covariance matrix for the treatment arm.
308
+
#' @param SigmaR arma::mat. Covariance matrix for the reference arm.
309
+
#' @param lequi_tol arma::rowvec. Lower equivalence thresholds for each endpoint.
310
+
#' @param uequi_tol arma::rowvec. Upper equivalence thresholds for each endpoint.
311
+
#' @param alpha arma::rowvec. Significance level (α) for each endpoint.
312
+
#' @param dropout arma::vec. Dropout rates for each arm (T, R).
313
+
#' @param typey Integer vector indicating the classification of each endpoint, where `1` corresponds to a primary endpoint and `2` corresponds to a secondary endpoint.
314
+
#' @param adseq Boolean. If `TRUE`, applies sequential (hierarchical) testing.
315
+
#' @param k Integer. Minimum number of endpoints required for equivalence.
316
+
#' @param arm_seed_T arma::ivec. Random seed vector for the treatment group (one per simulation).
317
+
#' @param arm_seed_R arma::ivec. Random seed vector for the reference group (one per simulation).
318
+
#' @param TART Double. Treatment allocation ratio (proportion of subjects in treatment arm).
319
+
#' @param TARR Double. Reference allocation ratio (proportion of subjects in reference arm).
320
+
#' @param vareq Boolean. If `TRUE`, assumes equal variances across treatment and reference groups.
321
+
#'
322
+
#' @details
323
+
#' Equivalence testing uses either the Difference of Means (DOM) test,
324
+
#' applying predefined equivalence thresholds and significance levels. When hierarchical testing (`adseq`)
325
+
#' is enabled, all primary endpoints must demonstrate equivalence before secondary endpoints are evaluated.
326
+
#' Dropout rates are incorporated into the sample size calculation to ensure proper adjustment.
327
+
#' Randomization is controlled through separate random seeds for the treatment and reference groups,
328
+
#' enhancing reproducibility.
329
+
#'
330
+
#' @return
331
+
#' The function returns an arma::mat storing simulation results row-wise for consistency
332
+
#' with R's output format. The first row (`totaly`) contains the overall equivalence decision
333
+
#' (1 for success, 0 for failure). The subsequent rows include equivalence deicisons for each endpoint,
334
+
#' mean estimates for both treatment and reference groups, and corresponding standard deviations.
run_simulations_par_dom<-function(nsim, n, muT, muR, SigmaT, SigmaR, lequi_tol, uequi_tol, alpha, dropout, typey, adseq, k, arm_seed_T, arm_seed_R, TART, TARR, vareq) {
339
+
.Call(`_SimTOST_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)
340
+
}
341
+
342
+
#' @title Run Simulations for a Parallel Design with Ratio of Means (ROM) test
343
+
#'
344
+
#' @description
345
+
#' This function simulates a parallel-group trial across multiple iterations.
346
+
#' It evaluates equivalence across multiple endpoints using the
347
+
#' Ratio of Means (ROM) test.
348
+
#'
349
+
#' @param nsim Integer. The number of simulations to run.
350
+
#' @param n Integer. The sample size per arm (before dropout).
351
+
#' @param muT arma::vec. Mean vector for the treatment arm.
352
+
#' @param muR arma::vec. Mean vector for the reference arm.
353
+
#' @param SigmaT arma::mat. Covariance matrix for the treatment arm.
354
+
#' @param SigmaR arma::mat. Covariance matrix for the reference arm.
355
+
#' @param lequi_tol arma::rowvec. Lower equivalence thresholds for each endpoint.
356
+
#' @param uequi_tol arma::rowvec. Upper equivalence thresholds for each endpoint.
357
+
#' @param alpha arma::rowvec. Significance level (α) for each endpoint.
358
+
#' @param dropout arma::vec. Dropout rates for each arm (T, R).
359
+
#' @param typey Integer vector indicating the classification of each endpoint, where `1` corresponds to a primary endpoint and `2` corresponds to a secondary endpoint.
360
+
#' @param adseq Boolean. If `TRUE`, applies sequential (hierarchical) testing.
361
+
#' @param k Integer. Minimum number of endpoints required for equivalence.
362
+
#' @param arm_seed_T arma::ivec. Random seed vector for the treatment group (one per simulation).
363
+
#' @param arm_seed_R arma::ivec. Random seed vector for the reference group (one per simulation).
364
+
#' @param TART Double. Treatment allocation ratio (proportion of subjects in treatment arm).
365
+
#' @param TARR Double. Reference allocation ratio (proportion of subjects in reference arm).
366
+
#' @param vareq Boolean. If `TRUE`, assumes equal variances across treatment and reference groups.
367
+
#'
368
+
#' @details
369
+
#' Equivalence testing uses either the Ratio of Means (ROM) test,
370
+
#' applying predefined equivalence thresholds and significance levels. When hierarchical testing (`adseq`)
371
+
#' is enabled, all primary endpoints must demonstrate equivalence before secondary endpoints are evaluated.
372
+
#' Dropout rates are incorporated into the sample size calculation to ensure proper adjustment.
373
+
#' Randomization is controlled through separate random seeds for the treatment and reference groups,
374
+
#' enhancing reproducibility.
375
+
#'
376
+
#' @return
377
+
#' The function returns an arma::mat storing simulation results row-wise for consistency
378
+
#' with R's output format. The first row (`totaly`) contains the overall equivalence decision
379
+
#' (1 for success, 0 for failure). The subsequent rows include equivalence deicisons for each endpoint,
380
+
#' mean estimates for both treatment and reference groups, and corresponding standard deviations.
#' @title Run Simulations for a 2x2 Crossover Design with Ratio of Means (ROM) test
436
+
#'
437
+
#' @description
438
+
#' This function simulates a 2x2 crossover trial across multiple iterations.
439
+
#' It evaluates equivalence across multiple endpoints using the
440
+
#' Ratio of Means (ROM) test.
441
+
#'
442
+
#' @param nsim Integer. The number of simulations to run.
443
+
#' @param n Integer. The sample size per period.
444
+
#' @param muT Numeric vector. Mean outcomes for the active treatment.
445
+
#' @param muR Numeric vector. Mean outcomes for the reference treatment.
446
+
#' @param SigmaW Numeric matrix. Within-subject covariance matrix for endpoints.
447
+
#' @param lequi_tol Numeric vector. Lower equivalence thresholds for each endpoint.
448
+
#' @param uequi_tol Numeric vector. Upper equivalence thresholds for each endpoint.
449
+
#' @param alpha Numeric vector. Significance levels for hypothesis testing across endpoints.
450
+
#' @param sigmaB Numeric. Between-subject variance for the crossover model.
451
+
#' @param dropout Numeric vector of size 2. Dropout rates for each sequence.
452
+
#' @param Eper Numeric vector. Expected period effects for each sequence.
453
+
#' @param Eco Numeric vector. Expected carryover effects for each sequence.
454
+
#' @param typey Integer vector indicating the classification of each endpoint, where `1` corresponds to a primary endpoint and `2` corresponds to a secondary endpoint.
455
+
#' @param adseq Logical. If `TRUE`, applies sequential (hierarchical) testing.
456
+
#' @param k Integer. Minimum number of endpoints required for equivalence.
457
+
#' @param arm_seed Integer vector. Random seed for each simulation.
458
+
#'
459
+
#' @details
460
+
#' This function evaluates equivalence using either the Ratio of Means (ROM) test.
461
+
#' Equivalence is determined based on predefined lower (`lequi_tol`) and upper (`uequi_tol`) equivalence thresholds,
462
+
#' and hypothesis testing is conducted at the specified significance level (`alpha`).
463
+
#' If `adseq` is `TRUE`, primary endpoints must establish equivalence before secondary endpoints are evaluated.
464
+
#' The sample size per period is adjusted based on dropout rates, ensuring valid study conclusions.
465
+
#' The simulation incorporates within-subject correlation using `SigmaW` and accounts for between-subject variance with `sigmaB`.
466
+
#' Expected period effects (`Eper`) and carryover effects (`Eco`) are included in the model.
467
+
#' A fixed random seed (`arm_seed`) is used to ensure reproducibility across simulations.
468
+
#'
469
+
#' @return
470
+
#' A numeric matrix where each column stores simulation results:
471
+
#' The first row (`totaly`) represents the overall equivalence decision (1 = success, 0 = failure).
0 commit comments