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.
get_par(
mu_list,
varcov_list,
TAR_list,
type_y = NA,
arm_names = NA,
y_names = NA
)
A list of mean (\(\mu\)) vectors. Each element in the list represents a comparator, with the corresponding \(\mu\) vector having a length equal to the number of endpoints.
A list of variance-covariance matrices. Each element corresponds to a comparator, with a matrix of size \((n \times n)\), where \(n\) is the number of endpoints.
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.
A numeric vector specifying the type of each endpoint. Use 1
for primary endpoints and 2
for secondary or other endpoints.
(Optional) A character vector containing names of the arms. If not provided, default names (e.g., T1, T2, ...) will be generated.
(Optional) A character vector containing names of the endpoints. If not provided, default names (e.g., y1, y2, ...) will be generated.
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.
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"))
#> $mu
#> $mu$Arm1
#> [1] 0.1 0.2
#>
#> $mu$Arm2
#> [1] 0.15 0.25
#>
#>
#> $varcov
#> $varcov$Arm1
#> [,1] [,2]
#> [1,] 1.0 0.5
#> [2,] 0.5 1.0
#>
#> $varcov$Arm2
#> [,1] [,2]
#> [1,] 1.0 0.3
#> [2,] 0.3 1.0
#>
#>
#> $tar
#> $tar$Arm1
#> [1] 0.5
#>
#> $tar$Arm2
#> [1] 0.5
#>
#>
#> $type_y
#> [1] 1 2
#>
#> $weight_seq
#> [1] 1 1
#>
#> $y_names
#> [1] "y1" "y2"
#>