|
6 | 6 | #' @param sigma_list list of sigma vectors, each element corresponds to a comparator with a sigma vector of size number of endpoints. |
7 | 7 | #' @param cor_mat matrix specifying the correlation matrix between endpoints, used along with sigma_list to calculate the varcov list in case it is not provided. |
8 | 8 | #' @param sigmaB number between subject variance only for 2x2 design. |
9 | | -#' @param Eper Vector of length 2, specifying the period effect in `dtype = "2x2"` design, applied to c(Period 0, Period 1). |
10 | | -#' @param Eco Vector of length 2, specifying the carry-over effect for each arm in `dtype = "2x2"` design, applied to c(Reference, Treatment). |
| 9 | +#' @param Eper Optional. Vector of length 2 specifying the period effect in a `dtype = "2x2"` design, applied to c(Period 0, Period 1). Defaults to `c(0, 0)` if not provided. Ignored for `dtype = "parallel"`. |
| 10 | +#' @param Eco Optional. Vector of length 2 specifying the carry-over effect for each arm in a `dtype = "2x2"` design, applied to c(Reference, Treatment). Defaults to `c(0, 0)` if not provided. Ignored for `dtype = "parallel"`. |
11 | 11 | #' @param rho Correlation parameter applied uniformly across all endpoint pairs, used with sigma_list to calculate varcov if cor_mat or varcov_list are not provided. |
12 | 12 | #' @param TAR vector of allocation rates with allocation rates of the arm, default is equivalent rate. |
13 | 13 | #' @param arm_names Optional vector with the treatment names. If not supplied, it will be derived from mu_list. |
|
81 | 81 | #' FDA = c("AUClast", "Cmax")) |
82 | 82 | #' |
83 | 83 | #'# Run the simulation |
84 | | -#'sampleSize(power = 0.9, # target power |
85 | | -#' alpha = 0.05, |
86 | | -#' mu_list = mu_list, |
87 | | -#' sigma_list = sigma_list, |
88 | | -#' lequi.tol = lequi.tol, |
89 | | -#' uequi.tol = uequi.tol, |
90 | | -#' list_comparator = list_comparator, |
91 | | -#' list_y_comparator = list_y_comparator, |
92 | | -#' adjust = "no", |
93 | | -#' dtype = "parallel", |
94 | | -#' ctype = "ROM", |
95 | | -#' vareq = FALSE, |
96 | | -#' lognorm = TRUE, |
97 | | -#' ncores = 1, |
98 | | -#' nsim = 50, |
99 | | -#' seed = 1234) |
| 84 | +#'sampleSize(power = 0.9, alpha = 0.05, mu_list = mu_list, |
| 85 | +#' sigma_list = sigma_list, lequi.tol = lequi.tol, |
| 86 | +#' uequi.tol = uequi.tol, list_comparator = list_comparator, |
| 87 | +#' list_y_comparator = list_y_comparator, adjust = "no", |
| 88 | +#' dtype = "parallel", ctype = "ROM", vareq = FALSE, |
| 89 | +#' lognorm = TRUE, ncores = 1, nsim = 50, seed = 1234) |
100 | 90 | #' |
101 | 91 | #' @export |
102 | 92 | sampleSize <- function(mu_list, varcov_list=NA, sigma_list=NA, cor_mat=NA, |
103 | | - sigmaB =NA, Eper = c(0,0), Eco = c(0,0), rho=0, |
| 93 | + sigmaB =NA, Eper, Eco, rho=0, |
104 | 94 | TAR=NA, |
105 | 95 | arm_names=NA, |
106 | 96 | ynames_list=NA, |
@@ -132,6 +122,10 @@ sampleSize <- function(mu_list, varcov_list=NA, sigma_list=NA, cor_mat=NA, |
132 | 122 | optimization_method = "fast" |
133 | 123 | ){ |
134 | 124 |
|
| 125 | + # Assign default values for Eper and Eco |
| 126 | + if (missing(Eper)) Eper <- c(0, 0) |
| 127 | + if (missing(Eco)) Eco <- c(0, 0) |
| 128 | + |
135 | 129 | # is mu provided? |
136 | 130 | if (all(is.na(mu_list))) { |
137 | 131 | stop("mu_list must be provided") |
@@ -462,7 +456,7 @@ sampleSize <- function(mu_list, varcov_list=NA, sigma_list=NA, cor_mat=NA, |
462 | 456 | } |
463 | 457 |
|
464 | 458 | # Check if dtype is "parallel" and Eper or Eco are non-default |
465 | | - if ((any(Eper != c(0, 0)) || any(Eco != c(0, 0)))) { |
| 459 | + if (any(Eper != c(0, 0)) || any(Eco != c(0, 0))) { |
466 | 460 | warning("Eper and Eco are only applicable for dtype = '2x2'. Non-default values for Eper or Eco will be ignored in parallel design.") |
467 | 461 | } |
468 | 462 | } else { |
|
0 commit comments