diff --git a/DESCRIPTION b/DESCRIPTION
index a89d75a7..6c9527cc 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: rpact
Title: Confirmatory Adaptive Clinical Trial Design and Analysis
-Version: 3.5.0
-Date: 2024-01-25
+Version: 3.5.1.9231
+Date: 2024-02-09
Authors@R: c(
person(
given = "Gernot",
@@ -71,6 +71,7 @@ Config/testthat/start-first: *analysis*
Collate:
'RcppExports.R'
'f_logger.R'
+ 'class_dictionary.R'
'f_core_constants.R'
'f_core_utilities.R'
'f_core_assertions.R'
diff --git a/NAMESPACE b/NAMESPACE
index 67adb870..64368ebe 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -8,7 +8,9 @@ S3method(as.data.frame,TrialDesign)
S3method(as.data.frame,TrialDesignCharacteristics)
S3method(as.data.frame,TrialDesignPlan)
S3method(as.data.frame,TrialDesignSet)
+S3method(as.list,Dictionary)
S3method(as.matrix,FieldSet)
+S3method(as.vector,Dictionary)
S3method(knit_print,ParameterSet)
S3method(knit_print,SummaryFactory)
S3method(length,TrialDesignSet)
@@ -30,6 +32,7 @@ S3method(plot,TrialDesignCharacteristics)
S3method(plot,TrialDesignPlan)
S3method(plot,TrialDesignSet)
S3method(print,Dataset)
+S3method(print,Dictionary)
S3method(print,FieldSet)
S3method(print,ParameterSet)
S3method(print,SimulationResults)
diff --git a/NEWS.md b/NEWS.md
index 34b65a49..4f37bc83 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,10 @@
+# rpact 3.5.1
+
+* The fields `.parameterNames` and `.parameterFormatFunctions` were removed from all rpact result objects in favor of a more efficient solution
+* Issues [15](https://github.com/rpact-com/rpact/issues/15), [16](https://github.com/rpact-com/rpact/issues/16), and [17](https://github.com/rpact-com/rpact/issues/17) fixed
+
+
# rpact 3.5.0
## New features
diff --git a/R/class_analysis_dataset.R b/R/class_analysis_dataset.R
index 9eaa0137..7f95e9cf 100644
--- a/R/class_analysis_dataset.R
+++ b/R/class_analysis_dataset.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7554 $
-## | Last changed: $Date: 2024-01-12 10:19:05 +0100 (Fr, 12 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -1383,8 +1383,6 @@ Dataset <- setRefClass("Dataset",
.enrichmentEnabled = enrichmentEnabled, ...
)
.plotSettings <<- PlotSettings()
- .parameterNames <<- .getParameterNames(dataset = .self)
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
.id <<- NA_integer_
.description <<- NA_character_
@@ -2347,6 +2345,7 @@ DatasetMeans <- setRefClass("DatasetMeans",
} else {
n <- dataset$getSampleSize(stage = stage, group = group)
n <- floor(n / numberOfVisits)
+
randomData <- stats::rnorm(
n = sampleSize,
mean = dataset$getMean(stage = stage, group = group),
@@ -2365,6 +2364,7 @@ DatasetMeans <- setRefClass("DatasetMeans",
sampleSizeBefore <- sampleSize - numberOfDropOutsBefore
if (n < sampleSizeBefore) {
numberOfDropOuts <- sampleSizeBefore - n
+ numberOfDropOuts <- min(numberOfDropOuts, ceiling(n * 0.2))
dropOuts <- sample(c(rep(1, n - numberOfDropOuts), rep(0, numberOfDropOuts)))
randomData[indices[dropOuts == 0]] <- NA_real_
if (!is.null(randomDataBefore)) {
@@ -2601,7 +2601,7 @@ plot.Dataset <- function(x, y, ..., main = "Dataset", xlab = "Stage", ylab = NA_
# implement survival plot here
}
} else {
- data$stageGroup <- interaction(data$stage, data$group)
+ data$stageGroup <- base::interaction(data$stage, data$group)
if (x$isDatasetMeans()) {
p <- ggplot2::ggplot(ggplot2::aes(
@@ -2647,9 +2647,9 @@ plot.Dataset <- function(x, y, ..., main = "Dataset", xlab = "Stage", ylab = NA_
# hide second legend
if (x$getNumberOfGroups() == 1) {
- p <- p + ggplot2::guides(fill = FALSE, colour = FALSE)
+ p <- p + ggplot2::guides(fill = "none", colour = "none")
} else {
- p <- p + ggplot2::guides(colour = FALSE)
+ p <- p + ggplot2::guides(colour = "none")
}
# set theme
@@ -2680,7 +2680,7 @@ plot.Dataset <- function(x, y, ..., main = "Dataset", xlab = "Stage", ylab = NA_
}
p <- plotSettings$addCompanyAnnotation(p, enabled = companyAnnotationEnabled)
- p
+ suppressWarnings(print(p))
}
#'
diff --git a/R/class_analysis_results.R b/R/class_analysis_results.R
index c5e3e268..01297316 100644
--- a/R/class_analysis_results.R
+++ b/R/class_analysis_results.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7126 $
-## | Last changed: $Date: 2023-06-23 14:26:39 +0200 (Fr, 23 Jun 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -62,8 +62,6 @@ ConditionalPowerResults <- setRefClass("ConditionalPowerResults",
callSuper(...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- C_PARAMETER_NAMES
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
if (!is.null(.stageResults) && is.null(.design)) {
.design <<- .stageResults$.design
@@ -533,8 +531,6 @@ ClosedCombinationTestResults <- setRefClass("ClosedCombinationTestResults",
callSuper(...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- C_PARAMETER_NAMES
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
.setParameterType("intersectionTest", C_PARAM_USER_DEFINED)
@@ -560,10 +556,6 @@ ClosedCombinationTestResults <- setRefClass("ClosedCombinationTestResults",
for (param in parametersGenerated) {
.setParameterType(param, C_PARAM_GENERATED)
}
-
- if (!is.null(.design) && inherits(.design, C_CLASS_NAME_TRIAL_DESIGN_FISHER)) {
- .parameterFormatFunctions$overallAdjustedTestStatistics <<- ".formatTestStatisticsFisher"
- }
},
show = function(showType = 1, digits = NA_integer_) {
.show(showType = showType, digits = digits, consoleOutputEnabled = TRUE)
@@ -712,14 +704,10 @@ AnalysisResults <- setRefClass("AnalysisResults",
methods = list(
initialize = function(design, dataInput, ...) {
callSuper(.design = design, .dataInput = dataInput, ...)
-
.plotSettings <<- PlotSettings()
- .parameterNames <<- .getParameterNames(design = design, analysisResults = .self)
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
},
.setStageResults = function(stageResults) {
.stageResults <<- stageResults
- .parameterNames <<- .getParameterNames(design = .design, stageResults = stageResults, analysisResults = .self)
},
getPlotSettings = function() {
return(.plotSettings)
@@ -1162,7 +1150,6 @@ as.data.frame.AnalysisResults <- function(x, row.names = NULL, optional = FALSE,
return(.getAsDataFrame(
parameterSet = x,
parameterNames = parametersToShow,
- tableColumnNames = .getTableColumnNames(design = x$.design),
niceColumnNamesEnabled = niceColumnNamesEnabled
))
}
diff --git a/R/class_analysis_stage_results.R b/R/class_analysis_stage_results.R
index 378a7d36..f7377eba 100644
--- a/R/class_analysis_stage_results.R
+++ b/R/class_analysis_stage_results.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7554 $
-## | Last changed: $Date: 2024-01-12 10:19:05 +0100 (Fr, 12 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -92,9 +92,7 @@ StageResults <- setRefClass("StageResults",
} else {
.setParameterType("stages", C_PARAM_USER_DEFINED)
}
- .parameterNames <<- .getParameterNames(design = design)
}
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
.setParameterType("stage", C_PARAM_NOT_APPLICABLE)
@@ -1213,8 +1211,7 @@ as.data.frame.StageResults <- function(x, row.names = NULL,
parameterSet = x,
parameterNames = parametersToShow,
niceColumnNamesEnabled = niceColumnNamesEnabled,
- includeAllParameters = includeAllParameters,
- tableColumnNames = .getTableColumnNames(design = x$.design)
+ includeAllParameters = includeAllParameters
))
}
diff --git a/R/class_core_parameter_set.R b/R/class_core_parameter_set.R
index e1c882e6..a949808a 100644
--- a/R/class_core_parameter_set.R
+++ b/R/class_core_parameter_set.R
@@ -13,11 +13,12 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7496 $
-## | Last changed: $Date: 2023-12-15 10:42:15 +0100 (Fr, 15 Dez 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
+#' @include class_dictionary.R
#' @include f_core_constants.R
#' @include f_core_assertions.R
NULL
@@ -43,8 +44,6 @@ NULL
FieldSet <- setRefClass("FieldSet",
fields = list(
.parameterTypes = "list",
- .parameterNames = "list",
- .parameterFormatFunctions = "list",
.showParameterTypeEnabled = "logical",
.catLines = "character"
),
@@ -103,7 +102,7 @@ FieldSet <- setRefClass("FieldSet",
if (is.na(headingBaseNumber)) {
headingBaseNumber <- 0L
}
- if (headingBaseNumber < -1) {
+ if (headingBaseNumber < -2) {
warning(
"Illegal option ", sQuote("rpact.print.heading.base.number"),
" (", headingBaseNumber, ") was set to 0"
@@ -119,12 +118,13 @@ FieldSet <- setRefClass("FieldSet",
}
if (heading > 0) {
- if (headingBaseNumber == -1) {
+ if (headingBaseNumber %in% c(-1, -2)) {
lineBreak <- ""
if (grepl("\n *$", line)) {
lineBreak <- "\n\n"
}
- line <- paste0("**", sub(": *", "", trimws(line)), "**", lineBreak)
+ fontStyle <- ifelse(headingBaseNumber == -1, "**", "*")
+ line <- paste0(fontStyle, sub(": *", "", trimws(line)), fontStyle, lineBreak)
} else {
headingCmd <- paste0(rep("#", heading + headingBaseNumber + 1), collapse = "")
lineBreak <- ""
@@ -192,13 +192,6 @@ FieldSet <- setRefClass("FieldSet",
#'
ParameterSet <- setRefClass("ParameterSet",
contains = "FieldSet",
- fields = list(
- .parameterTypes = "list",
- .parameterNames = "list",
- .parameterFormatFunctions = "list",
- .showParameterTypeEnabled = "logical",
- .catLines = "character"
- ),
methods = list(
initialize = function(...,
.showParameterTypeEnabled = TRUE) {
@@ -206,8 +199,6 @@ ParameterSet <- setRefClass("ParameterSet",
.showParameterTypeEnabled = .showParameterTypeEnabled
)
.parameterTypes <<- list()
- .parameterNames <<- list()
- .parameterFormatFunctions <<- list()
.catLines <<- character(0)
},
clone = function() {
@@ -236,7 +227,8 @@ ParameterSet <- setRefClass("ParameterSet",
return(ifelse(startWithUpperCase, .firstCharacterToUpperCase(s), s))
},
.initParameterTypes = function() {
- for (parameterName in names(.parameterNames)) {
+ .parameterTypes <<- list()
+ for (parameterName in .self$.getVisibleFieldNames()) {
.parameterTypes[[parameterName]] <<- C_PARAM_TYPE_UNKNOWN
}
},
@@ -459,7 +451,7 @@ ParameterSet <- setRefClass("ParameterSet",
param$paramName <- parameterName
category <- parts[2]
- categoryCaption <- .parameterNames[[category]]
+ categoryCaption <- .getParameterCaption(category, .self)
if (is.null(categoryCaption)) {
categoryCaption <- paste0("%", category, "%")
}
@@ -492,7 +484,7 @@ ParameterSet <- setRefClass("ParameterSet",
category = NULL,
showParameterType = FALSE,
consoleOutputEnabled = TRUE) {
- if (is.null(param)) {
+ if (is.null(param) || is.null(param$paramValue) || length(param$paramValue) == 0) {
return(invisible(""))
}
@@ -568,9 +560,12 @@ ParameterSet <- setRefClass("ParameterSet",
return(invisible(output))
},
.extractParameterNameAndValue = function(parameterName) {
- d <- regexpr(paste0("\\..+\\$"), parameterName)
+ d <- regexpr("\\..+\\$", parameterName)
if (d[1] != 1) {
- return(list(parameterName = parameterName, paramValue = get(parameterName)))
+ return(list(
+ parameterName = parameterName,
+ paramValue = base::get(parameterName, envir = .self)
+ ))
}
index <- attr(d, "match.length")
@@ -601,10 +596,10 @@ ParameterSet <- setRefClass("ParameterSet",
showParameterType = FALSE, category = NULL, matrixRow = NA_integer_, consoleOutputEnabled = TRUE,
paramNameRaw = NA_character_, numberOfCategories = NA_integer_) {
if (!is.na(paramNameRaw)) {
- paramCaption <- .parameterNames[[paramNameRaw]]
+ paramCaption <- .getParameterCaption(paramNameRaw, .self)
}
if (is.null(paramCaption)) {
- paramCaption <- .parameterNames[[paramName]]
+ paramCaption <- .getParameterCaption(paramName, .self)
}
if (is.null(paramCaption)) {
paramCaption <- paste0("%", paramName, "%")
@@ -701,11 +696,16 @@ ParameterSet <- setRefClass("ParameterSet",
invisible(output)
},
.getNChar = function() {
- if (length(.parameterNames) == 0) {
+ fieldNames <- .getVisibleFieldNames()
+ if (length(fieldNames) == 0) {
return(40)
}
-
- return(min(40, max(nchar(.parameterNames))) + 4)
+
+ fieldCaptions <- character()
+ for (parameterName in fieldNames) {
+ fieldCaptions <- c(fieldCaptions, .getParameterCaption(parameterName, .self))
+ }
+ return(min(40, max(nchar(fieldCaptions))) + 4)
},
.showParameterTypeDescription = function(consoleOutputEnabled = consoleOutputEnabled) {
.cat("\n", consoleOutputEnabled = consoleOutputEnabled)
@@ -719,11 +719,6 @@ ParameterSet <- setRefClass("ParameterSet",
.printAsDataFrame = function(parameterNames, niceColumnNamesEnabled = FALSE,
includeAllParameters = FALSE, handleParameterNamesAsToBeExcluded = FALSE,
lineBreakEnabled = FALSE) {
- if (.isTrialDesign(.self)) {
- tableColumnNames <- .getTableColumnNames(design = .self)
- } else {
- tableColumnNames <- C_TABLE_COLUMN_NAMES
- }
if (.isTrialDesignPlan(.self)) {
parameterNames <- NULL
@@ -735,8 +730,7 @@ ParameterSet <- setRefClass("ParameterSet",
niceColumnNamesEnabled = niceColumnNamesEnabled,
includeAllParameters = includeAllParameters,
handleParameterNamesAsToBeExcluded = handleParameterNamesAsToBeExcluded,
- returnParametersAsCharacter = TRUE,
- tableColumnNames = tableColumnNames
+ returnParametersAsCharacter = TRUE
)
result <- as.matrix(dataFrame)
if (.isTrialDesignPlan(.self)) {
@@ -810,15 +804,17 @@ ParameterSet <- setRefClass("ParameterSet",
return(NULL)
},
- .getDataFrameColumnCaption = function(parameterName, tableColumnNames, niceColumnNamesEnabled) {
+ .getDataFrameColumnCaption = function(parameterName, niceColumnNamesEnabled) {
if (length(parameterName) == 0 || parameterName == "") {
stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT, "'parameterName' must be a valid parameter name")
}
+
+ if (!niceColumnNamesEnabled) {
+ return(parameterName)
+ }
- tableColumnName <- tableColumnNames[[parameterName]]
- return(ifelse(niceColumnNamesEnabled && !is.null(tableColumnName),
- tableColumnName, parameterName
- ))
+ tableColumnName <- .getParameterCaption(parameterName, .self, tableOutputEnabled = TRUE)
+ return(ifelse(!is.null(tableColumnName), tableColumnName, parameterName))
},
.getUnidimensionalNumberOfStages = function(parameterNames) {
kMax <- .self[["kMax"]]
@@ -843,7 +839,7 @@ ParameterSet <- setRefClass("ParameterSet",
parameterName, parameterValues, parameterCaption) {
tryCatch(
{
- formatFunctionName <- .parameterFormatFunctions[[parameterName]]
+ formatFunctionName <- .getParameterFormatFunction(parameterName, .self)
if (!is.null(formatFunctionName)) {
parameterValuesFormatted <- eval(call(formatFunctionName, parameterValues))
} else {
@@ -885,13 +881,17 @@ ParameterSet <- setRefClass("ParameterSet",
#
.getSubListByNames = function(x, listEntryNames) {
"Returns a sub-list."
- if (!is.list(x)) {
- stop(C_EXCEPTION_TYPE_RUNTIME_ISSUE, "'x' must be a list")
+ if (!is.list(x) && !inherits(x, "Dictionary")) {
+ stop(C_EXCEPTION_TYPE_RUNTIME_ISSUE, "'x' must be a list or Dictionary (is ", .getClassName(x), ")")
}
if (!is.character(listEntryNames)) {
stop(C_EXCEPTION_TYPE_RUNTIME_ISSUE, "'listEntryNames' must be a character vector")
}
+
+ if (inherits(x, "Dictionary")) {
+ return(getDictionarySubset(x, listEntryNames))
+ }
return(x[which(names(x) %in% listEntryNames)])
},
@@ -1100,15 +1100,11 @@ ParameterSet <- setRefClass("ParameterSet",
niceColumnNamesEnabled,
includeAllParameters,
returnParametersAsCharacter,
- tableColumnNames,
mandatoryParameterNames) {
numberOfVariants <- .getMultidimensionalNumberOfVariants(parameterSet, parameterNames)
numberOfStages <- parameterSet$.getMultidimensionalNumberOfStages(parameterNames)
- stagesCaption <- parameterSet$.getDataFrameColumnCaption(
- "stages",
- tableColumnNames, niceColumnNamesEnabled
- )
+ stagesCaption <- parameterSet$.getDataFrameColumnCaption("stages", niceColumnNamesEnabled)
dataFrame <- data.frame(
stages = sort(rep(1:numberOfStages, numberOfVariants))
@@ -1122,9 +1118,7 @@ ParameterSet <- setRefClass("ParameterSet",
}
dataFrame$populations <- rep(populations, numberOfStages)
populationsCaption <- parameterSet$.getDataFrameColumnCaption(
- "populations",
- tableColumnNames, niceColumnNamesEnabled
- )
+ "populations", niceColumnNamesEnabled)
names(dataFrame) <- c(stagesCaption, populationsCaption)
}
@@ -1133,9 +1127,7 @@ ParameterSet <- setRefClass("ParameterSet",
{
if (!is.null(variedParameter) && variedParameter != "stages") {
variedParameterCaption <- parameterSet$.getDataFrameColumnCaption(
- variedParameter,
- tableColumnNames, niceColumnNamesEnabled
- )
+ variedParameter, niceColumnNamesEnabled)
dataFrame[[variedParameterCaption]] <- rep(parameterSet[[variedParameter]], numberOfStages)
}
},
@@ -1161,9 +1153,7 @@ ParameterSet <- setRefClass("ParameterSet",
)
if (!is.null(columnValues)) {
columnCaption <- parameterSet$.getDataFrameColumnCaption(
- parameterName,
- tableColumnNames, niceColumnNamesEnabled
- )
+ parameterName, niceColumnNamesEnabled)
dataFrame[[columnCaption]] <- columnValues
if (returnParametersAsCharacter) {
parameterSet$.formatDataFrameParametersAsCharacter(
@@ -1213,9 +1203,7 @@ ParameterSet <- setRefClass("ParameterSet",
!is.matrix(value) && !is.array(value) && !is.data.frame(value) &&
(is.numeric(value) || is.character(value) || is.logical(value))) {
columnCaption <- parameterSet$.getDataFrameColumnCaption(
- extraParameter,
- tableColumnNames, niceColumnNamesEnabled
- )
+ extraParameter, niceColumnNamesEnabled)
if (length(value) == 1) {
dataFrame[[columnCaption]] <- rep(value, nrow(dataFrame))
@@ -1239,16 +1227,19 @@ ParameterSet <- setRefClass("ParameterSet",
}
.getAsDataFrameUnidimensional <- function(parameterSet, parameterNames, niceColumnNamesEnabled,
- includeAllParameters, returnParametersAsCharacter, tableColumnNames) {
+ includeAllParameters, returnParametersAsCharacter) {
numberOfStages <- parameterSet$.getUnidimensionalNumberOfStages(parameterNames)
dataFrame <- NULL
for (parameterName in parameterNames) {
tryCatch(
{
- parameterCaption <- ifelse(niceColumnNamesEnabled &&
- !is.null(tableColumnNames[[parameterName]]),
- tableColumnNames[[parameterName]], parameterName
- )
+ parameterCaption <- parameterName
+ if (niceColumnNamesEnabled) {
+ parameterCaption <- .getParameterCaption(parameterName, parameterSet, tableOutputEnabled = TRUE)
+ }
+ if (is.null(parameterCaption)) {
+ parameterCaption <- parameterName
+ }
parameterValues <- parameterSet[[parameterName]]
if (parameterName == "futilityBounds") {
parameterValues[parameterValues == C_FUTILITY_BOUNDS_DEFAULT] <- -Inf
@@ -1293,7 +1284,6 @@ ParameterSet <- setRefClass("ParameterSet",
includeAllParameters = FALSE,
handleParameterNamesAsToBeExcluded = FALSE,
returnParametersAsCharacter = FALSE,
- tableColumnNames = C_TABLE_COLUMN_NAMES,
mandatoryParameterNames = character(0)) {
parameterNamesToBeExcluded <- c()
if (handleParameterNamesAsToBeExcluded) {
@@ -1339,7 +1329,7 @@ ParameterSet <- setRefClass("ParameterSet",
(.isTrialDesignPlanCountData(parameterSet) && length(parameterSet$theta) > 1)) {
return(.addDelayedInformationRates(.getAsDataFrameMultidimensional(
parameterSet, parameterNames, niceColumnNamesEnabled,
- includeAllParameters, returnParametersAsCharacter, tableColumnNames,
+ includeAllParameters, returnParametersAsCharacter,
mandatoryParameterNames
)))
}
@@ -1358,7 +1348,7 @@ ParameterSet <- setRefClass("ParameterSet",
return(.addDelayedInformationRates(.getAsDataFrameUnidimensional(
parameterSet, parameterNames, niceColumnNamesEnabled,
- includeAllParameters, returnParametersAsCharacter, tableColumnNames
+ includeAllParameters, returnParametersAsCharacter
)))
}
diff --git a/R/class_core_plot_settings.R b/R/class_core_plot_settings.R
index d61a9d3b..267cf86d 100644
--- a/R/class_core_plot_settings.R
+++ b/R/class_core_plot_settings.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7526 $
-## | Last changed: $Date: 2023-12-21 13:38:20 +0100 (Do, 21 Dez 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -337,16 +337,6 @@ PlotSettings <- setRefClass("PlotSettings",
.scalingEnabled <<- TRUE
.pointScalingCorrectionEnabled <<- TRUE
.pointBorderEnabled <<- TRUE
-
- .parameterNames <<- list(
- "lineSize" = "Line size",
- "pointSize" = "Point size",
- "pointColor" = "Point color",
- "mainTitleFontSize" = "Main title font size",
- "axesTextFontSize" = "Axes text font size",
- "legendFontSize" = "Legend font size",
- "scalingFactor" = "Scaling factor"
- )
},
clone = function() {
return(PlotSettings(
diff --git a/R/class_design.R b/R/class_design.R
index 528329cd..71298817 100644
--- a/R/class_design.R
+++ b/R/class_design.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7126 $
-## | Last changed: $Date: 2023-06-23 14:26:39 +0200 (Fr, 23 Jun 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -101,25 +101,6 @@ TrialDesign <- setRefClass("TrialDesign",
.plotSettings <<- PlotSettings()
- if (inherits(.self, "TrialDesignConditionalDunnett")) {
- .parameterNames <<- C_PARAMETER_NAMES
- } else {
- .parameterNames <<- .getSubListByNames(.getParameterNames(design = .self), c(
- "stages",
- "kMax",
- "alpha",
- "informationRates",
- "userAlphaSpending",
- "criticalValues",
- "stageLevels",
- "alphaSpent",
- "bindingFutility",
- "tolerance"
- ))
- }
-
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
-
.initStages()
},
show = function(showType = 1, digits = NA_integer_) {
@@ -245,9 +226,6 @@ TrialDesignCharacteristics <- setRefClass("TrialDesignCharacteristics",
methods = list(
initialize = function(design, ...) {
callSuper(.design = design, ...)
- .parameterNames <<- .getParameterNames(design = design)
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
- .parameterFormatFunctions[["nFixed"]] <<- ".formatProbabilities"
.initStages()
},
show = function(showType = 1, digits = NA_integer_) {
@@ -353,8 +331,7 @@ as.data.frame.TrialDesignCharacteristics <- function(x, row.names = NULL,
parameterNames = parameterNamesToBeExcluded,
niceColumnNamesEnabled = niceColumnNamesEnabled,
includeAllParameters = includeAllParameters,
- handleParameterNamesAsToBeExcluded = TRUE,
- tableColumnNames = .getTableColumnNames(design = x$.design)
+ handleParameterNamesAsToBeExcluded = TRUE
))
}
@@ -435,21 +412,6 @@ TrialDesignFisher <- setRefClass(C_CLASS_NAME_TRIAL_DESIGN_FISHER,
tolerance = tolerance
)
- .parameterNames <<- c(.parameterNames, .getSubListByNames(
- .getParameterNames(design = .self), c(
- "method",
- "alpha0Vec",
- "scale",
- "nonStochasticCurtailment",
- "sided",
- "simAlpha",
- "iterations",
- "seed"
- )
- ))
-
- .parameterFormatFunctions$criticalValues <<- ".formatCriticalValuesFisher"
-
.initParameterTypes()
.setParameterType("iterations", C_PARAM_NOT_APPLICABLE)
.setParameterType("seed", C_PARAM_NOT_APPLICABLE)
@@ -637,8 +599,6 @@ TrialDesignInverseNormal <- setRefClass(C_CLASS_NAME_TRIAL_DESIGN_INVERSE_NORMAL
delayedInformation = delayedInformation
)
- .initParameterNames()
- .parameterFormatFunctions$criticalValues <<- ".formatCriticalValues"
.initParameterTypes()
.initStages()
@@ -647,32 +607,6 @@ TrialDesignInverseNormal <- setRefClass(C_CLASS_NAME_TRIAL_DESIGN_INVERSE_NORMAL
.setParameterType("decisionCriticalValues", C_PARAM_NOT_APPLICABLE)
.setParameterType("reversalProbabilities", C_PARAM_NOT_APPLICABLE)
},
- .initParameterNames = function() {
- .parameterNames <<- c(.parameterNames, .getSubListByNames(
- .getParameterNames(design = .self), c(
- "beta",
- "betaSpent",
- "sided",
- "futilityBounds",
- "typeOfDesign",
- "deltaWT",
- "deltaPT1",
- "deltaPT0",
- "optimizationCriterion",
- "gammaA",
- "gammaB",
- "typeBetaSpending",
- "userBetaSpending",
- "power",
- "twoSidedPower",
- "constantBoundsHP",
- "betaAdjustment",
- "delayedInformation",
- "decisionCriticalValues",
- "reversalProbabilities"
- )
- ))
- },
.formatComparisonResult = function(x) {
if (is.null(x) || length(x) == 0 || !is.numeric(x)) {
return(x)
@@ -903,7 +837,6 @@ TrialDesignGroupSequential <- setRefClass(
methods = list(
initialize = function(...) {
callSuper(...)
- .parameterFormatFunctions$criticalValues <<- ".formatCriticalValues"
.initStages()
},
show = function(showType = 1, digits = NA_integer_) {
@@ -1251,7 +1184,6 @@ as.data.frame.TrialDesign <- function(x, row.names = NULL,
parameterSet = x,
parameterNames = parameterNames,
niceColumnNamesEnabled = niceColumnNamesEnabled,
- includeAllParameters = includeAllParameters,
- tableColumnNames = .getTableColumnNames(design = x)
+ includeAllParameters = includeAllParameters
))
}
diff --git a/R/class_design_plan.R b/R/class_design_plan.R
index d4196334..9b840f81 100644
--- a/R/class_design_plan.R
+++ b/R/class_design_plan.R
@@ -13,9 +13,9 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7592 $
-## | Last changed: $Date: 2024-01-24 10:48:09 +0100 (Mi, 24 Jan 2024) $
-## | Last changed by: $Author: wassmer $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
+## | Last changed by: $Author: pahlke $
## |
#' @include f_core_constants.R
@@ -112,8 +112,6 @@ TrialDesignPlan <- setRefClass("TrialDesignPlan",
callSuper(.design = design, ...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- .getParameterNames(design = design, designPlan = .self)
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
if (.isTrialDesignPlanMeans(.self)) {
defaultValueList <- C_TRIAL_DESIGN_PLAN_DEFAULT_VALUES_MEANS
@@ -1066,7 +1064,6 @@ TrialDesignPlanCountData <- setRefClass("TrialDesignPlanCountData",
groups <<- 2L
optimumAllocationRatio <<- FALSE
- .parameterFormatFunctions$maxInformation <<- ".formatRatesDynamic"
.self$.setParameterType("groups", C_PARAM_NOT_APPLICABLE)
.self$.setParameterType("directionUpper", C_PARAM_NOT_APPLICABLE)
.self$.setParameterType("optimumAllocationRatio", C_PARAM_NOT_APPLICABLE)
diff --git a/R/class_design_power_and_asn.R b/R/class_design_power_and_asn.R
index 4c706d2b..14bf9b01 100644
--- a/R/class_design_power_and_asn.R
+++ b/R/class_design_power_and_asn.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7126 $
-## | Last changed: $Date: 2023-06-23 14:26:39 +0200 (Fr, 23 Jun 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -70,8 +70,6 @@ PowerAndAverageSampleNumberResult <- setRefClass("PowerAndAverageSampleNumberRes
callSuper(.design = design, theta = theta, nMax = nMax, ...)
theta <<- .assertIsValidThetaRange(thetaRange = theta, thetaAutoSeqEnabled = FALSE)
.initPowerAndAverageSampleNumber()
- .parameterNames <<- .getParameterNames(design = design)
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
},
clone = function() {
return(PowerAndAverageSampleNumberResult(design = .self$.design, theta = .self$theta, nMax = .self$nMax))
@@ -322,8 +320,7 @@ as.data.frame.PowerAndAverageSampleNumberResult <- function(x, row.names = NULL,
parameterSet = x,
parameterNames = parameterNames,
niceColumnNamesEnabled = niceColumnNamesEnabled,
- includeAllParameters = includeAllParameters,
- tableColumnNames = .getTableColumnNames(design = x$.design)
+ includeAllParameters = includeAllParameters
)
return(dataFrame)
}
diff --git a/R/class_design_set.R b/R/class_design_set.R
index 9df1ab66..c72b17da 100644
--- a/R/class_design_set.R
+++ b/R/class_design_set.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7558 $
-## | Last changed: $Date: 2024-01-12 15:29:16 +0100 (Fri, 12 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -767,7 +767,7 @@ as.data.frame.TrialDesignSet <- function(x,
if (.isTrialDesignWithValidFutilityBounds(design)) {
futilityBoundsName <- "futilityBounds"
if (niceColumnNamesEnabled) {
- futilityBoundsName <- .getTableColumnNames(design = design)[["futilityBounds"]]
+ futilityBoundsName <- .getParameterCaption("futilityBounds", design, tableOutputEnabled = TRUE)
}
kMax <- design$kMax
@@ -776,7 +776,7 @@ as.data.frame.TrialDesignSet <- function(x,
if (.isTrialDesignWithValidAlpha0Vec(design)) {
alpha0VecName <- "alpha0Vec"
if (niceColumnNamesEnabled) {
- alpha0VecName <- .getTableColumnNames(design = design)[["alpha0Vec"]]
+ alpha0VecName <- .getParameterCaption("alpha0Vec", design, tableOutputEnabled = TRUE)
}
kMax <- design$kMax
diff --git a/R/class_dictionary.R b/R/class_dictionary.R
new file mode 100644
index 00000000..f9ec1f50
--- /dev/null
+++ b/R/class_dictionary.R
@@ -0,0 +1,169 @@
+## |
+## | *Dictionary class*
+## |
+## | This file is part of the R package rpact:
+## | Confirmatory Adaptive Clinical Trial Design and Analysis
+## |
+## | Author: Gernot Wassmer, PhD, and Friedrich Pahlke, PhD
+## | Licensed under "GNU Lesser General Public License" version 3
+## | License text can be found here: https://www.r-project.org/Licenses/LGPL-3
+## |
+## | RPACT company website: https://www.rpact.com
+## | rpact package website: https://www.rpact.org
+## |
+## | Contact us for information about our services: info@rpact.com
+## |
+## | File version: $Revision: 7476 $
+## | Last changed: $Date: 2023-12-07 11:57:03 +0100 (Do, 07 Dez 2023) $
+## | Last changed by: $Author: pahlke $
+## |
+
+createDictionary <- function(name, keyValuePairList = NULL) {
+ result <- new.env(parent = emptyenv())
+ class(result) <- "Dictionary"
+ attr(result, "name") <- name
+ if (!is.null(keyValuePairList)) {
+ initDictionary(result, keyValuePairList)
+ }
+ return(result)
+}
+
+.assertIsDictionary <- function(x) {
+ if (is.null(x)) {
+ stop(
+ C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
+ "'x' must be a valid 'Dictionary' (is NULL)"
+ )
+ }
+ if (!inherits(x, "Dictionary")) {
+ stop(
+ C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
+ "'x' must be an instance of class 'Dictionary' (is ", .getClassName(x), ")"
+ )
+ }
+}
+
+#'
+#' @examples
+#' x <- createDictionary("x", list(a = 1, b = 2, c = 3))
+#' getDictionaryKeyByValue(x, 2)
+#'
+#' @noRd
+#'
+getDictionaryKeyByValue <- function(x, value) {
+ .assertIsDictionary(x)
+ keys <- names(x)
+ values <- as.vector(x)
+ return(unique(keys[values == value]))
+}
+
+#'
+#' @examples
+#' x <- createDictionary("x", list(a = 1, b = 2, c = 3))
+#' getDictionarySubset(x, c("b", "c"))
+#'
+#' @noRd
+#'
+getDictionarySubset <- function(x, subsetNames) {
+ .assertIsDictionary(x)
+ result <- createDictionary(attr(x, "name"))
+ for (objName in base::ls(envir = x)) {
+ if (objName %in% subsetNames) {
+ base::assign(objName, x[[objName]], envir = result)
+ }
+ }
+ return(result)
+}
+
+cloneDictionary <- function(x) {
+ .assertIsDictionary(x)
+ result <- createDictionary(attr(x, "name"))
+ for (objName in base::ls(envir = x)) {
+ base::assign(objName, x[[objName]], envir = result)
+ }
+ return(result)
+}
+
+#'
+#' @export
+#' @noRd
+#'
+as.vector.Dictionary <- function(x, ...) {
+ .assertIsDictionary(x)
+ vec <- character()
+ for (key in names(x)) {
+ vec <- c(vec, base::get(key, envir = x))
+ }
+ return(vec)
+}
+
+#'
+#' @export
+#' @noRd
+#'
+as.list.Dictionary <- function(x, ...) {
+ .assertIsDictionary(x)
+ result <- list()
+ for (key in names(x)) {
+ result[[key]] <- base::get(key, envir = x)
+ }
+ return(result)
+}
+
+#'
+#' @export
+#' @noRd
+#'
+print.Dictionary <- function(x, ...) {
+ .assertIsDictionary(x)
+ cat(attr(x, "name"), "\n")
+ for (key in names(x)) {
+ cat("$", key, "\n", sep = "")
+ print(base::get(key, envir = x))
+ cat("\n")
+ }
+}
+
+initDictionary <- function(x, keyValuePairList) {
+ .assertIsDictionary(x)
+ if (is.null(keyValuePairList) || length(keyValuePairList) == 0 || !is.list(keyValuePairList)) {
+ stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT, "'keyValuePairList' must be a valid list")
+ }
+
+ if (any(names(keyValuePairList) == "")) {
+ stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT, "'keyValuePairList' must be a named list")
+ }
+
+ for (key in names(keyValuePairList)) {
+ value <- keyValuePairList[[key]]
+ addValueToDictionary(x, key, value)
+ }
+}
+
+addValueToDictionary <- function(x, key, value) {
+ .assertIsDictionary(x)
+ if (base::exists(key, envir = x)) {
+ stop(
+ C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
+ "dictionary ", attr(x, "name"), " already contains key ", sQuote(key)
+ )
+ }
+ setValueToDictionary(x, key, value)
+}
+
+setValueToDictionary <- function(x, key, value) {
+ .assertIsDictionary(x)
+ base::assign(key, value, envir = x)
+}
+
+getValueFromDictionary <- function(x, key) {
+ .assertIsDictionary(x)
+ if (!base::exists(key, envir = x)) {
+ stop(
+ C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
+ "dictionary ", attr(x, "name"), " does not contain key ", sQuote(key)
+ )
+ }
+
+ return(base::get(key, envir = x))
+}
diff --git a/R/class_event_probabilities.R b/R/class_event_probabilities.R
index 9081aad3..63405415 100644
--- a/R/class_event_probabilities.R
+++ b/R/class_event_probabilities.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7126 $
-## | Last changed: $Date: 2023-06-23 14:26:39 +0200 (Fr, 23 Jun 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -84,8 +84,6 @@ EventProbabilities <- setRefClass("EventProbabilities",
initialize = function(...) {
callSuper(...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- C_PARAMETER_NAMES
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
.setParameterType("overallEventProbabilities", C_PARAM_NOT_APPLICABLE) # deprecated
},
getPlotSettings = function() {
@@ -167,8 +165,6 @@ NumberOfSubjects <- setRefClass("NumberOfSubjects",
initialize = function(...) {
callSuper(...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- C_PARAMETER_NAMES
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
},
getPlotSettings = function() {
return(.plotSettings)
diff --git a/R/class_performance_score.R b/R/class_performance_score.R
index be5fb4a6..3a906245 100644
--- a/R/class_performance_score.R
+++ b/R/class_performance_score.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7148 $
-## | Last changed: $Date: 2023-07-03 15:50:22 +0200 (Mo, 03 Jul 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -60,8 +60,6 @@ PerformanceScore <- setRefClass("PerformanceScore",
callSuper(.simulationResults = simulationResults, ...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- C_PARAMETER_NAMES
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
},
.show = function(showType = 1, digits = NA_integer_, consoleOutputEnabled = TRUE) {
"Method for automatically printing performance score objects"
diff --git a/R/class_simulation_results.R b/R/class_simulation_results.R
index 32c54105..aad0a2dc 100644
--- a/R/class_simulation_results.R
+++ b/R/class_simulation_results.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7509 $
-## | Last changed: $Date: 2023-12-20 16:06:21 +0100 (Mi, 20 Dez 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -107,8 +107,6 @@ SimulationResults <- setRefClass("SimulationResults",
callSuper(.design = design, .showStatistics = showStatistics, ...)
.plotSettings <<- PlotSettings()
- .parameterNames <<- .getParameterNames(design = design, designPlan = .self)
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
},
getPlotSettings = function() {
return(.plotSettings)
@@ -260,7 +258,7 @@ SimulationResults <- setRefClass("SimulationResults",
parameterValues2 <- .getVariedParameterValues(variedParameterName2)
for (parameterName in params) {
- paramCaption <- .parameterNames[[parameterName]]
+ paramCaption <- .getParameterCaption(parameterName, .self)
if (is.null(paramCaption)) {
paramCaption <- paste0("%", parameterName, "%")
}
@@ -293,7 +291,7 @@ SimulationResults <- setRefClass("SimulationResults",
}
if (parameterName == "subjectsActiveArm" && variedParameterName2 == "armNumber") {
parameterName2 <- "subjectsControlArm"
- paramCaption2 <- .parameterNames[[parameterName2]]
+ paramCaption2 <- .getParameterCaption(parameterName2, .self)
if (is.null(paramCaption2)) {
paramCaption2 <- paste0("%", parameterName2, "%")
}
diff --git a/R/class_summary.R b/R/class_summary.R
index 49971cdb..45b71c02 100644
--- a/R/class_summary.R
+++ b/R/class_summary.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7595 $
-## | Last changed: $Date: 2024-01-25 13:19:41 +0100 (Do, 25 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -546,7 +546,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
if (variedParameterName == "piTreatments") {
variedParameterCaption <- "pi(treatment)"
} else {
- variedParameterCaption <- C_PARAMETER_NAMES[[variedParameterName]]
+ variedParameterCaption <- .getParameterCaption(variedParameterName)
if (is.matrix(variedParameterValues) && ncol(variedParameterValues) == 1) {
variedParameterCaption <- sub("s$", "", variedParameterCaption)
}
@@ -559,7 +559,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
} else {
variedParameterName <- .getVariedParameterSimulationMultiArm(parameterSet)
variedParameterValues <- parameterSet[[variedParameterName]]
- variedParameterCaption <- C_PARAMETER_NAMES[[variedParameterName]]
+ variedParameterCaption <- .getParameterCaption(variedParameterName)
numberOfVariants <- length(variedParameterValues)
}
variedParameterCaption <- tolower(variedParameterCaption)
@@ -634,9 +634,8 @@ SummaryFactory <- setRefClass("SummaryFactory",
return(invisible())
}
- variedParameterCaption <- parameterSet$.getDataFrameColumnCaption(variedParameter,
- tableColumnNames = C_TABLE_COLUMN_NAMES, niceColumnNamesEnabled = TRUE
- )
+ variedParameterCaption <- parameterSet$.getDataFrameColumnCaption(
+ variedParameter, niceColumnNamesEnabled = TRUE)
variedParameterCaption <- tolower(variedParameterCaption)
if (variedParameterCaption == "alternative" || variedParameterCaption == ".alternative") {
@@ -887,12 +886,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
if (inherits(fieldSet, "Dataset") &&
grepl("samplesize|event", tolower(parameterName))) {
} else {
- if (inherits(fieldSet, "FieldSet")) {
- formatFunctionName <- fieldSet$.parameterFormatFunctions[[parameterName]]
- }
- if (is.null(formatFunctionName)) {
- formatFunctionName <- C_PARAMETER_FORMAT_FUNCTIONS[[parameterName]]
- }
+ formatFunctionName <- .getParameterFormatFunction(parameterName, fieldSet)
}
}
}
@@ -3170,7 +3164,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
parameterName <- "singleNumberOfEventsPerStage"
parameterCaption <- "Single number of events"
} else {
- parameterName <- "eventsPerStage"
+ parameterName <- "eventsPerStage"
parameterCaption <- "Cumulative number of events"
}
} else {
@@ -3251,7 +3245,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
if (inherits(designPlan, "SimulationResults")) {
parameterNameSubjects <- ifelse(survivalEnabled, "numberOfSubjects", "sampleSizes")
- parameterNameEvents <- "eventsPerStage"
+ parameterNameEvents <- "overallEventsPerStage"
} else {
if (design$kMax == 1 && (
designPlan$.isSampleSizeObject() ||
@@ -3641,7 +3635,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
if (variedParameterName == "piTreatments") {
variedParameterCaption <- "pi(treatment)"
} else {
- variedParameterCaption <- C_PARAMETER_NAMES[[variedParameterName]]
+ variedParameterCaption <- .getParameterCaption(variedParameterName)
}
if (is.matrix(variedParameterValues) && ncol(variedParameterValues) == 1) {
variedParameterCaption <- sub("s$", "", variedParameterCaption)
@@ -3649,7 +3643,7 @@ SummaryFactory <- setRefClass("SummaryFactory",
} else {
variedParameterName <- .getVariedParameterSimulationMultiArm(designPlan)
variedParameterValues <- designPlan[[variedParameterName]]
- variedParameterCaption <- C_PARAMETER_NAMES[[variedParameterName]]
+ variedParameterCaption <- .getParameterCaption(variedParameterName)
}
userDefinedEffectMatrix <- !enrichmentEnabled &&
diff --git a/R/class_time.R b/R/class_time.R
index 46b33854..342e4353 100644
--- a/R/class_time.R
+++ b/R/class_time.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7476 $
-## | Last changed: $Date: 2023-12-07 11:57:03 +0100 (Do, 07 Dez 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -31,8 +31,6 @@ TimeDefinition <- setRefClass("TimeDefinition",
methods = list(
initialize = function(...) {
callSuper(...)
- .parameterNames <<- C_PARAMETER_NAMES
- .parameterFormatFunctions <<- C_PARAMETER_FORMAT_FUNCTIONS
},
.getRegexpFromTo = function(..., from, to, fromPrefix = "", toPrefix = "") {
return(paste0("(^ *", fromPrefix, from, " *- *", toPrefix, to, " *$)"))
@@ -636,9 +634,9 @@ PiecewiseSurvivalTime <- setRefClass("PiecewiseSurvivalTime",
rownames(data) <- as.character(1:nrow(data))
colnames(data) <- c(
"Start time",
- C_PARAMETER_NAMES["lambda1"], # Hazard rate (1)
- C_PARAMETER_NAMES["lambda2"]
- ) # Hazard rate (2)
+ .getParameterCaption("lambda1", tableOutputEnabled = TRUE),
+ .getParameterCaption("lambda2", tableOutputEnabled = TRUE)
+ )
return(data)
},
.isPiBased = function() {
@@ -1434,7 +1432,7 @@ AccrualTime <- setRefClass("AccrualTime",
rownames(data) <- as.character(1:nrow(data))
colnames(data) <- c(
"Start time",
- C_PARAMETER_NAMES["accrualIntensity"]
+ .getParameterCaption("accrualIntensity", .self)
)
return(data)
},
diff --git a/R/f_core_constants.R b/R/f_core_constants.R
index 4f05b9ea..1770b89b 100644
--- a/R/f_core_constants.R
+++ b/R/f_core_constants.R
@@ -13,11 +13,12 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7590 $
-## | Last changed: $Date: 2024-01-23 11:32:01 +0100 (Di, 23 Jan 2024) $
-## | Last changed by: $Author: wassmer $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
+## | Last changed by: $Author: pahlke $
## |
+#' @include class_dictionary.R
#' @include f_core_utilities.R
NULL
@@ -221,7 +222,7 @@ C_TYPE_OF_DESIGN_AS_USER <- "asUser" # user defined alpha spending
C_TYPE_OF_DESIGN_NO_EARLY_EFFICACY <- "noEarlyEfficacy" # no early efficacy stop
C_DEFAULT_TYPE_OF_DESIGN <- C_TYPE_OF_DESIGN_OF # the default type of design
-C_TYPE_OF_DESIGN_LIST <- list(
+C_TYPE_OF_DESIGN_LIST <- createDictionary("C_TYPE_OF_DESIGN_LIST", list(
"OF" = "O'Brien & Fleming",
"P" = "Pocock",
"WT" = "Wang & Tsiatis Delta class",
@@ -234,7 +235,7 @@ C_TYPE_OF_DESIGN_LIST <- list(
"asHSD" = "Hwang, Shi & DeCani alpha spending",
"asUser" = "User defined alpha spending",
"noEarlyEfficacy" = "No early efficacy stop"
-)
+))
C_PLOT_SHOW_SOURCE_ARGUMENTS <- c("commands", "axes", "test", "validate")
@@ -289,14 +290,14 @@ C_TYPE_OF_DESIGN_BS_KD <- "bsKD" # Kim & DeMets beta spending
C_TYPE_OF_DESIGN_BS_HSD <- "bsHSD" # Hwang, Shi & DeCani beta spending
C_TYPE_OF_DESIGN_BS_USER <- "bsUser" # user defined beta spending
-C_TYPE_OF_DESIGN_BS_LIST <- list(
+C_TYPE_OF_DESIGN_BS_LIST <- createDictionary("C_TYPE_OF_DESIGN_BS_LIST", list(
"none" = "none",
"bsP" = "Pocock type beta spending",
"bsOF" = "O'Brien & Fleming type beta spending",
"bsKD" = "Kim & DeMets beta spending",
"bsHSD" = "Hwang, Shi & DeCani beta spending",
"bsUser" = "user defined beta spending"
-)
+))
C_CIPHERS <- list(token = "310818669631424001", secret = "9318655074497250732")
@@ -389,7 +390,7 @@ C_FISHER_METHOD_DEFAULT <- C_FISHER_METHOD_EQUAL_ALPHA
## -------------------------------------------
##
-C_PARAMETER_NAMES <- list(
+C_PARAMETER_NAMES <- createDictionary("C_PARAMETER_NAMES", list(
iterations = "Iterations",
seed = "Seed",
groups = "Treatment groups",
@@ -398,6 +399,8 @@ C_PARAMETER_NAMES <- list(
means = "Means",
stDevs = "Standard deviations",
overallEvents = "Cumulative events",
+ overallEvents1 = "Cumulative events (1)",
+ overallEvents2 = "Cumulative events (2)",
overallAllocationRatios = "Cumulative allocation ratios",
expectedEvents = "Expected events",
varianceEvents = "Variance of events",
@@ -500,16 +503,11 @@ C_PARAMETER_NAMES <- list(
overallStDevs1 = "Cumulative standard deviations (1)",
overallStDevs2 = "Cumulative standard deviations (2)",
overallStDevs = "Cumulative (pooled) standard deviations",
- testStatistics = "Stage-wise test statistics",
combInverseNormal = "Combination test statistics", # Inverse normal combination
combFisher = "Combination test statistics", # Fisher combination
weightsFisher = "Fixed weights",
weightsInverseNormal = "Fixed weights",
overallLogRanks = "Cumulative log-ranks",
- overallEvents = "Cumulative number of events",
- overallEvents1 = "Cumulative number of events (1)",
- overallEvents2 = "Cumulative number of events (2)",
- overallAllocationRatios = "Cumulative allocation ratios",
events = "Number of events",
allocationRatios = "Allocation ratios",
logRanks = "Log-ranks",
@@ -556,9 +554,7 @@ C_PARAMETER_NAMES <- list(
expectedEventsH0 = "Expected number of events under H0",
expectedEventsH01 = "Expected number of events under H0/H1",
expectedEventsH1 = "Expected number of events under H1",
- analysisTime = "Analysis times",
studyDurationH1 = "Expected study duration under H1",
- expectedNumberOfSubjectsH1 = "Expected number of subjects under H1",
twoSidedPower = "Two-sided power",
plannedEvents = "Planned cumulative events",
plannedSubjects = "Planned cumulative subjects", # per arm (multi-arm); overall (base)
@@ -571,11 +567,7 @@ C_PARAMETER_NAMES <- list(
maxNumberOfIterations = "Maximum number of iterations",
allocation1 = "Allocation 1",
allocation2 = "Allocation 2",
- expectedNumberOfEvents = "Expected number of events",
- expectedNumberOfEventsPerStage = "Expected number of events by stage",
- eventsNotAchieved = "Events not achieved",
subjects = "Subjects",
- overallReject = "Overall reject",
futilityStop = "Overall futility stop",
studyDuration = "Expected study duration",
maxStudyDuration = "Maximal study duration",
@@ -611,9 +603,10 @@ C_PARAMETER_NAMES <- list(
median1 = "median(1)",
median2 = "median(2)",
eventsPerStage = "Number of events per stage",
+ expectedNumberOfEventsPerStage = "Expected number of events by stage",
+ eventsNotAchieved = "Events not achieved",
overallEventsPerStage = "Cumulative number of events",
- expectedNumberOfEvents = "Observed number of events",
- expectedNumberOfSubjects = "Observed number of subjects",
+ expectedNumberOfEvents = "Expected number of events",
singleNumberOfEventsPerStage = "Single number of events",
endOfAccrualIsUserDefined = "End of accrual is user defined",
followUpTimeMustBeUserDefined = "Follow-up time must be user defined",
@@ -695,7 +688,6 @@ C_PARAMETER_NAMES <- list(
variationConditionalPower = "Variation conditional power",
subscoreConditionalPower = "Sub-score conditional power",
performanceScore = "Performance scores",
-
overdispersion = "Overdispersion",
lambda = "Lambda",
fixedExposureTime = "Fixed exposure time",
@@ -704,15 +696,14 @@ C_PARAMETER_NAMES <- list(
studySubjects = "Study subjects",
expectedStudyDurationH1 = "Expected study duration under H1",
informationOverStages = "Information over stages",
- maxInformation = "Maximum information",
expectedInformationH0 = "Expected information under H0",
expectedInformationH01 = "Expected information under H0/H1",
expectedInformationH1 = "Expected information under H1",
plannedMaxSubjects = "Planned maximum number of subjects",
plannedCalendarTime = "Planned calendar time"
-)
+))
-C_TABLE_COLUMN_NAMES <- list(
+C_TABLE_COLUMN_NAMES <- createDictionary("C_TABLE_COLUMN_NAMES", list(
iterations = "Iterations",
seed = "Seed",
groups = "Treatment group",
@@ -721,6 +712,8 @@ C_TABLE_COLUMN_NAMES <- list(
means = "Mean",
stDevs = "Standard deviation",
overallEvents = "Cumulative event",
+ overallEvents1 = "Cumulative events (1)",
+ overallEvents2 = "Cumulative events (2)",
overallAllocationRatios = "Cumulative allocation ratio",
overallMeans = "Cumulative mean",
expectedEvents = "Expected event",
@@ -796,9 +789,7 @@ C_TABLE_COLUMN_NAMES <- list(
overallPiTreatments = "Cumulative treatment rate",
overallPisControl = "Cumulative control rate",
overallPisTreatment = "Cumulative treatment rate",
- stages = "Stage",
effectSizes = "Overall effect size",
- testStatistics = "Stage-wise test statistic",
pValues = "p-value",
testActions = "Action",
conditionalPower = "Conditional power",
@@ -828,10 +819,6 @@ C_TABLE_COLUMN_NAMES <- list(
weightsFisher = "Fixed weight",
weightsInverseNormal = "Fixed weight",
overallLogRanks = "Cumulative log-rank",
- overallEvents = "Cumulative # events",
- overallEvents1 = "Cumulative # events (1)",
- overallEvents2 = "Cumulative # events (2)",
- overallAllocationRatios = "Cumulative allocation ratio",
events = "# events",
allocationRatios = "Allocation ratio",
logRanks = "Log-rank",
@@ -860,7 +847,6 @@ C_TABLE_COLUMN_NAMES <- list(
expectedNumberOfSubjectsH0 = "Expected # subjects under H0",
expectedNumberOfSubjectsH01 = "Expected # subjects under H0/H1",
expectedNumberOfSubjectsH1 = "Expected # subjects under H1",
- expectedNumberOfSubjects = "Expected # subjects",
chi = "Probability of an event",
hazardRatio = "Hazard ratio",
hazardRatios = "Hazard ratios",
@@ -882,7 +868,6 @@ C_TABLE_COLUMN_NAMES <- list(
eventsPerStage1 = "Observed # events by stage (1)",
eventsPerStage2 = "Observed # events by stage (2)",
studyDurationH1 = "Expected study duration H1",
- expectedNumberOfSubjectsH1 = "Expected # subjects H1",
twoSidedPower = "Two-sided power",
plannedEvents = "Planned cumulative events",
plannedSubjects = "Planned cumulative subjects",
@@ -895,7 +880,6 @@ C_TABLE_COLUMN_NAMES <- list(
maxNumberOfIterations = "Maximum # iterations",
allocation1 = "Allocation 1",
allocation2 = "Allocation 2",
- expectedNumberOfEvents = "Expected # events",
expectedNumberOfEventsPerStage = "Expected # events by stage",
eventsNotAchieved = "Events not achieved",
subjects = "Subjects",
@@ -927,12 +911,11 @@ C_TABLE_COLUMN_NAMES <- list(
piecewiseSurvivalEnabled = "Piecewise exponential survival enabled",
median1 = "median(1)",
median2 = "median(2)",
- eventsPerStage = "Cumulative # events",
- eventsPerStage = "# events per stage",
- overallEventsPerStage = "Cumulative # events",
- expectedNumberOfEvents = "Observed # events",
- expectedNumberOfSubjects = "Observed # subjects",
- singleNumberOfEventsPerStage = "Single # events",
+ eventsPerStage = "Events per stage",
+ overallEventsPerStage = "Cumulative events",
+ expectedNumberOfEvents = "Expected events",
+ expectedNumberOfSubjects = "Expected subjects",
+ singleNumberOfEventsPerStage = "Single events",
endOfAccrualIsUserDefined = "End of accrual is user defined",
followUpTimeMustBeUserDefined = "Follow-up time must be user defined",
maxNumberOfSubjectsIsUserDefined = "Max number of subjects is user defined",
@@ -1009,7 +992,6 @@ C_TABLE_COLUMN_NAMES <- list(
variationConditionalPower = "Variation conditional power",
subscoreConditionalPower = "Sub-score conditional power",
performanceScore = "Performance score",
-
overdispersion = "Overdispersion",
lambda = "Lambda",
fixedExposureTime = "Fixed exposure time",
@@ -1018,145 +1000,183 @@ C_TABLE_COLUMN_NAMES <- list(
studySubjects = "Study subjects",
expectedStudyDurationH1 = "Expected study duration under H1",
informationOverStages = "Information over stages",
- maxInformation = "Maximum information",
expectedInformationH0 = "Expected information under H0",
expectedInformationH01 = "Expected information under H0/H1",
expectedInformationH1 = "Expected information under H1",
plannedMaxSubjects = "Planned max. number of subjects",
plannedCalendarTime = "Planned calendar time"
-)
+))
+
+C_PARAMETER_NAMES_PLOT_SETTINGS <- createDictionary("C_PARAMETER_NAMES_PLOT_SETTINGS", list(
+ "lineSize" = "Line size",
+ "pointSize" = "Point size",
+ "pointColor" = "Point color",
+ "mainTitleFontSize" = "Main title font size",
+ "axesTextFontSize" = "Axes text font size",
+ "legendFontSize" = "Legend font size",
+ "scalingFactor" = "Scaling factor"
+))
+
+.getParameterCaption <- function(parameterName, obj = NULL, ..., tableOutputEnabled = FALSE) {
+ if (is.null(obj)) {
+ if (tableOutputEnabled) {
+ return(C_TABLE_COLUMN_NAMES[[parameterName]])
+ }
-.getParameterCaptions <- function(captionList, ...,
- design = NULL,
- designPlan = NULL,
- stageResults = NULL,
- analysisResults = NULL,
- dataset = NULL,
- designCharacteristics = NULL,
- designSet = NULL,
- tableColumns = FALSE) {
- parameterNames <- captionList
-
- if (!is.null(design)) {
- parameterNameFutilityBounds <- "futilityBounds"
- if (.isDelayedInformationEnabled(design = design)) {
- if (!is.na(design$bindingFutility) && !design$bindingFutility) {
- parameterNameFutilityBounds <- "futilityBoundsDelayedInformationNonBinding"
- } else {
- parameterNameFutilityBounds <- "futilityBoundsDelayedInformation"
+ return(C_PARAMETER_NAMES[[parameterName]])
+ }
+
+ if (inherits(obj, "PlotSettings")) {
+ return(C_PARAMETER_NAMES_PLOT_SETTINGS[[parameterName]])
+ }
+
+ if (inherits(obj, "TrialDesign")) {
+ if (identical(parameterName, "futilityBounds")) {
+ if (.isDelayedInformationEnabled(design = obj)) {
+ if (!is.na(obj$bindingFutility) && !obj$bindingFutility) {
+ return("futilityBoundsDelayedInformationNonBinding")
+ }
+ return("futilityBoundsDelayedInformation")
+ } else if (!is.na(obj$bindingFutility) && !obj$bindingFutility) {
+ return("futilityBoundsNonBinding")
}
- parameterNames$criticalValues <- captionList[["criticalValuesDelayedInformation"]]
+ }
+ if (identical(parameterName, "criticalValues") && .isDelayedInformationEnabled(design = obj)) {
+ return("criticalValuesDelayedInformation")
+ }
+ if (identical(parameterName, "criticalValuesEffectScale") && .isDelayedInformationEnabled(design = obj)) {
+ return("criticalValuesEffectScaleDelayedInformation")
+ }
+ if (identical(parameterName, "futilityBoundsEffectScale") && .isDelayedInformationEnabled(design = obj)) {
+ return("futilityBoundsEffectScaleDelayedInformation")
+ }
+ if (identical(parameterName, "futilityBoundsPValueScale") && .isDelayedInformationEnabled(design = obj)) {
+ return("futilityBoundsPValueScaleDelayedInformation")
+ }
+ }
- parameterNames$criticalValuesEffectScale <- captionList[["criticalValuesEffectScaleDelayedInformation"]]
- parameterNames$futilityBoundsEffectScale <- captionList[["futilityBoundsEffectScaleDelayedInformation"]]
- parameterNames$futilityBoundsPValueScale <- captionList[["futilityBoundsPValueScaleDelayedInformation"]]
- } else if (!is.na(design$bindingFutility) && !design$bindingFutility) {
- parameterNameFutilityBounds <- "futilityBoundsNonBinding"
+ if (identical(parameterName, "futilityBounds") &&
+ inherits(obj, "TrialDesignSet") && length(obj$designs) > 1) {
+ bindingFutilityValues <- logical(0)
+ for (design in obj$designs) {
+ bindingFutilityValues <- unique(c(bindingFutilityValues, design$bindingFutility))
}
- parameterNames$futilityBounds <- captionList[[parameterNameFutilityBounds]]
- if (!is.null(designSet) && length(designSet$designs) > 1) {
- bindingFutilityValues <- logical(0)
- for (design in designSet$designs) {
- bindingFutilityValues <- unique(c(bindingFutilityValues, design$bindingFutility))
- }
- if (length(bindingFutilityValues) > 1) {
- parameterNames$futilityBounds <- "Futility bound"
- }
+ if (length(bindingFutilityValues) > 1) {
+ return("Futility bound")
}
}
- if (!is.null(designPlan) && inherits(designPlan, "TrialDesignPlanSurvival") &&
- !is.null(designPlan$.piecewiseSurvivalTime) &&
- designPlan$.piecewiseSurvivalTime$piecewiseSurvivalEnabled) {
- parameterNames$lambda2 <- "Piecewise survival lambda (2)"
- parameterNames$lambda1 <- "Piecewise survival lambda (1)"
+ if (identical(parameterName, "eventsPerStage") &&
+ (inherits(obj, "TrialDesignPlanSurvival") ||
+ inherits(obj, "SimulationResultsMultiArmSurvival"))) {
+ return(ifelse(tableOutputEnabled, "Cumulative events", "Cumulative events per stage"))
}
- if (!is.null(designPlan) &&
- inherits(designPlan, "TrialDesignPlanSurvival") &&
- identical(designPlan$.design$kMax, 1L)) {
- parameterNames$maxNumberOfEvents <- "Number of events"
+ if (identical(parameterName, "lambda1") &&
+ inherits(obj, "TrialDesignPlanSurvival") &&
+ !is.null(obj$.piecewiseSurvivalTime) &&
+ obj$.piecewiseSurvivalTime$piecewiseSurvivalEnabled) {
+ return("Piecewise survival lambda (1)")
}
- if (!is.null(designPlan) && inherits(designPlan, "TrialDesignPlan") &&
- identical(designPlan$.design$kMax, 1L)) {
- parameterNames$studyDuration <- "Study duration"
+ if (identical(parameterName, "lambda2") &&
+ inherits(obj, "TrialDesignPlanSurvival") &&
+ !is.null(obj$.piecewiseSurvivalTime) &&
+ obj$.piecewiseSurvivalTime$piecewiseSurvivalEnabled) {
+ return("Piecewise survival lambda (2)")
}
- if (!is.null(analysisResults)) {
- pluralExt <- ifelse(tableColumns, "", "s")
- if (.isTrialDesignConditionalDunnett(analysisResults$.design)) {
- parameterNames$repeatedConfidenceIntervalLowerBounds <-
- paste0("Overall confidence interval", pluralExt, " (lower)")
- parameterNames$repeatedConfidenceIntervalUpperBounds <-
- paste0("Overall confidence interval", pluralExt, " (upper)")
- parameterNames$repeatedPValues <- paste0("Overall p-value", pluralExt)
- } else if (identical(analysisResults$.design$kMax, 1L)) {
- parameterNames$repeatedConfidenceIntervalLowerBounds <- paste0("Confidence interval", pluralExt, " (lower)")
- parameterNames$repeatedConfidenceIntervalUpperBounds <- paste0("Confidence interval", pluralExt, " (upper)")
- parameterNames$repeatedPValues <- paste0("Overall p-value", pluralExt)
+ if (identical(parameterName, "maxNumberOfEvents") &&
+ inherits(obj, "TrialDesignPlanSurvival") &&
+ identical(obj$.design$kMax, 1L)) {
+ return("Number of events")
+ }
+
+ if (identical(parameterName, "studyDuration") &&
+ inherits(obj, "TrialDesignPlan") &&
+ identical(obj$.design$kMax, 1L)) {
+ return("Study duration")
+ }
+
+ if (inherits(obj, "AnalysisResults")) {
+ pluralExt <- ifelse(tableOutputEnabled, "", "s")
+ if (identical(parameterName, "repeatedConfidenceIntervalLowerBounds")) {
+ if (.isTrialDesignConditionalDunnett(obj$.design)) {
+ return(paste0("Overall confidence interval", pluralExt, " (lower)"))
+ } else {
+ return(paste0("Confidence interval", pluralExt, " (lower)"))
+ }
+ }
+ if (identical(parameterName, "repeatedConfidenceIntervalUpperBounds")) {
+ if (.isTrialDesignConditionalDunnett(obj$.design)) {
+ return(paste0("Overall confidence interval", pluralExt, " (upper)"))
+ } else {
+ return(paste0("Confidence interval", pluralExt, " (upper)"))
+ }
+ }
+ if (identical(parameterName, "repeatedPValues")) {
+ return(paste0("Overall p-value", pluralExt))
}
}
- if (!is.null(designPlan) &&
- (inherits(designPlan, "TrialDesignPlanMeans") ||
- inherits(designPlan, "SimulationResultsMeans")) &&
- isTRUE(designPlan$meanRatio)) {
- parameterNames$stDev <- "Coefficient of variation"
+ if (identical(parameterName, "stDev") &&
+ (inherits(obj, "TrialDesignPlanMeans") || inherits(obj, "SimulationResultsMeans")) &&
+ isTRUE(obj$meanRatio)) {
+ return("Coefficient of variation")
}
- if (!is.null(design) && .getClassName(design) != "TrialDesign" && design$sided == 2) {
- parameterNames$criticalValuesPValueScale <- paste0("Local two-sided significance level", ifelse(tableColumns, "", "s"))
+ if (identical(parameterName, "criticalValuesPValueScale") && inherits(obj, "TrailDesign") &&
+ .getClassName(obj) != "TrialDesign" && obj$sided == 2) {
+ return(paste0("Local two-sided significance level", ifelse(tableOutputEnabled, "", "s")))
}
- if ((!is.null(stageResults) && stageResults$isOneSampleDataset()) ||
- (!is.null(dataset) && inherits(dataset, "DatasetMeans"))) {
- parameterNames$overallStDevs <- paste0("Cumulative standard deviation", ifelse(tableColumns, "", "s"))
+ if (identical(parameterName, "overallStDevs") &&
+ ((inherits(obj, "StageResults") && obj$isOneSampleDataset()) ||
+ inherits(obj, "DatasetMeans"))) {
+ return(paste0("Cumulative standard deviation", ifelse(tableOutputEnabled, "", "s")))
}
- return(parameterNames)
-}
+ if (tableOutputEnabled) {
+ return(C_TABLE_COLUMN_NAMES[[parameterName]])
+ }
-.getParameterNames <- function(...,
- design = NULL,
- designPlan = NULL,
- stageResults = NULL,
- analysisResults = NULL,
- dataset = NULL,
- designCharacteristics = NULL) {
- .getParameterCaptions(
- captionList = C_PARAMETER_NAMES,
- design = design,
- designPlan = designPlan,
- stageResults = stageResults,
- analysisResults = analysisResults,
- dataset = dataset,
- designCharacteristics = designCharacteristics
- )
+ return(C_PARAMETER_NAMES[[parameterName]])
}
-.getTableColumnNames <- function(...,
- design = NULL,
- designPlan = NULL,
- stageResults = NULL,
- analysisResults = NULL,
- dataset = NULL,
- designCharacteristics = NULL,
- designSet = NULL) {
- .getParameterCaptions(
- captionList = C_TABLE_COLUMN_NAMES,
- design = design,
- designPlan = designPlan,
- stageResults = stageResults,
- analysisResults = analysisResults,
- dataset = dataset,
- designCharacteristics = designCharacteristics,
- designSet = designSet,
- tableColumns = TRUE
- )
+.getParameterFormatFunction <- function(parameterName, obj = NULL) {
+ if (is.null(obj) || !inherits(obj, "FieldSet")) {
+ return(C_PARAMETER_FORMAT_FUNCTIONS[[parameterName]])
+ }
+
+ if (parameterName == "overallAdjustedTestStatistics" &&
+ inherits(obj, "ClosedCombinationTestResults") &&
+ !is.null(obj[[".design"]]) &&
+ inherits(obj$.design, C_CLASS_NAME_TRIAL_DESIGN_FISHER)) {
+ return(".formatTestStatisticsFisher")
+ }
+
+ if (parameterName == "maxInformation" && inherits(obj, "TrialDesignPlanCountData")) {
+ return(".formatRatesDynamic")
+ }
+
+ if (parameterName == "nFixed" && inherits(obj, "TrialDesignCharacteristics")) {
+ return(".formatProbabilities")
+ }
+
+ if (parameterName == "criticalValues" && inherits(obj, "TrialDesignFisher")) {
+ return(".formatCriticalValuesFisher")
+ }
+
+ if (parameterName == "accrualTime" && inherits(obj, "TrialDesignPlanCountData")) {
+ if (obj$.getParameterType("accrualTime") == C_PARAM_USER_DEFINED) {
+ return(".formatHowItIs")
+ }
+ }
+
+ return(C_PARAMETER_FORMAT_FUNCTIONS[[parameterName]])
}
-C_PARAMETER_FORMAT_FUNCTIONS <- list(
+C_PARAMETER_FORMAT_FUNCTIONS <- createDictionary("C_PARAMETER_FORMAT_FUNCTIONS", list(
means = ".formatMeans",
stDevs = ".formatStDevs",
stDev = ".formatStDevs",
@@ -1173,11 +1193,9 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
alphaSpent = ".formatProbabilities",
alpha0Vec = ".formatProbabilities",
simAlpha = ".formatProbabilities",
- criticalValues = ".formatCriticalValuesFisher", # will be set in class TrialDesignFisher
- criticalValues = ".formatCriticalValues", # will be set in class TrialDesignGroupSequential
+ criticalValues = ".formatCriticalValues",
betaSpent = ".formatProbabilities",
futilityBounds = ".formatCriticalValues",
- alpha0Vec = ".formatProbabilities",
constantBoundsHP = ".formatCriticalValues",
nMax = ".formatProbabilities",
nFixed = ".formatSampleSizes",
@@ -1218,7 +1236,6 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
overallStDevs2 = ".formatStDevs",
overallStDevs = ".formatStDevs",
overallPooledStDevs = ".formatStDevs",
- testStatistics = ".formatTestStatistics",
combInverseNormal = ".formatTestStatistics",
combFisher = ".formatTestStatisticsFisher",
weightsFisher = ".formatRates",
@@ -1271,7 +1288,6 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
expectedEventsH1 = ".formatEvents",
analysisTime = ".formatTime",
studyDurationH1 = ".formatDurations",
- expectedNumberOfSubjectsH1 = ".formatSampleSizes",
expectedEvents = ".formatEvents",
varianceEvents = ".formatEvents",
overallExpectedEvents = ".formatEvents",
@@ -1296,8 +1312,6 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
accrualIntensity = ".formatAccrualIntensities",
accrualIntensityRelative = ".formatAccrualIntensities",
eventsPerStage = ".formatEvents",
- expectedNumberOfEvents = ".formatEvents",
- expectedNumberOfSubjects = ".formatEvents",
singleNumberOfEventsPerStage = ".formatEvents",
time = ".formatTime",
cumulativeEventProbabilities = ".formatProbabilities",
@@ -1319,7 +1333,6 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
overallPisControl = ".formatRates",
overallPisTreatment = ".formatRates",
adjustedStageWisePValues = ".formatPValues",
- overallAdjustedTestStatistics = ".formatTestStatisticsFisher", # will be set in class ClosedCombinationTestResults
overallAdjustedTestStatistics = ".formatTestStatistics",
conditionalErrorRate = ".formatProbabilities",
secondStagePValues = ".formatPValues",
@@ -1357,7 +1370,6 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
variationConditionalPower = ".formatProbabilities",
subscoreConditionalPower = ".formatProbabilities",
performanceScore = ".formatProbabilities",
-
overdispersion = ".formatStDevs",
lambda = ".formatRates",
fixedExposureTime = ".formatTime",
@@ -1370,4 +1382,4 @@ C_PARAMETER_FORMAT_FUNCTIONS <- list(
expectedInformationH01 = ".formatRatesDynamic",
expectedInformationH1 = ".formatRatesDynamic",
plannedMaxSubjects = ".formatSampleSizes"
-)
+))
diff --git a/R/f_core_plot.R b/R/f_core_plot.R
index 5fedef73..254c7737 100644
--- a/R/f_core_plot.R
+++ b/R/f_core_plot.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7558 $
-## | Last changed: $Date: 2024-01-12 15:29:16 +0100 (Fri, 12 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -792,23 +792,24 @@ getAvailablePlotTypes <- function(obj, output = c("numeric", "caption", "numcap"
for (variedParameter in variedParameters) {
variedParameterNames <- c(
variedParameterNames,
- .getTableColumnNames(design = designMaster)[[variedParameter]]
+ .getParameterCaption(variedParameter, designMaster, tableOutputEnabled = TRUE)
)
}
names(variedParameters) <- variedParameterNames
return(list(data = data, variedParameters = variedParameters))
}
-.getCategories <- function(data, yParameterName, tableColumnNames) {
+.getCategories <- function(data, yParameterName, parameterSet) {
+ axisLabel <- .getAxisLabel(yParameterName, parameterSet)
if (is.null(data$categories) || sum(is.na(data$categories)) > 0) {
- return(rep(.getAxisLabel(yParameterName, tableColumnNames), nrow(data)))
+ return(rep(axisLabel, nrow(data)))
}
- return(paste(data$categories, .getAxisLabel(yParameterName, tableColumnNames), sep = ", "))
+ return(paste(data$categories, axisLabel, sep = ", "))
}
-.getAxisLabel <- function(parameterName, tableColumnNames) {
- axisLabel <- tableColumnNames[[parameterName]]
+.getAxisLabel <- function(parameterName, parameterSet) {
+ axisLabel <- .getParameterCaption(parameterName, parameterSet, tableOutputEnabled = TRUE)
if (is.null(axisLabel)) {
return(paste0("%", parameterName, "%"))
}
@@ -945,45 +946,41 @@ getAvailablePlotTypes <- function(obj, output = c("numeric", "caption", "numcap"
}
mirrorModeEnabled <- any(grepl("Mirrored$", yParameterNames))
-
- tableColumnNames <- .getTableColumnNames(design = designMaster,
- designSet = if (.isTrialDesignSet(parameterSet)) parameterSet else NULL)
-
- xAxisLabel <- .getAxisLabel(xParameterName, tableColumnNames)
- yAxisLabel1 <- .getAxisLabel(yParameterName1, tableColumnNames)
+ xAxisLabel <- .getAxisLabel(xParameterName, parameterSet)
+ yAxisLabel1 <- .getAxisLabel(yParameterName1, parameterSet)
yAxisLabel2 <- NULL
if (!is.null(yParameterName2) && !is.null(yParameterName3)) {
if (!is.na(yParameterName2)) {
- pn2 <- .getAxisLabel(yParameterName2, tableColumnNames)
+ pn2 <- .getAxisLabel(yParameterName2, parameterSet)
if (yParameterName2 == "overallEarlyStop") {
pn2 <- "Stopping Probability"
}
- yAxisLabel2 <- paste(pn2, .getAxisLabel(yParameterName3, tableColumnNames), sep = " and ")
+ yAxisLabel2 <- paste(pn2, .getAxisLabel(yParameterName3, parameterSet), sep = " and ")
} else {
- yAxisLabel2 <- .getAxisLabel(yParameterName3, tableColumnNames)
+ yAxisLabel2 <- .getAxisLabel(yParameterName3, parameterSet)
}
} else if (xParameterName == "effectMatrix" && !is.null(yParameterName2) && !is.na(yParameterName2) &&
yParameterName1 %in% c("expectedNumberOfEvents", "expectedNumberOfSubjects") &&
yParameterName2 == "rejectAtLeastOne") {
# special case: simulation results, plot type 6 (expected number of subjects and power)
- yAxisLabel2 <- .getAxisLabel(yParameterName2, tableColumnNames)
+ yAxisLabel2 <- .getAxisLabel(yParameterName2, parameterSet)
yParameterName3 <- yParameterName2
yParameterName2 <- NA_character_
} else if (!is.null(yParameterName2) && !mirrorModeEnabled) {
- yAxisLabel1 <- paste(yAxisLabel1, .getAxisLabel(yParameterName2, tableColumnNames), sep = " and ")
+ yAxisLabel1 <- paste(yAxisLabel1, .getAxisLabel(yParameterName2, parameterSet), sep = " and ")
}
if (yParameterName1 %in% c("alphaSpent", "betaSpent")) {
yAxisLabel1 <- "Cumulative Error"
if (is.null(yParameterName2)) {
- yAxisLabel1 <- paste0(yAxisLabel1, " (", .getAxisLabel(yParameterName1, tableColumnNames), ")")
+ yAxisLabel1 <- paste0(yAxisLabel1, " (", .getAxisLabel(yParameterName1, parameterSet), ")")
}
}
- yAxisLabel1 <- sub(paste0(C_PARAMETER_NAMES[["futilityBoundsDelayedInformation"]], " and"),
+ yAxisLabel1 <- sub(paste0(.getParameterCaption("futilityBoundsDelayedInformation"), " and"),
"Lower and", yAxisLabel1,
fixed = TRUE
)
- yAxisLabel1 <- sub(paste0(C_PARAMETER_NAMES[["futilityBoundsDelayedInformationNonBinding"]], " and"),
+ yAxisLabel1 <- sub(paste0(.getParameterCaption("futilityBoundsDelayedInformationNonBinding"), " and"),
"Lower and", yAxisLabel1,
fixed = TRUE
)
@@ -1075,20 +1072,20 @@ getAvailablePlotTypes <- function(obj, output = c("numeric", "caption", "numcap"
df1 <- data.frame(
xValues = data$xValues,
yValues = data$yValues * scalingFactor1,
- categories = .getCategories(data, yParameterName1, tableColumnNames)
+ categories = .getCategories(data, yParameterName1, parameterSet)
)
if (!is.na(yParameterName2)) {
df2 <- data.frame(
xValues = data$xValues,
yValues = data$yValues2 * scalingFactor2,
- categories = .getCategories(data, yParameterName2, tableColumnNames)
+ categories = .getCategories(data, yParameterName2, parameterSet)
)
}
if (!is.null(yParameterName3)) {
df3 <- data.frame(
xValues = data$xValues,
yValues = data$yValues3 * scalingFactor2,
- categories = .getCategories(data, yParameterName3, tableColumnNames)
+ categories = .getCategories(data, yParameterName3, parameterSet)
)
if (is.na(yParameterName2)) {
data <- rbind(df1, df3)
diff --git a/R/f_core_utilities.R b/R/f_core_utilities.R
index 885809a4..078d3658 100644
--- a/R/f_core_utilities.R
+++ b/R/f_core_utilities.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7557 $
-## | Last changed: $Date: 2024-01-12 13:41:28 +0100 (Fr, 12 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -1045,24 +1045,8 @@ getParameterCaption <- function(obj, parameterName) {
stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT, "'obj' (", .getClassName(obj), ") must be an rpact result object")
}
.assertIsSingleCharacter(parameterName, "parameterName", naAllowed = FALSE)
-
- design <- NULL
- designPlan <- NULL
- if (inherits(obj, "TrialDesignPlan")) {
- designPlan <- obj
- design <- obj$.design
- } else if (inherits(obj, "TrialDesign")) {
- design <- obj
- } else {
- design <- obj[[".design"]]
- }
-
- parameterNames <- .getParameterNames(design = design, designPlan = designPlan)
- if (is.null(parameterNames) || length(parameterNames) == 0) {
- return(NULL)
- }
-
- return(parameterNames[[parameterName]])
+
+ return(.getParameterCaption(parameterName, obj))
}
#'
@@ -1094,24 +1078,29 @@ getParameterName <- function(obj, parameterCaption) {
stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT, "'obj' (", .getClassName(obj), ") must be an rpact result object")
}
.assertIsSingleCharacter(parameterCaption, "parameterCaption", naAllowed = FALSE)
-
- design <- NULL
- designPlan <- NULL
- if (inherits(obj, "TrialDesignPlan")) {
- designPlan <- obj
- design <- obj$.design
- } else if (inherits(obj, "TrialDesign")) {
- design <- obj
- } else {
- design <- obj[[".design"]]
- }
-
- parameterNames <- .getParameterNames(design = design, designPlan = designPlan)
- if (is.null(parameterNames) || length(parameterNames) == 0) {
- return(NULL)
+
+ parameterName <- getDictionaryKeyByValue(C_PARAMETER_NAMES, parameterCaption)
+ if (!is.null(parameterName)) {
+ return(parameterName)
+ }
+
+ parameterName <- getDictionaryKeyByValue(C_PARAMETER_NAMES_PLOT_SETTINGS, parameterCaption)
+ if (!is.null(parameterName)) {
+ return(parameterName)
+ }
+
+ fieldNames <- obj$.getVisibleFieldNames()
+ for (parameterName in fieldNames) {
+ if (identical(.getParameterCaption(parameterName, obj), parameterCaption)) {
+ return(parameterName)
+ }
+
+ if (identical(.getParameterCaption(parameterName, obj, tableOutputEnabled = TRUE), parameterCaption)) {
+ return(parameterName)
+ }
}
- return(unique(names(parameterNames)[parameterNames == parameterCaption]))
+ return("unknown")
}
.removeLastEntryFromArray <- function(x) {
diff --git a/R/f_design_plan_count_data.R b/R/f_design_plan_count_data.R
index 5c125efd..1073129f 100644
--- a/R/f_design_plan_count_data.R
+++ b/R/f_design_plan_count_data.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7596 $
-## | Last changed: $Date: 2024-01-25 14:33:51 +0100 (Do, 25 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -57,7 +57,7 @@
return(1 / (1 / sumLambda1 + 1 / sumLambda2) -
information * shift / log(lambda1 / lambda2 / thetaH0)^2)
},
- interval = c(0, 10 * min(1, max(accrualTime))),
+ interval = c(0, 10 * max(1, max(accrualTime))),
extendInt = "yes",
tol = 1e-07
)$root)
@@ -192,12 +192,10 @@
.setValueAndParameterType(designPlan, "overdispersion", overdispersion, 0)
.setValueAndParameterType(designPlan, "fixedExposureTime", fixedExposureTime, NA_real_, notApplicableIfNA = TRUE)
.setValueAndParameterType(designPlan, "accrualTime", accrualTime, NA_real_, notApplicableIfNA = TRUE)
- if (designPlan$.getParameterType("accrualTime") == C_PARAM_USER_DEFINED) {
- designPlan$.parameterFormatFunctions$accrualTime <- ".formatHowItIs"
- }
.setValueAndParameterType(designPlan, "accrualIntensity", accrualIntensity, NA_real_, notApplicableIfNA = TRUE)
.setValueAndParameterType(designPlan, "followUpTime", followUpTime, NA_real_, notApplicableIfNA = TRUE)
- .setValueAndParameterType(designPlan, "maxNumberOfSubjects", as.integer(maxNumberOfSubjects), NA_integer_, notApplicableIfNA = TRUE)
+ .setValueAndParameterType(designPlan, "maxNumberOfSubjects",
+ as.integer(maxNumberOfSubjects), NA_integer_, notApplicableIfNA = TRUE)
.setValueAndParameterType(
designPlan, "allocationRatioPlanned",
allocationRatioPlanned, C_ALLOCATION_RATIO_DEFAULT
@@ -383,7 +381,8 @@ getSampleSizeCounts <- function(design = NULL, ...,
)
)
- designPlan$earlyStop <- sum(c(designCharacteristics$rejectionProbabilities[1:(design$kMax - 1)], designPlan$futilityStop))
+ designPlan$earlyStop <- sum(c(
+ designCharacteristics$rejectionProbabilities[1:(design$kMax - 1)], designPlan$futilityStop))
designPlan$.setParameterType("earlyStop", C_PARAM_GENERATED)
} else {
diff --git a/R/f_design_plan_plot.R b/R/f_design_plan_plot.R
index ff65f7f1..08d5bfb4 100644
--- a/R/f_design_plan_plot.R
+++ b/R/f_design_plan_plot.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7565 $
-## | Last changed: $Date: 2024-01-15 15:07:02 +0100 (Mo, 15 Jan 2024) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -435,9 +435,8 @@
)
if (groupedPlotEnabled) {
- tableColumnNames <- C_TABLE_COLUMN_NAMES
- criticalValuesName <- designPlan$.getDataFrameColumnCaption("criticalValuesEffectScale", tableColumnNames, TRUE)
- futilityBoundsName <- designPlan$.getDataFrameColumnCaption("futilityBoundsEffectScale", tableColumnNames, TRUE)
+ criticalValuesName <- designPlan$.getDataFrameColumnCaption("criticalValuesEffectScale", TRUE)
+ futilityBoundsName <- designPlan$.getDataFrameColumnCaption("futilityBoundsEffectScale", TRUE)
designPlan <- data.frame(
xValues = rep(data[[xParameterName]], 4),
diff --git a/R/f_parameter_set_utilities.R b/R/f_parameter_set_utilities.R
index 3ea0c5bb..22fd0dfa 100644
--- a/R/f_parameter_set_utilities.R
+++ b/R/f_parameter_set_utilities.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 5924 $
-## | Last changed: $Date: 2022-03-04 10:48:37 +0100 (Fri, 04 Mar 2022) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -46,6 +46,13 @@ NULL
}
.getMatrixFormatted <- function(paramValueFormatted, enforceListOuput = FALSE) {
+ if (length(paramValueFormatted) == 0) {
+ return(list(
+ paramValueFormatted = matrix(nrow = 0, ncol = 0),
+ type = "matrix"
+ ))
+ }
+
if (!is.matrix(paramValueFormatted) && enforceListOuput) {
paramValueFormatted <- matrix(paramValueFormatted, nrow = 1)
}
@@ -136,7 +143,7 @@ NULL
paramValueFormatted <- C_TYPE_OF_DESIGN_BS_LIST[[paramValue]]
}
} else {
- formatFunctionName <- obj$.parameterFormatFunctions[[parameterName]]
+ formatFunctionName <- .getParameterFormatFunction(parameterName, obj)
if (!is.null(formatFunctionName)) {
paramValueFormatted <- eval(call(formatFunctionName, paramValueFormatted))
if (.isArray(paramValue) && length(dim(paramValue)) == 2) {
diff --git a/R/f_quality_assurance.R b/R/f_quality_assurance.R
index 734f335c..36a2ac41 100644
--- a/R/f_quality_assurance.R
+++ b/R/f_quality_assurance.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7428 $
-## | Last changed: $Date: 2023-11-13 10:42:22 +0100 (Mo, 13 Nov 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -37,7 +37,8 @@ NULL
.skipTestIfPipeOperatorNotAvailable <- function() {
if (!.isPipeOperatorAvailable()) {
- testthat::skip("The test is disabled because it works only for R version >= 4.1.0 (pipe operator is available)")
+ testthat::skip(paste0("The test is disabled because it works only for ",
+ "R version >= 4.1.0 (pipe operator is available)"))
}
}
@@ -195,7 +196,8 @@ NULL
for (testFile in testFiles) {
file.copy(file.path(testthatTempSubDirectory, testFile), file.path(testFileTargetDirectory, testFile))
}
- message(length(testFiles), " extracted from ", sQuote(packageSource), " and copied to ", sQuote(testFileTargetDirectory))
+ message(length(testFiles), " extracted from ", sQuote(packageSource),
+ " and copied to ", sQuote(testFileTargetDirectory))
},
finally = {
if (!is.null(testthatTempDirectory)) {
@@ -214,7 +216,7 @@ NULL
tryCatch(
{
version <- utils::packageVersion("rpact")
- baseUrl <- paste0("http://", token, ":", secret, "@unit.tests.rpact.com/", version, "/tests/")
+ baseUrl <- paste0("https://", token, ":", secret, "@unit.tests.rpact.com/", version, "/tests/")
if (!dir.exists(testFileTargetDirectory)) {
dir.create(testFileTargetDirectory)
@@ -228,7 +230,7 @@ NULL
file.copy(testthatBaseFile, file.path(testFileTargetDirectory, "testthat.R"))
} else {
currentFile <- "testthat.R"
- result <- download.file(
+ result <- utils::download.file(
url = paste0(baseUrl, "testthat.R"),
destfile = file.path(testFileTargetDirectory, "testthat.R"),
method = "auto", mode = "wb"
@@ -239,7 +241,7 @@ NULL
}
currentFile <- "index.txt"
- result <- download.file(
+ result <- utils::download.file(
url = paste0(baseUrl, "testthat/index.txt"),
destfile = indexFile, quiet = TRUE,
method = "auto", mode = "wb"
@@ -264,7 +266,7 @@ NULL
message("Start to download ", length(testFiles), " unit test files (http). Please wait...")
for (testFile in testFiles) {
currentFile <- testFile
- result <- download.file(
+ result <- utils::download.file(
url = paste0(baseUrl, "testthat/", testFile),
destfile = file.path(testthatSubDirectory, testFile), quiet = TRUE,
method = "auto", mode = "wb"
@@ -290,7 +292,8 @@ NULL
.logDebug(e$message)
stop(
C_EXCEPTION_TYPE_RUNTIME_ISSUE,
- "failed to download unit test files (http): illegal 'token' / 'secret' or rpact version ", version, " unknown"
+ "failed to download unit test files (http): ",
+ "illegal 'token' / 'secret' or rpact version ", version, " unknown"
)
},
finally = {
@@ -373,7 +376,8 @@ NULL
.logDebug(e$message)
stop(
C_EXCEPTION_TYPE_RUNTIME_ISSUE,
- "failed to download unit test files (ftp): illegal 'token' / 'secret' or rpact version ", version, " unknown"
+ "failed to download unit test files (ftp): ",
+ "illegal 'token' / 'secret' or rpact version ", version, " unknown"
)
},
finally = {
@@ -396,7 +400,8 @@ NULL
"mode", "cacheEnabled", "extra", "cleanOldFiles", "connectionType"
)) {
if (is.null(connection) || !is.list(connection)) {
- stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT, "'connection' must be a list (is ", .getClassName(connection), ")")
+ stop(C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
+ "'connection' must be a list (is ", .getClassName(connection), ")")
}
name <- match.arg(name)
@@ -555,7 +560,9 @@ testPackage <- function(outDir = ".", ...,
)
}
- cat("Total runtime for testing: ", .getRuntimeString(startTime, endTime = endTime, runtimeUnits = "auto"), ".\n", sep = "")
+ cat("Total runtime for testing: ", .getRuntimeString(startTime,
+ endTime = endTime, runtimeUnits = "auto"
+ ), ".\n", sep = "")
inputFileName <- file.path(outDir, "testthat.Rout")
if (file.exists(inputFileName)) {
diff --git a/R/f_simulation_enrichment.R b/R/f_simulation_enrichment.R
index 49d29f56..76d912c4 100644
--- a/R/f_simulation_enrichment.R
+++ b/R/f_simulation_enrichment.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7206 $
-## | Last changed: $Date: 2023-07-25 14:55:05 +0200 (Tue, 25 Jul 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -256,7 +256,7 @@ NULL
if (k < kMax) {
futilityStop[k] <- all(futility[stageResults$selectedPopulations[1:gMax, k], k])
- if (all(isFALSE(stageResults$selectedPopulations[1:gMax, k + 1]))) {
+ if (all(!stageResults$selectedPopulations[1:gMax, k + 1], na.rm = TRUE)) {
futilityStop[k] <- TRUE
}
}
@@ -449,24 +449,6 @@ NULL
)
}
- if (endpoint == "means") {
- # if (is.na(conditionalPower) && is.null(calcSubjectsFunction) && !is.na(thetaH1)) {
- # warning("'thetaH1' will be ignored because neither 'conditionalPower' nor ",
- # "'calcSubjectsFunction' is defined", call. = FALSE)
- # }
- # if (is.na(conditionalPower) && is.null(calcSubjectsFunction) && !is.na(stDevH1)) {
- # warning("'stDevH1' will be ignored because neither 'conditionalPower' nor ",
- # "'calcSubjectsFunction' is defined", call. = FALSE)
- # }
- }
-
- if (endpoint == "survival") {
- # if (is.na(conditionalPower) && is.null(calcEventsFunction) && !is.na(thetaH1)) {
- # warning("'thetaH1' will be ignored because neither 'conditionalPower' nor ",
- # "'calcEventsFunction' is defined", call. = FALSE)
- # }
- }
-
conditionalPower <- .ignoreParameterIfNotUsed(
"conditionalPower",
conditionalPower, kMax > 1, "design is fixed ('kMax' = 1)"
diff --git a/R/f_simulation_multiarm.R b/R/f_simulation_multiarm.R
index 744416f6..b97de324 100644
--- a/R/f_simulation_multiarm.R
+++ b/R/f_simulation_multiarm.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7379 $
-## | Last changed: $Date: 2023-10-30 16:19:12 +0100 (Mo, 30 Okt 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -222,7 +222,7 @@ NULL
if (k < kMax) {
futilityStop[k] <- all(futility[stageResults$selectedArms[1:gMax, k], k])
- if (all(isFALSE(stageResults$selectedArms[1:gMax, k + 1]))) {
+ if (all(!stageResults$selectedArms[1:gMax, k + 1], na.rm = TRUE)) {
futilityStop[k] <- TRUE
}
}
@@ -290,7 +290,7 @@ NULL
signedOverallTestStatistics[, 2] <- sqrt(informationAtInterim) *
testStatistics[, 1] + sqrt(1 - informationAtInterim) * testStatistics[, 2]
- if (all(isFALSE(stageResults$selectedArms[1:gMax, 2]))) {
+ if (all(!stageResults$selectedArms[1:gMax, 2], na.rm = TRUE)) {
futilityStop <- TRUE
}
diff --git a/R/f_simulation_plot.R b/R/f_simulation_plot.R
index 3bba1b52..18c753d7 100644
--- a/R/f_simulation_plot.R
+++ b/R/f_simulation_plot.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7492 $
-## | Last changed: $Date: 2023-12-13 08:31:58 +0100 (Mi, 13 Dez 2023) $
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -101,7 +101,7 @@ NULL
if (grepl("SimulationResultsEnrichment", .getClassName(simulationResults))) {
effectDataList <- .getSimulationEnrichmentEffectData(simulationResults)
if (ncol(effectDataList$effectData) == 1) {
- xLabel <- simulationResults$.parameterNames[[effectDataList$effectMatrixName]]
+ xLabel <- .getParameterCaption(effectDataList$effectMatrixName, simulationResults)
return(sub("s$", "", xLabel))
}
@@ -141,7 +141,7 @@ NULL
data <- NULL
for (yParameterName in yParameterNames) {
- category <- simulationResults$.parameterNames[[yParameterName]]
+ category <- .getParameterCaption(yParameterName, simulationResults)
part <- data.frame(
categories = rep(category, length(xValues)),
xValues = xValues,
diff --git a/R/parameter_descriptions.R b/R/parameter_descriptions.R
index a6dcfbe0..e1ecdad4 100644
--- a/R/parameter_descriptions.R
+++ b/R/parameter_descriptions.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7592 $
-## | Last changed: $Date: 2024-01-24 10:48:09 +0100 (Mi, 24 Jan 2024) $
+## | File version: $Revision: 7619 $
+## | Last changed: $Date: 2024-02-09 11:29:14 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: wassmer $
## |
@@ -335,7 +335,7 @@ NULL
NULL
#' Parameter Description: followUpTime for Counts
-#' @param followUpTime If specified, The assumed (additional) follow-up time for the study, there is no default.
+#' @param followUpTime If specified, the assumed (additional) follow-up time for the study, there is no default.
#' The total study duration is \code{accrualTime + followUpTime}.
#' @name param_followUpTime_counts
#' @keywords internal
diff --git a/README.Rmd b/README.Rmd
index 935b6781..6fb42e5f 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -13,14 +13,14 @@ knitr::opts_chunk$set(
```
-[![](https://img.shields.io/badge/CRAN-3.5.0-green.svg)](https://cran.r-project.org/package=rpact)
-[![R-CMD-check](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml)
-[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
-[![Monthly downloads](https://cranlogs.r-pkg.org/badges/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
-[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
-[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
-[![](https://img.shields.io/badge/doi-10.1007/978--3--319--32562--0-yellow.svg)](https://doi.org/10.1007/978-3-319-32562-0)
-[![shinyapps.io](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://rpact.shinyapps.io/public)
+[![](https://www.r-pkg.org/badges/version/rpact)](https://cran.r-project.org/package=rpact)
+[![R-CMD-check](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml)
+[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
+[![Monthly downloads](https://cranlogs.r-pkg.org/badges/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
+[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
+[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
+[![](https://img.shields.io/badge/doi-10.1007/978--3--319--32562--0-yellow.svg)](https://doi.org/10.1007/978-3-319-32562-0)
+[![shinyapps.io](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://rpact.shinyapps.io/public)
[![](https://img.shields.io/badge/RPACT-Cloud-blue.svg)](https://rpact.shinyapps.io/cloud)
diff --git a/README.md b/README.md
index dd587869..a97ba5e7 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,12 @@
-[![](https://img.shields.io/badge/CRAN-3.5.0-green.svg)](https://cran.r-project.org/package=rpact)
-[![R-CMD-check](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml)
-[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
-[![Monthly downloads](https://cranlogs.r-pkg.org/badges/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
-[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
-[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)[![](https://img.shields.io/badge/doi-10.1007/978--3--319--32562--0-yellow.svg)](https://doi.org/10.1007/978-3-319-32562-0)
-[![shinyapps.io](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://rpact.shinyapps.io/public)
+[![](https://www.r-pkg.org/badges/version/rpact)](https://cran.r-project.org/package=rpact)
+[![R-CMD-check](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rpact-com/rpact/actions/workflows/R-CMD-check.yaml)
+[![Total downloads](https://cranlogs.r-pkg.org/badges/grand-total/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
+[![Monthly downloads](https://cranlogs.r-pkg.org/badges/rpact?color=blue)](https://CRAN.R-project.org/package=rpact)
+[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
+[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
+[![](https://img.shields.io/badge/doi-10.1007/978--3--319--32562--0-yellow.svg)](https://doi.org/10.1007/978-3-319-32562-0)
+[![shinyapps.io](https://img.shields.io/badge/Shiny-shinyapps.io-blue?style=flat&labelColor=white&logo=RStudio&logoColor=blue)](https://rpact.shinyapps.io/public)
[![](https://img.shields.io/badge/RPACT-Cloud-blue.svg)](https://rpact.shinyapps.io/cloud)
diff --git a/cran-comments.md b/cran-comments.md
index 696522eb..65c06321 100644
--- a/cran-comments.md
+++ b/cran-comments.md
@@ -10,7 +10,7 @@ There were no ERRORs or WARNINGs.
## Unit tests: testthat results (complete test)
-OK: 33863
+OK: 43819
Failed: 0
Warnings: 0
Skipped: 0
diff --git a/inst/doc/rpact_getting_started.html b/inst/doc/rpact_getting_started.html
index 0167589b..2c4a798d 100644
--- a/inst/doc/rpact_getting_started.html
+++ b/inst/doc/rpact_getting_started.html
@@ -12,7 +12,7 @@
-
+
Getting started with rpact
@@ -239,7 +239,7 @@
Getting started with rpact
Friedrich Pahlke and Gernot Wassmer
-2024-01-25
+2024-02-09
diff --git a/man/getPowerCounts.Rd b/man/getPowerCounts.Rd
index c89ed55b..70892def 100644
--- a/man/getPowerCounts.Rd
+++ b/man/getPowerCounts.Rd
@@ -74,7 +74,7 @@ default is \code{0}.}
\item{accrualIntensity}{If specified, the assumed accrual intensities for the study, there is no default.}
-\item{followUpTime}{If specified, The assumed (additional) follow-up time for the study, there is no default.
+\item{followUpTime}{If specified, the assumed (additional) follow-up time for the study, there is no default.
The total study duration is \code{accrualTime + followUpTime}.}
\item{allocationRatioPlanned}{The planned allocation ratio \code{n1 / n2} for a two treatment groups
diff --git a/man/getSampleSizeCounts.Rd b/man/getSampleSizeCounts.Rd
index 8d038ff1..361da003 100644
--- a/man/getSampleSizeCounts.Rd
+++ b/man/getSampleSizeCounts.Rd
@@ -66,7 +66,7 @@ default is \code{0}.}
\item{accrualIntensity}{If specified, the assumed accrual intensities for the study, there is no default.}
-\item{followUpTime}{If specified, The assumed (additional) follow-up time for the study, there is no default.
+\item{followUpTime}{If specified, the assumed (additional) follow-up time for the study, there is no default.
The total study duration is \code{accrualTime + followUpTime}.}
\item{maxNumberOfSubjects}{\code{maxNumberOfSubjects > 0} needs to be specified for power calculations or calculation
diff --git a/man/param_followUpTime_counts.Rd b/man/param_followUpTime_counts.Rd
index e927ab67..d70f24bb 100644
--- a/man/param_followUpTime_counts.Rd
+++ b/man/param_followUpTime_counts.Rd
@@ -4,7 +4,7 @@
\alias{param_followUpTime_counts}
\title{Parameter Description: followUpTime for Counts}
\arguments{
-\item{followUpTime}{If specified, The assumed (additional) follow-up time for the study, there is no default.
+\item{followUpTime}{If specified, the assumed (additional) follow-up time for the study, there is no default.
The total study duration is \code{accrualTime + followUpTime}.}
}
\description{
diff --git a/tests/testthat/test-f_simulation_multiarm_means.R b/tests/testthat/test-f_simulation_multiarm_means.R
index d042ef1e..38521700 100644
--- a/tests/testthat/test-f_simulation_multiarm_means.R
+++ b/tests/testthat/test-f_simulation_multiarm_means.R
@@ -1,1811 +1,1798 @@
-## |
+## |
## | *Unit tests*
-## |
+## |
## | This file is part of the R package rpact:
## | Confirmatory Adaptive Clinical Trial Design and Analysis
-## |
+## |
## | Author: Gernot Wassmer, PhD, and Friedrich Pahlke, PhD
## | Licensed under "GNU Lesser General Public License" version 3
## | License text can be found here: https://www.r-project.org/Licenses/LGPL-3
-## |
+## |
## | RPACT company website: https://www.rpact.com
## | RPACT package website: https://www.rpact.org
-## |
+## |
## | Contact us for information about our services: info@rpact.com
-## |
+## |
## | File name: test-f_simulation_multiarm_means.R
-## | Creation date: 08 November 2023, 09:11:42
-## | File version: $Revision: 7560 $
-## | Last changed: $Date: 2024-01-15 14:20:32 +0100 (Mo, 15 Jan 2024) $
+## | Creation date: 09 February 2024, 10:57:28
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
-## |
+## |
test_plan_section("Testing Simulation Multi-Arm Means Function")
test_that("'getSimulationMultiArmMeans': several configurations", {
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
- # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetBonferroni}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- # @refFS[Formula]{fs:adjustedPValueSubsetHierarchical}
- # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
- # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
- x1 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4, plannedSubjects = c(10, 30, 50), stDev = 1.2,
- muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x1' with expected results
- expect_equal(x1$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x1$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x1$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x1$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x1$iterations[3, ], c(9, 8, 8, 5), label = paste0("c(", paste0(x1$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x1$rejectAtLeastOne, c(0.3, 0.6, 0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x1$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.1, 0, 0.2, 0.1, 0, 0, 0.3, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0, 0.1, 0, 0.2, 0.3, 0, 0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x1$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityStop, collapse = ", "), ")"))
- expect_equal(x1$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x1$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x1$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x1$earlyStop[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x1$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x1$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[3, ], c(0.2, 0.4, 0.6, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x1$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.5, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.3, 1, 0.6, 0.3, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$selectedArms)), collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x1$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x1$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x1$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x1$expectedNumberOfSubjects, c(268.55306, 310.74423, 296.80608, 214.56859), tolerance = 1e-07, label = paste0("c(", paste0(x1$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$sampleSizes)), c(10, 1.1840544, 11.111111, 10, 10, 12.5, 10, 0.74314427, 1.9878756, 10, 0, 0, 10, 7.3350068, 25.517647, 10, 26.989766, 43.604406, 10, 0, 0, 10, 21.344686, 26.724319, 10, 2.6348908, 7.2351621, 10, 21.298615, 12.5, 10, 40, 44.643278, 10, 10, 0, 10, 33.493936, 27.945681, 10, 4.3287276, 16.089351, 10, 25.258173, 25.120998, 10, 23.39578, 28.363338, 10, 44.647888, 71.809601, 10, 62.617108, 84.693757, 10, 66.001318, 71.752151, 10, 54.740466, 55.087656), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[2, ], c(0.046651357, 0.022479034, 0.083769211, 0.082365248), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[3, ], c(0.49123587, 0.2668344, 0.64496483, 0.65218675), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x1), NA)))
- expect_output(print(x1)$show())
- invisible(capture.output(expect_error(summary(x1), NA)))
- expect_output(summary(x1)$show())
- x1CodeBased <- eval(parse(text = getObjectRCode(x1, stringWrapParagraphWidth = NULL)))
- expect_equal(x1CodeBased$iterations, x1$iterations, tolerance = 1e-07)
- expect_equal(x1CodeBased$rejectAtLeastOne, x1$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x1CodeBased$rejectedArmsPerStage, x1$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$futilityStop, x1$futilityStop, tolerance = 1e-07)
- expect_equal(x1CodeBased$futilityPerStage, x1$futilityPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$earlyStop, x1$earlyStop, tolerance = 1e-07)
- expect_equal(x1CodeBased$successPerStage, x1$successPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$selectedArms, x1$selectedArms, tolerance = 1e-07)
- expect_equal(x1CodeBased$numberOfActiveArms, x1$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x1CodeBased$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x1CodeBased$sampleSizes, x1$sampleSizes, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPowerAchieved, x1$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x1), "character")
- df <- as.data.frame(x1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x2 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "userDefined", activeArms = 4,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, adaptations = rep(TRUE, 2),
- effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x2' with expected results
- expect_equal(x2$iterations[1, ], c(10, 10), label = paste0("c(", paste0(x2$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x2$iterations[2, ], c(10, 10), label = paste0("c(", paste0(x2$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x2$iterations[3, ], c(8, 8), label = paste0("c(", paste0(x2$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x2$rejectAtLeastOne, c(0.5, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x2$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.3, 0, 0, 0, 0, 0.2, 0, 0, 0.2, 0.2, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x2$futilityStop, c(0, 0), label = paste0("c(", paste0(x2$futilityStop, collapse = ", "), ")"))
- expect_equal(x2$futilityPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x2$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x2$futilityPerStage[2, ], c(0, 0), label = paste0("c(", paste0(x2$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x2$earlyStop[1, ], c(0, 0), label = paste0("c(", paste0(x2$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x2$earlyStop[2, ], c(0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x2$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x2$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[2, ], c(0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x2$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[3, ], c(0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x2$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.2, 0, 1, 0.5, 0.3, 1, 0.2, 0.2, 1, 1, 0.8, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$selectedArms)), collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[1, ], c(4, 4), label = paste0("c(", paste0(x2$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[2, ], c(1, 1), label = paste0("c(", paste0(x2$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[3, ], c(1, 1), label = paste0("c(", paste0(x2$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x2$expectedNumberOfSubjects, c(238.96461, 281.13648), tolerance = 1e-07, label = paste0("c(", paste0(x2$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$sampleSizes)), c(10, 1.1060693, 12.5, 10, 20, 25, 10, 4.7297328, 25.346201, 10, 18.776011, 38.686485, 10, 2.8470245, 10.408309, 10, 11.298615, 0, 10, 26.795872, 25.5, 10, 3.2314462, 14.141225, 10, 35.478699, 73.75451, 10, 53.306071, 77.82771), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[2, ], c(0.064857702, 0.041878984), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[3, ], c(0.72573181, 0.45099208), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x2), NA)))
- expect_output(print(x2)$show())
- invisible(capture.output(expect_error(summary(x2), NA)))
- expect_output(summary(x2)$show())
- x2CodeBased <- eval(parse(text = getObjectRCode(x2, stringWrapParagraphWidth = NULL)))
- expect_equal(x2CodeBased$iterations, x2$iterations, tolerance = 1e-07)
- expect_equal(x2CodeBased$rejectAtLeastOne, x2$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x2CodeBased$rejectedArmsPerStage, x2$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$futilityStop, x2$futilityStop, tolerance = 1e-07)
- expect_equal(x2CodeBased$futilityPerStage, x2$futilityPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$earlyStop, x2$earlyStop, tolerance = 1e-07)
- expect_equal(x2CodeBased$successPerStage, x2$successPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$selectedArms, x2$selectedArms, tolerance = 1e-07)
- expect_equal(x2CodeBased$numberOfActiveArms, x2$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x2CodeBased$expectedNumberOfSubjects, x2$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x2CodeBased$sampleSizes, x2$sampleSizes, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPowerAchieved, x2$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x2), "character")
- df <- as.data.frame(x2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x3 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x3' with expected results
- expect_equal(x3$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x3$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x3$iterations[3, ], c(10, 9, 9, 8), label = paste0("c(", paste0(x3$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x3$rejectAtLeastOne, c(0, 0.3, 0.6, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x3$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.2, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0, 0, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x3$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityStop, collapse = ", "), ")"))
- expect_equal(x3$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x3$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x3$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x3$earlyStop[2, ], c(0, 0.1, 0.1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x3$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[2, ], c(0, 0.1, 0.1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x3$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[3, ], c(0, 0.2, 0.5, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x3$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$selectedArms)), c(1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0, 0, 1, 0.3, 0.2, 1, 0.2, 0.2, 1, 0.2, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.4, 1, 0.6, 0.6, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$selectedArms)), collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x3$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x3$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x3$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x3$expectedNumberOfSubjects, c(295.76875, 343.71408, 335.10548, 281.56474), tolerance = 1e-07, label = paste0("c(", paste0(x3$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$sampleSizes)), c(10, 1.0357205, 10, 10, 30, 33.333333, 10, 0.59871171, 1.0418812, 10, 0, 0, 10, 7.3350068, 22.965882, 10, 16.989766, 27.64836, 10, 0, 0, 10, 21.344686, 16.702699, 10, 13.17796, 20, 10, 15.323901, 2.6274327, 10, 40, 44.444444, 10, 10, 0, 10, 25.447372, 22.922435, 10, 7.2951578, 22.222222, 10, 38.282522, 25.259795, 10, 36.742398, 42.916408, 10, 46.996059, 75.888318, 10, 69.608825, 85.831349, 10, 78.881233, 70.74612, 10, 68.087084, 59.619107), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[2, ], c(0.042062266, 0.013174936, 0.075843331, 0.053971766), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[3, ], c(0.41527426, 0.27301585, 0.35639557, 0.62491311), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x3), NA)))
- expect_output(print(x3)$show())
- invisible(capture.output(expect_error(summary(x3), NA)))
- expect_output(summary(x3)$show())
- x3CodeBased <- eval(parse(text = getObjectRCode(x3, stringWrapParagraphWidth = NULL)))
- expect_equal(x3CodeBased$iterations, x3$iterations, tolerance = 1e-07)
- expect_equal(x3CodeBased$rejectAtLeastOne, x3$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x3CodeBased$rejectedArmsPerStage, x3$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$futilityStop, x3$futilityStop, tolerance = 1e-07)
- expect_equal(x3CodeBased$futilityPerStage, x3$futilityPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$earlyStop, x3$earlyStop, tolerance = 1e-07)
- expect_equal(x3CodeBased$successPerStage, x3$successPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$selectedArms, x3$selectedArms, tolerance = 1e-07)
- expect_equal(x3CodeBased$numberOfActiveArms, x3$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x3CodeBased$expectedNumberOfSubjects, x3$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x3CodeBased$sampleSizes, x3$sampleSizes, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPowerAchieved, x3$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x3), "character")
- df <- as.data.frame(x3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x4 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x4' with expected results
- expect_equal(x4$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x4$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x4$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x4$rejectAtLeastOne, c(0.4, 0.8, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x4$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0.1, 0.2, 0, 0, 0.1, 0, 0, 0.3, 0, 0.2, 0.3, 0, 0.6, 0.2, 0, 0, 0.4, 0, 0.1, 0.7, 0, 0.4, 0.6, 0, 0.7, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x4$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityStop, collapse = ", "), ")"))
- expect_equal(x4$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x4$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x4$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x4$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[3, ], c(0, 0.1, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x4$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(unlist(as.list(x4$selectedArms)), collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x4$expectedNumberOfSubjects, c(1050, 891.96665, 849.19143, 705.05343), tolerance = 1e-07, label = paste0("c(", paste0(x4$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$sampleSizes)), c(10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[2, ], c(0.0086377938, 0.22005253, 0.081022458, 0.15135806), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[3, ], c(0.17779298, 0.23451185, 0.45925582, 0.77364695), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x4), NA)))
- expect_output(print(x4)$show())
- invisible(capture.output(expect_error(summary(x4), NA)))
- expect_output(summary(x4)$show())
- x4CodeBased <- eval(parse(text = getObjectRCode(x4, stringWrapParagraphWidth = NULL)))
- expect_equal(x4CodeBased$iterations, x4$iterations, tolerance = 1e-07)
- expect_equal(x4CodeBased$rejectAtLeastOne, x4$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x4CodeBased$rejectedArmsPerStage, x4$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$futilityStop, x4$futilityStop, tolerance = 1e-07)
- expect_equal(x4CodeBased$futilityPerStage, x4$futilityPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$earlyStop, x4$earlyStop, tolerance = 1e-07)
- expect_equal(x4CodeBased$successPerStage, x4$successPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$selectedArms, x4$selectedArms, tolerance = 1e-07)
- expect_equal(x4CodeBased$numberOfActiveArms, x4$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x4CodeBased$expectedNumberOfSubjects, x4$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x4CodeBased$sampleSizes, x4$sampleSizes, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalPowerAchieved, x4$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x4), "character")
- df <- as.data.frame(x4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x5 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x5' with expected results
- expect_equal(x5$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x5$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x5$iterations[3, ], c(10, 9, 8, 8), label = paste0("c(", paste0(x5$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x5$rejectAtLeastOne, c(0.5, 0.9, 1, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x5$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.3, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.3, 0, 0.3, 0.2, 0, 0.2, 0.2, 0, 0.1, 0.3, 0, 0.1, 0.4, 0, 0.1, 0.3, 0, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x5$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityStop, collapse = ", "), ")"))
- expect_equal(x5$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x5$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x5$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x5$earlyStop[2, ], c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x5$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[2, ], c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x5$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[3, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x5$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$selectedArms)), c(1, 0.5, 0.5, 1, 0.7, 0.6, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.9, 0.7, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.6, 0.4, 1, 0.4, 0.2, 1, 0.7, 0.7, 1, 0.5, 0.4, 1, 0.4, 0.4, 1, 0.9, 0.7, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$selectedArms)), collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x5$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x5$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x5$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x5$expectedNumberOfSubjects, c(591.09538, 503.05596, 452.93301, 405.41488), tolerance = 1e-07, label = paste0("c(", paste0(x5$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$sampleSizes)), c(10, 42.50248, 47.078471, 10, 45.384313, 50.975979, 10, 10, 12.5, 10, 29.554131, 37.5, 10, 15.855942, 30, 10, 22.437029, 19.843895, 10, 72.307665, 59.768075, 10, 30.61074, 15.281075, 10, 47.430714, 50, 10, 35.976108, 53.08315, 10, 50.052941, 40.398451, 10, 31.50186, 5.7250423, 10, 60.784176, 67.078471, 10, 46.971175, 44.173288, 10, 20.632484, 31.869624, 10, 71.666731, 33.506118, 10, 83.286657, 97.078471, 10, 75.384313, 84.038156, 10, 76.496545, 72.268075, 10, 81.666731, 46.006118), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x5$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[2, ], c(0.061919533, 0.10420825, 0.16753344, 0.13874821), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[3, ], c(0.29816652, 0.52092951, 0.66819594, 0.56533632), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x5), NA)))
- expect_output(print(x5)$show())
- invisible(capture.output(expect_error(summary(x5), NA)))
- expect_output(summary(x5)$show())
- x5CodeBased <- eval(parse(text = getObjectRCode(x5, stringWrapParagraphWidth = NULL)))
- expect_equal(x5CodeBased$iterations, x5$iterations, tolerance = 1e-07)
- expect_equal(x5CodeBased$rejectAtLeastOne, x5$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x5CodeBased$rejectedArmsPerStage, x5$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$futilityStop, x5$futilityStop, tolerance = 1e-07)
- expect_equal(x5CodeBased$futilityPerStage, x5$futilityPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$earlyStop, x5$earlyStop, tolerance = 1e-07)
- expect_equal(x5CodeBased$successPerStage, x5$successPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$selectedArms, x5$selectedArms, tolerance = 1e-07)
- expect_equal(x5CodeBased$numberOfActiveArms, x5$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x5CodeBased$expectedNumberOfSubjects, x5$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x5CodeBased$sampleSizes, x5$sampleSizes, tolerance = 1e-07)
- expect_equal(x5CodeBased$conditionalPowerAchieved, x5$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x5), "character")
- df <- as.data.frame(x5)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x5)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x6 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x6' with expected results
- expect_equal(x6$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x6$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x6$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x6$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x6$iterations[3, ], c(10, 9, 7, 6), label = paste0("c(", paste0(x6$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x6$rejectAtLeastOne, c(0.4, 0.6, 0.8, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x6$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.2, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.2, 0, 0.1, 0.4, 0, 0.3, 0.5, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x6$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityStop, collapse = ", "), ")"))
- expect_equal(x6$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x6$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x6$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x6$earlyStop[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x6$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x6$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[3, ], c(0.4, 0.5, 0.5, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x6$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0, 0, 1, 0.1, 0.1, 1, 0.5, 0.4, 1, 0.1, 0, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0, 0, 1, 0.1, 0, 1, 0.4, 0.4, 1, 0.6, 0.5, 1, 0.8, 0.5, 1, 0.5, 0.3, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.7, 1, 1, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$selectedArms)), collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x6$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[2, ], c(1.3, 1.2, 1.1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x6$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[3, ], c(1.2, 1, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x6$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x6$expectedNumberOfSubjects, c(436.56282, 365.15193, 284.70045, 253.12175), tolerance = 1e-07, label = paste0("c(", paste0(x6$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$sampleSizes)), c(10, 4.7999536, 10, 10, 16.971175, 11.111111, 10, 0, 0, 10, 10, 16.666667, 10, 35.332961, 40, 10, 10, 0, 10, 21.400604, 22.595075, 10, 21.344686, 22.270265, 10, 23.218148, 30, 10, 22.202225, 23.298934, 10, 0, 0, 10, 10, 0, 10, 29.860691, 40, 10, 41.405234, 49.459866, 10, 62.809861, 31.890295, 10, 22.672359, 23.636115, 10, 73.351063, 100, 10, 73.607458, 83.869911, 10, 74.210465, 54.485369, 10, 64.017046, 62.573047), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x6$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[2, ], c(0.024687171, 0.015314975, 0.045856815, 0.050229622), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[3, ], c(0.1883251, 0.40048173, 0.51841906, 0.54348956), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x6), NA)))
- expect_output(print(x6)$show())
- invisible(capture.output(expect_error(summary(x6), NA)))
- expect_output(summary(x6)$show())
- x6CodeBased <- eval(parse(text = getObjectRCode(x6, stringWrapParagraphWidth = NULL)))
- expect_equal(x6CodeBased$iterations, x6$iterations, tolerance = 1e-07)
- expect_equal(x6CodeBased$rejectAtLeastOne, x6$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x6CodeBased$rejectedArmsPerStage, x6$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$futilityStop, x6$futilityStop, tolerance = 1e-07)
- expect_equal(x6CodeBased$futilityPerStage, x6$futilityPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$earlyStop, x6$earlyStop, tolerance = 1e-07)
- expect_equal(x6CodeBased$successPerStage, x6$successPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$selectedArms, x6$selectedArms, tolerance = 1e-07)
- expect_equal(x6CodeBased$numberOfActiveArms, x6$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x6CodeBased$expectedNumberOfSubjects, x6$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x6CodeBased$sampleSizes, x6$sampleSizes, tolerance = 1e-07)
- expect_equal(x6CodeBased$conditionalPowerAchieved, x6$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x6), "character")
- df <- as.data.frame(x6)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x6)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x7 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x7' with expected results
- expect_equal(x7$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x7$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x7$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x7$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x7$iterations[3, ], c(9, 8, 8, 5), label = paste0("c(", paste0(x7$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x7$rejectAtLeastOne, c(0.2, 0.4, 0.7, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x7$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.2, 0.1, 0, 0, 0.3, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.2, 0.2, 0, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x7$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityStop, collapse = ", "), ")"))
- expect_equal(x7$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x7$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x7$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x7$earlyStop[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x7$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x7$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[3, ], c(0.1, 0.2, 0.5, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x7$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.5, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.3, 1, 0.6, 0.3, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$selectedArms)), collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x7$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x7$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x7$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x7$expectedNumberOfSubjects, c(222.21727, 277.8712, 297.53775, 227.3405), tolerance = 1e-07, label = paste0("c(", paste0(x7$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$sampleSizes)), c(10, 1.1840544, 1.315616, 10, 10, 12.5, 10, 0.74314427, 0.92893034, 10, 0, 0, 10, 7.3350068, 8.1500075, 10, 26.989766, 33.737207, 10, 0, 0, 10, 21.344686, 40, 10, 2.6348908, 2.9276564, 10, 21.298615, 12.5, 10, 40, 50, 10, 10, 0, 10, 33.493936, 33.674217, 10, 4.3287276, 5.4109095, 10, 25.258173, 21.280514, 10, 23.39578, 27.859565, 10, 44.647888, 46.067497, 10, 62.617108, 64.148116, 10, 66.001318, 72.209444, 10, 54.740466, 67.859565), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x7$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[2, ], c(0.046651357, 0.022479034, 0.083769211, 0.082365248), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[3, ], c(0.39772697, 0.18083546, 0.60828997, 0.66318671), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x7), NA)))
- expect_output(print(x7)$show())
- invisible(capture.output(expect_error(summary(x7), NA)))
- expect_output(summary(x7)$show())
- x7CodeBased <- eval(parse(text = getObjectRCode(x7, stringWrapParagraphWidth = NULL)))
- expect_equal(x7CodeBased$iterations, x7$iterations, tolerance = 1e-07)
- expect_equal(x7CodeBased$rejectAtLeastOne, x7$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x7CodeBased$rejectedArmsPerStage, x7$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$futilityStop, x7$futilityStop, tolerance = 1e-07)
- expect_equal(x7CodeBased$futilityPerStage, x7$futilityPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$earlyStop, x7$earlyStop, tolerance = 1e-07)
- expect_equal(x7CodeBased$successPerStage, x7$successPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$selectedArms, x7$selectedArms, tolerance = 1e-07)
- expect_equal(x7CodeBased$numberOfActiveArms, x7$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x7CodeBased$expectedNumberOfSubjects, x7$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x7CodeBased$sampleSizes, x7$sampleSizes, tolerance = 1e-07)
- expect_equal(x7CodeBased$conditionalPowerAchieved, x7$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x7), "character")
- df <- as.data.frame(x7)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x7)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x8 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
- typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x8' with expected results
- expect_equal(x8$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x8$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x8$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x8$rejectAtLeastOne, c(0.3, 0.6, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x8$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0.2, 0, 0, 0.2, 0.3, 0, 0, 0, 0.1, 0, 0.2, 0, 0.4, 0.2, 0, 0.7, 0.2, 0, 0.2, 0.1, 0.1, 0.2, 0.3, 0, 0.7, 0.3, 0, 0.8, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x8$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityStop, collapse = ", "), ")"))
- expect_equal(x8$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x8$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x8$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x8$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(unlist(as.list(x8$selectedArms)), collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x8$expectedNumberOfSubjects, c(1050, 914.65115, 996.33236, 1027.6565), tolerance = 1e-07, label = paste0("c(", paste0(x8$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$sampleSizes)), c(10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x8$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[2, ], c(0.015572779, 0.22941785, 0.084615364, 0.1668833), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[3, ], c(0.10350918, 0.24229761, 0.63483372, 0.79913622), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x8), NA)))
- expect_output(print(x8)$show())
- invisible(capture.output(expect_error(summary(x8), NA)))
- expect_output(summary(x8)$show())
- x8CodeBased <- eval(parse(text = getObjectRCode(x8, stringWrapParagraphWidth = NULL)))
- expect_equal(x8CodeBased$iterations, x8$iterations, tolerance = 1e-07)
- expect_equal(x8CodeBased$rejectAtLeastOne, x8$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x8CodeBased$rejectedArmsPerStage, x8$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$futilityStop, x8$futilityStop, tolerance = 1e-07)
- expect_equal(x8CodeBased$futilityPerStage, x8$futilityPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$earlyStop, x8$earlyStop, tolerance = 1e-07)
- expect_equal(x8CodeBased$successPerStage, x8$successPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$selectedArms, x8$selectedArms, tolerance = 1e-07)
- expect_equal(x8CodeBased$numberOfActiveArms, x8$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x8CodeBased$expectedNumberOfSubjects, x8$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x8CodeBased$sampleSizes, x8$sampleSizes, tolerance = 1e-07)
- expect_equal(x8CodeBased$conditionalPowerAchieved, x8$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x8), "character")
- df <- as.data.frame(x8)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x9 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
- typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x9' with expected results
- expect_equal(x9$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x9$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x9$iterations[3, ], c(10, 9, 8, 7), label = paste0("c(", paste0(x9$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x9$rejectAtLeastOne, c(0.4, 0.6, 0.7, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x9$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$rejectedArmsPerStage)), c(0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.3, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0.5, 0, 0, 0.3, 0, 0, 0.2, 0.1, 0, 0.1, 0.1, 0, 0.1, 0, 0.1, 0.5, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x9$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityStop, collapse = ", "), ")"))
- expect_equal(x9$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x9$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x9$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x9$earlyStop[2, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x9$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[2, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x9$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x9$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$selectedArms)), c(1, 0.5, 0.5, 1, 0.7, 0.6, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.9, 0.7, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.6, 0.4, 1, 0.4, 0.1, 1, 0.7, 0.7, 1, 0.5, 0.4, 1, 0.4, 0.4, 1, 0.9, 0.6, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$selectedArms)), collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x9$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x9$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x9$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x9$expectedNumberOfSubjects, c(541.86022, 465.03543, 438.85623, 427.93855), tolerance = 1e-07, label = paste0("c(", paste0(x9$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$sampleSizes)), c(10, 42.315846, 42.315846, 10, 43.044196, 41.478749, 10, 10, 12.5, 10, 28.887554, 41.267934, 10, 15.358913, 15.358913, 10, 21.683959, 24.093288, 10, 70.857557, 63.571946, 10, 27.933797, 39.905424, 10, 46.61779, 46.61779, 10, 34.631951, 38.479946, 10, 49.194842, 36.493552, 10, 31.168408, 1.6691539, 10, 59.660857, 59.660857, 10, 44.698358, 43.316707, 10, 19.566345, 24.457932, 10, 67.989758, 54.271083, 10, 81.976703, 81.976703, 10, 72.029232, 73.684344, 10, 74.809372, 68.511715, 10, 77.989758, 68.556797), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x9$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[2, ], c(0.085169097, 0.1203719, 0.19239671, 0.15260753), tolerance = 1e-07, label = paste0("c(", paste0(x9$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[3, ], c(0.20442999, 0.2985599, 0.51072411, 0.55234699), tolerance = 1e-07, label = paste0("c(", paste0(x9$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x9), NA)))
- expect_output(print(x9)$show())
- invisible(capture.output(expect_error(summary(x9), NA)))
- expect_output(summary(x9)$show())
- x9CodeBased <- eval(parse(text = getObjectRCode(x9, stringWrapParagraphWidth = NULL)))
- expect_equal(x9CodeBased$iterations, x9$iterations, tolerance = 1e-07)
- expect_equal(x9CodeBased$rejectAtLeastOne, x9$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x9CodeBased$rejectedArmsPerStage, x9$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$futilityStop, x9$futilityStop, tolerance = 1e-07)
- expect_equal(x9CodeBased$futilityPerStage, x9$futilityPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$earlyStop, x9$earlyStop, tolerance = 1e-07)
- expect_equal(x9CodeBased$successPerStage, x9$successPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$selectedArms, x9$selectedArms, tolerance = 1e-07)
- expect_equal(x9CodeBased$numberOfActiveArms, x9$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x9CodeBased$expectedNumberOfSubjects, x9$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x9CodeBased$sampleSizes, x9$sampleSizes, tolerance = 1e-07)
- expect_equal(x9CodeBased$conditionalPowerAchieved, x9$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x9), "character")
- df <- as.data.frame(x9)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x9)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x10 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
- typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x10' with expected results
- expect_equal(x10$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x10$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x10$iterations[2, ], c(7, 8, 5, 9), label = paste0("c(", paste0(x10$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x10$iterations[3, ], c(7, 6, 4, 4), label = paste0("c(", paste0(x10$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x10$rejectAtLeastOne, c(0.2, 0.4, 0.2, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x10$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0.1, 0.1, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x10$futilityStop, c(0.3, 0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x10$futilityStop, collapse = ", "), ")"))
- expect_equal(x10$futilityPerStage[1, ], c(0.3, 0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x10$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x10$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x10$earlyStop[1, ], c(0.3, 0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x10$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x10$earlyStop[2, ], c(0, 0.2, 0.1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x10$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[2, ], c(0, 0.2, 0.1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x10$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[3, ], c(0.2, 0.2, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x10$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$selectedArms)), c(1, 0.1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.1, 0, 1, 0.2, 0.2, 1, 0.2, 0, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0, 0, 1, 0.2, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.4, 0.3, 1, 0.3, 0.1, 1, 0.7, 0.7, 1, 0.8, 0.6, 1, 0.5, 0.4, 1, 0.9, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$selectedArms)), collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x10$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[2, ], c(1.2857143, 1.125, 1.2, 1.1111111), tolerance = 1e-07, label = paste0("c(", paste0(x10$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[3, ], c(1.2857143, 1.1666667, 1.25, 1.25), tolerance = 1e-07, label = paste0("c(", paste0(x10$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x10$expectedNumberOfSubjects, c(225.54374, 222.86662, 137.52897, 198.07751), tolerance = 1e-07, label = paste0("c(", paste0(x10$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$sampleSizes)), c(10, 5.7796177, 5.7796177, 10, 0, 0, 10, 0, 0, 10, 21.972849, 49.43891, 10, 18.318062, 18.318062, 10, 4.015823, 0, 10, 19.919121, 24.898901, 10, 4.2855233, 0, 10, 4.0944014, 4.0944014, 10, 25.284305, 32.792226, 10, 0, 0, 10, 13.080039, 4.4300867, 10, 40.432794, 40.432794, 10, 33.32367, 44.431559, 10, 42.475692, 28.104858, 10, 18.985094, 14.869399, 10, 56.76351, 56.76351, 10, 50.123797, 60.557119, 10, 45.125964, 31.417698, 10, 51.714883, 53.868997), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x10$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[2, ], c(0.051011725, 0.14528092, 0.099325934, 0.10008765), tolerance = 1e-07, label = paste0("c(", paste0(x10$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[3, ], c(0.1199627, 0.35325827, 0.33382798, 0.10956309), tolerance = 1e-07, label = paste0("c(", paste0(x10$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x10), NA)))
- expect_output(print(x10)$show())
- invisible(capture.output(expect_error(summary(x10), NA)))
- expect_output(summary(x10)$show())
- x10CodeBased <- eval(parse(text = getObjectRCode(x10, stringWrapParagraphWidth = NULL)))
- expect_equal(x10CodeBased$iterations, x10$iterations, tolerance = 1e-07)
- expect_equal(x10CodeBased$rejectAtLeastOne, x10$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x10CodeBased$rejectedArmsPerStage, x10$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$futilityStop, x10$futilityStop, tolerance = 1e-07)
- expect_equal(x10CodeBased$futilityPerStage, x10$futilityPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$earlyStop, x10$earlyStop, tolerance = 1e-07)
- expect_equal(x10CodeBased$successPerStage, x10$successPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$selectedArms, x10$selectedArms, tolerance = 1e-07)
- expect_equal(x10CodeBased$numberOfActiveArms, x10$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x10CodeBased$expectedNumberOfSubjects, x10$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x10CodeBased$sampleSizes, x10$sampleSizes, tolerance = 1e-07)
- expect_equal(x10CodeBased$conditionalPowerAchieved, x10$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x10), "character")
- df <- as.data.frame(x10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x11 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x11' with expected results
- expect_equal(x11$iterations[1, ], c(10, 10, 10), label = paste0("c(", paste0(x11$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x11$iterations[2, ], c(9, 6, 6), label = paste0("c(", paste0(x11$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x11$iterations[3, ], c(9, 6, 6), label = paste0("c(", paste0(x11$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x11$rejectAtLeastOne, c(0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x11$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x11$futilityStop, c(0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x11$futilityStop, collapse = ", "), ")"))
- expect_equal(x11$futilityPerStage[1, ], c(0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x11$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x11$futilityPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x11$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x11$earlyStop[1, ], c(0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x11$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x11$earlyStop[2, ], c(0, 0, 0), label = paste0("c(", paste0(x11$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x11$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x11$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[3, ], c(0, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x11$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.3, 0.3, 1, 0.3, 0.2, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.9, 0.9, 1, 0.6, 0.6, 1, 0.6, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$selectedArms)), collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0("c(", paste0(x11$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0("c(", paste0(x11$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[3, ], c(1, 0.83333333, 0.66666667), tolerance = 1e-07, label = paste0("c(", paste0(x11$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x11$expectedNumberOfSubjects, c(293.83569, 240.03958, 175.41029), tolerance = 1e-07, label = paste0("c(", paste0(x11$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$sampleSizes)), c(10, 1.428489, 11.111111, 10, 16.666667, 16.666667, 10, 10.322237, 0, 10, 9.8699583, 33.333333, 10, 41.973847, 33.333333, 10, 21.511686, 16.666667, 10, 15.186109, 22.222222, 10, 6.5876644, 9.8048039, 10, 17.33069, 22.310249, 10, 17.556106, 24.756944, 10, 16.666667, 16.666667, 10, 2.0321899, 14.334858, 10, 44.040662, 91.42361, 10, 81.894844, 76.471471, 10, 51.196803, 53.311774), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x11$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[2, ], c(0.038698548, 0.10704476, 0.043430379), tolerance = 1e-07, label = paste0("c(", paste0(x11$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[3, ], c(0.30869297, 0.23212739, 0.40151299), tolerance = 1e-07, label = paste0("c(", paste0(x11$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x11), NA)))
- expect_output(print(x11)$show())
- invisible(capture.output(expect_error(summary(x11), NA)))
- expect_output(summary(x11)$show())
- x11CodeBased <- eval(parse(text = getObjectRCode(x11, stringWrapParagraphWidth = NULL)))
- expect_equal(x11CodeBased$iterations, x11$iterations, tolerance = 1e-07)
- expect_equal(x11CodeBased$rejectAtLeastOne, x11$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x11CodeBased$rejectedArmsPerStage, x11$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$futilityStop, x11$futilityStop, tolerance = 1e-07)
- expect_equal(x11CodeBased$futilityPerStage, x11$futilityPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$earlyStop, x11$earlyStop, tolerance = 1e-07)
- expect_equal(x11CodeBased$successPerStage, x11$successPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$selectedArms, x11$selectedArms, tolerance = 1e-07)
- expect_equal(x11CodeBased$numberOfActiveArms, x11$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x11CodeBased$expectedNumberOfSubjects, x11$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x11CodeBased$sampleSizes, x11$sampleSizes, tolerance = 1e-07)
- expect_equal(x11CodeBased$conditionalPowerAchieved, x11$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x11), "character")
- df <- as.data.frame(x11)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x11)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x12 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x12' with expected results
- expect_equal(x12$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x12$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x12$iterations[2, ], c(10, 6, 8, 8), label = paste0("c(", paste0(x12$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x12$iterations[3, ], c(8, 5, 1, 2), label = paste0("c(", paste0(x12$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x12$rejectAtLeastOne, c(0.3, 0.1, 0.7, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x12$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0, 0.1, 0, 0.2, 0.3, 0, 0.1, 0.3, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x12$futilityStop, c(0, 0.4, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x12$futilityStop, collapse = ", "), ")"))
- expect_equal(x12$futilityPerStage[1, ], c(0, 0.4, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x12$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x12$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x12$earlyStop[1, ], c(0, 0.4, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x12$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x12$earlyStop[2, ], c(0.2, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x12$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[2, ], c(0.2, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x12$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[3, ], c(0.1, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x12$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0, 0, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0, 1, 0.3, 0.2, 1, 0.5, 0.3, 1, 0.2, 0.1, 1, 0.6, 0.1, 1, 0.4, 0, 1, 1, 0.8, 1, 0.6, 0.5, 1, 0.8, 0.1, 1, 0.8, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$selectedArms)), collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x12$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x12$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x12$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x12$expectedNumberOfSubjects, c(270.86167, 201.58944, 127.72687, 185.63922), tolerance = 1e-07, label = paste0("c(", paste0(x12$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$sampleSizes)), c(10, 1.1167748, 12.5, 10, 8.9578499, 20, 10, 0.5, 0, 10, 0, 0, 10, 6.7277808, 32.819107, 10, 6.3724427, 20, 10, 0, 0, 10, 12.5, 0, 10, 2.4005123, 12.5, 10, 12.766635, 29.774077, 10, 11.503905, 0, 10, 27.658054, 100, 10, 28.865098, 31.331731, 10, 23.415877, 20, 10, 24.075387, 100, 10, 19.616461, 0, 10, 39.110166, 89.150838, 10, 51.512805, 89.774077, 10, 36.079292, 100, 10, 59.774515, 100), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x12$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[2, ], c(0.064552587, 0.074113563, 0.13271614, 0.12195746), tolerance = 1e-07, label = paste0("c(", paste0(x12$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[3, ], c(0.41775137, 0.42792704, 0.6049542, 0.13870598), tolerance = 1e-07, label = paste0("c(", paste0(x12$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x12), NA)))
- expect_output(print(x12)$show())
- invisible(capture.output(expect_error(summary(x12), NA)))
- expect_output(summary(x12)$show())
- x12CodeBased <- eval(parse(text = getObjectRCode(x12, stringWrapParagraphWidth = NULL)))
- expect_equal(x12CodeBased$iterations, x12$iterations, tolerance = 1e-07)
- expect_equal(x12CodeBased$rejectAtLeastOne, x12$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x12CodeBased$rejectedArmsPerStage, x12$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$futilityStop, x12$futilityStop, tolerance = 1e-07)
- expect_equal(x12CodeBased$futilityPerStage, x12$futilityPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$earlyStop, x12$earlyStop, tolerance = 1e-07)
- expect_equal(x12CodeBased$successPerStage, x12$successPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$selectedArms, x12$selectedArms, tolerance = 1e-07)
- expect_equal(x12CodeBased$numberOfActiveArms, x12$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x12CodeBased$expectedNumberOfSubjects, x12$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x12CodeBased$sampleSizes, x12$sampleSizes, tolerance = 1e-07)
- expect_equal(x12CodeBased$conditionalPowerAchieved, x12$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x12), "character")
- df <- as.data.frame(x12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x13 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "userDefined", activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, adaptations = rep(TRUE, 2),
- effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4), intersectionTest = "Sidak",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x13' with expected results
- expect_equal(x13$iterations[1, ], c(10, 10), label = paste0("c(", paste0(x13$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x13$iterations[2, ], c(10, 10), label = paste0("c(", paste0(x13$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x13$iterations[3, ], c(7, 7), label = paste0("c(", paste0(x13$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x13$rejectAtLeastOne, c(0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x13$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x13$futilityStop, c(0, 0), label = paste0("c(", paste0(x13$futilityStop, collapse = ", "), ")"))
- expect_equal(x13$futilityPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x13$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x13$futilityPerStage[2, ], c(0, 0), label = paste0("c(", paste0(x13$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x13$earlyStop[1, ], c(0, 0), label = paste0("c(", paste0(x13$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x13$earlyStop[2, ], c(0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x13$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x13$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[2, ], c(0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x13$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[3, ], c(0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x13$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.5, 0.4, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.2, 1, 0.2, 0.1, 1, 1, 0.7, 1, 1, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$selectedArms)), collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[1, ], c(4, 4), label = paste0("c(", paste0(x13$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[2, ], c(1, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x13$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[3, ], c(1, 1), label = paste0("c(", paste0(x13$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x13$expectedNumberOfSubjects, c(238.16649, 275.50348), tolerance = 1e-07, label = paste0("c(", paste0(x13$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$sampleSizes)), c(10, 1.0395374, 14.285714, 10, 3.9539792, 11.199547, 10, 4.4634729, 31.899994, 10, 34.913911, 57.142857, 10, 2.5722467, 14.285714, 10, 4.8326382, 6.9814836, 10, 23.677991, 28.571429, 10, 10.117751, 8.8667681, 10, 31.753247, 89.042851, 10, 53.818279, 84.190656), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(x13$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[2, ], c(0.095374468, 0.077588778), tolerance = 1e-07, label = paste0("c(", paste0(x13$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[3, ], c(0.56669649, 0.49770257), tolerance = 1e-07, label = paste0("c(", paste0(x13$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x13), NA)))
- expect_output(print(x13)$show())
- invisible(capture.output(expect_error(summary(x13), NA)))
- expect_output(summary(x13)$show())
- x13CodeBased <- eval(parse(text = getObjectRCode(x13, stringWrapParagraphWidth = NULL)))
- expect_equal(x13CodeBased$iterations, x13$iterations, tolerance = 1e-07)
- expect_equal(x13CodeBased$rejectAtLeastOne, x13$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x13CodeBased$rejectedArmsPerStage, x13$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$futilityStop, x13$futilityStop, tolerance = 1e-07)
- expect_equal(x13CodeBased$futilityPerStage, x13$futilityPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$earlyStop, x13$earlyStop, tolerance = 1e-07)
- expect_equal(x13CodeBased$successPerStage, x13$successPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$selectedArms, x13$selectedArms, tolerance = 1e-07)
- expect_equal(x13CodeBased$numberOfActiveArms, x13$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x13CodeBased$expectedNumberOfSubjects, x13$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x13CodeBased$sampleSizes, x13$sampleSizes, tolerance = 1e-07)
- expect_equal(x13CodeBased$conditionalPowerAchieved, x13$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x13), "character")
- df <- as.data.frame(x13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x14 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x14' with expected results
- expect_equal(x14$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x14$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x14$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x14$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x14$iterations[3, ], c(9, 9, 6, 7), label = paste0("c(", paste0(x14$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x14$rejectAtLeastOne, c(0.1, 0, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x14$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x14$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityStop, collapse = ", "), ")"))
- expect_equal(x14$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x14$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x14$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x14$earlyStop[2, ], c(0.1, 0.1, 0.4, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x14$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[2, ], c(0.1, 0.1, 0.4, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x14$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[3, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x14$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.4, 0.3, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.2, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 0.6, 1, 1, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$selectedArms)), collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x14$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[2, ], c(1, 0.9, 0.8, 1), tolerance = 1e-07, label = paste0("c(", paste0(x14$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x14$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x14$expectedNumberOfSubjects, c(302.82831, 359.55539, 205.66054, 326.21609), tolerance = 1e-07, label = paste0("c(", paste0(x14$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$sampleSizes)), c(10, 0.96871141, 11.111111, 10, 4.382328, 11.111111, 10, 0.4, 0, 10, 30, 42.857143, 10, 6.7277808, 29.172539, 10, 33.823466, 44.444444, 10, 10, 16.666667, 10, 10, 0, 10, 12.834638, 22.222222, 10, 19.792403, 33.249006, 10, 14.088095, 16.666667, 10, 12.962323, 28.571429, 10, 24.585127, 27.825125, 10, 6.8553955, 11.111111, 10, 16.145786, 28.660644, 10, 22.561443, 17.977538, 10, 45.116257, 90.330997, 10, 64.853592, 99.915673, 10, 40.633881, 61.993977, 10, 75.523767, 89.406109), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x14$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[2, ], c(0.054394525, 0.030769719, 0.1336666, 0.07472066), tolerance = 1e-07, label = paste0("c(", paste0(x14$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[3, ], c(0.39787587, 0.27550431, 0.64928935, 0.24074486), tolerance = 1e-07, label = paste0("c(", paste0(x14$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x14), NA)))
- expect_output(print(x14)$show())
- invisible(capture.output(expect_error(summary(x14), NA)))
- expect_output(summary(x14)$show())
- x14CodeBased <- eval(parse(text = getObjectRCode(x14, stringWrapParagraphWidth = NULL)))
- expect_equal(x14CodeBased$iterations, x14$iterations, tolerance = 1e-07)
- expect_equal(x14CodeBased$rejectAtLeastOne, x14$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x14CodeBased$rejectedArmsPerStage, x14$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$futilityStop, x14$futilityStop, tolerance = 1e-07)
- expect_equal(x14CodeBased$futilityPerStage, x14$futilityPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$earlyStop, x14$earlyStop, tolerance = 1e-07)
- expect_equal(x14CodeBased$successPerStage, x14$successPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$selectedArms, x14$selectedArms, tolerance = 1e-07)
- expect_equal(x14CodeBased$numberOfActiveArms, x14$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x14CodeBased$expectedNumberOfSubjects, x14$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x14CodeBased$sampleSizes, x14$sampleSizes, tolerance = 1e-07)
- expect_equal(x14CodeBased$conditionalPowerAchieved, x14$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x14), "character")
- df <- as.data.frame(x14)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x14)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x15 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x15' with expected results
- expect_equal(x15$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x15$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x15$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x15$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x15$iterations[3, ], c(10, 8, 8, 10), label = paste0("c(", paste0(x15$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x15$rejectAtLeastOne, c(0.1, 0.6, 0.9, 1), tolerance = 1e-07, label = paste0("c(", paste0(x15$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.2, 0, 0.1, 0.2, 0, 0, 0, 0, 0.2, 0.1, 0, 0.3, 0.3, 0, 0.3, 0.4, 0, 0.1, 0, 0, 0.3, 0.1, 0, 0.5, 0.2, 0.1, 0.4, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x15$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityStop, collapse = ", "), ")"))
- expect_equal(x15$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x15$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x15$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x15$earlyStop[2, ], c(0, 0.2, 0.2, 0), tolerance = 1e-07, label = paste0("c(", paste0(x15$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[2, ], c(0, 0.2, 0.2, 0), tolerance = 1e-07, label = paste0("c(", paste0(x15$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[3, ], c(0, 0, 0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x15$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$selectedArms)), c(1, 0.6, 0.6, 1, 0.6, 0.5, 1, 0.2, 0.1, 1, 0.7, 0.5, 1, 0.7, 0.6, 1, 0.8, 0.7, 1, 0.7, 0.7, 1, 0.7, 0.7, 1, 0.7, 0.7, 1, 0.8, 0.7, 1, 0.7, 0.7, 1, 0.9, 0.9, 1, 0.6, 0.6, 1, 0.6, 0.5, 1, 0.7, 0.6, 1, 0.8, 0.8, 1, 1, 1, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$selectedArms)), collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x15$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[2, ], c(2.6, 2.8, 2.3, 3.1), tolerance = 1e-07, label = paste0("c(", paste0(x15$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[3, ], c(2.5, 3, 2.625, 2.9), tolerance = 1e-07, label = paste0("c(", paste0(x15$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x15$expectedNumberOfSubjects, c(690.38911, 619.77858, 554.02061, 670.88154), tolerance = 1e-07, label = paste0("c(", paste0(x15$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$sampleSizes)), c(10, 54.180167, 50.4, 10, 52.125518, 50.5, 10, 14.569332, 12.5, 10, 64.800747, 25.135561, 10, 65.454083, 50.4, 10, 63.913266, 75.5, 10, 64.569332, 62.866861, 10, 64.800747, 45.135561, 10, 69.120607, 60.4, 10, 63.913266, 75.5, 10, 64.569332, 62.866861, 10, 84.800747, 55.535561, 10, 55.454083, 50.4, 10, 43.913266, 50.5, 10, 64.569332, 50.366861, 10, 74.800747, 45.535561, 10, 94.180167, 90.4, 10, 73.913266, 88, 10, 84.569332, 75.366861, 10, 94.800747, 65.535561), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x15$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[2, ], c(0.086326519, 0.21541695, 0.13871639, 0.19252038), tolerance = 1e-07, label = paste0("c(", paste0(x15$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[3, ], c(0.19907656, 0.37086672, 0.52811383, 0.57866018), tolerance = 1e-07, label = paste0("c(", paste0(x15$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x15), NA)))
- expect_output(print(x15)$show())
- invisible(capture.output(expect_error(summary(x15), NA)))
- expect_output(summary(x15)$show())
- x15CodeBased <- eval(parse(text = getObjectRCode(x15, stringWrapParagraphWidth = NULL)))
- expect_equal(x15CodeBased$iterations, x15$iterations, tolerance = 1e-07)
- expect_equal(x15CodeBased$rejectAtLeastOne, x15$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x15CodeBased$rejectedArmsPerStage, x15$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$futilityStop, x15$futilityStop, tolerance = 1e-07)
- expect_equal(x15CodeBased$futilityPerStage, x15$futilityPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$earlyStop, x15$earlyStop, tolerance = 1e-07)
- expect_equal(x15CodeBased$successPerStage, x15$successPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$selectedArms, x15$selectedArms, tolerance = 1e-07)
- expect_equal(x15CodeBased$numberOfActiveArms, x15$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x15CodeBased$expectedNumberOfSubjects, x15$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x15CodeBased$sampleSizes, x15$sampleSizes, tolerance = 1e-07)
- expect_equal(x15CodeBased$conditionalPowerAchieved, x15$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x15), "character")
- df <- as.data.frame(x15)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x15)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x16 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Simes",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x16' with expected results
- expect_equal(x16$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x16$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x16$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x16$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x16$iterations[3, ], c(8, 8, 8, 7), label = paste0("c(", paste0(x16$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x16$rejectAtLeastOne, c(0.1, 0.5, 0.7, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x16$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0.2, 0.1, 0, 0.1, 0, 0.1, 0.2, 0.2, 0, 0.1, 0.4, 0.1, 0.6, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x16$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityStop, collapse = ", "), ")"))
- expect_equal(x16$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x16$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x16$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x16$earlyStop[2, ], c(0.2, 0.2, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x16$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[2, ], c(0.2, 0.2, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x16$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[3, ], c(0.1, 0.1, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x16$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$selectedArms)), c(1, 0.2, 0.1, 1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.3, 0.2, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.5, 0.3, 1, 0.8, 0.8, 1, 0.7, 0.7, 1, 0.5, 0.5, 1, 0.7, 0.4, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$selectedArms)), collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x16$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[2, ], c(1.6, 1.6, 1.6, 1.8), tolerance = 1e-07, label = paste0("c(", paste0(x16$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[3, ], c(1.875, 2, 1.75, 1.8571429), tolerance = 1e-07, label = paste0("c(", paste0(x16$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x16$expectedNumberOfSubjects, c(485.19749, 377.01763, 431.09127, 345.60572), tolerance = 1e-07, label = paste0("c(", paste0(x16$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$sampleSizes)), c(10, 20, 12.5, 10, 42.387791, 51, 10, 34.430263, 50, 10, 5.1691192, 14.285714, 10, 23.043067, 37.5, 10, 20, 25, 10, 21.806036, 11.497164, 10, 28.635967, 34.757362, 10, 25.356096, 37.5, 10, 4.5550484, 1.5787961, 10, 36.82395, 37.5, 10, 42.851335, 17.605103, 10, 68.399163, 100, 10, 46.942839, 52.578796, 10, 31.806941, 48.997164, 10, 50.953751, 18.295116, 10, 68.399163, 100, 10, 56.942839, 65.078796, 10, 68.630891, 86.497164, 10, 73.805086, 49.614505), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x16$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[2, ], c(0.014811608, 0.14052361, 0.084441455, 0.088580327), tolerance = 1e-07, label = paste0("c(", paste0(x16$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[3, ], c(0.16524243, 0.38443342, 0.48058247, 0.6510419), tolerance = 1e-07, label = paste0("c(", paste0(x16$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x16), NA)))
- expect_output(print(x16)$show())
- invisible(capture.output(expect_error(summary(x16), NA)))
- expect_output(summary(x16)$show())
- x16CodeBased <- eval(parse(text = getObjectRCode(x16, stringWrapParagraphWidth = NULL)))
- expect_equal(x16CodeBased$iterations, x16$iterations, tolerance = 1e-07)
- expect_equal(x16CodeBased$rejectAtLeastOne, x16$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x16CodeBased$rejectedArmsPerStage, x16$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$futilityStop, x16$futilityStop, tolerance = 1e-07)
- expect_equal(x16CodeBased$futilityPerStage, x16$futilityPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$earlyStop, x16$earlyStop, tolerance = 1e-07)
- expect_equal(x16CodeBased$successPerStage, x16$successPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$selectedArms, x16$selectedArms, tolerance = 1e-07)
- expect_equal(x16CodeBased$numberOfActiveArms, x16$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x16CodeBased$expectedNumberOfSubjects, x16$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x16CodeBased$sampleSizes, x16$sampleSizes, tolerance = 1e-07)
- expect_equal(x16CodeBased$conditionalPowerAchieved, x16$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x16), "character")
- df <- as.data.frame(x16)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x16)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x17 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Simes",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x17' with expected results
- expect_equal(x17$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x17$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x17$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x17$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x17$iterations[3, ], c(8, 9, 5, 6), label = paste0("c(", paste0(x17$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x17$rejectAtLeastOne, c(0.3, 0.2, 0.9, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x17$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0.2, 0, 0, 0.1, 0.4, 0, 0.2, 0, 0, 0, 0.1, 0, 0.1, 0, 0.2, 0.3, 0.1, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x17$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityStop, collapse = ", "), ")"))
- expect_equal(x17$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x17$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x17$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x17$earlyStop[2, ], c(0.2, 0.1, 0.5, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x17$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[2, ], c(0.2, 0.1, 0.5, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x17$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[3, ], c(0.3, 0.2, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x17$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.4, 0.3, 1, 0.4, 0.2, 1, 0, 0, 1, 0.2, 0.1, 1, 0.2, 0.1, 1, 0.3, 0.2, 1, 0.6, 0.5, 1, 0.3, 0.1, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.6, 0.1, 1, 0.6, 0.4, 1, 1, 0.8, 1, 1, 0.9, 1, 1, 0.5, 1, 1, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$selectedArms)), collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x17$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[2, ], c(1.1, 1.2, 1.3, 1.2), tolerance = 1e-07, label = paste0("c(", paste0(x17$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[3, ], c(1.125, 1, 1.4, 1), tolerance = 1e-07, label = paste0("c(", paste0(x17$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x17$expectedNumberOfSubjects, c(328.39002, 302.69421, 285.23022, 240.4545), tolerance = 1e-07, label = paste0("c(", paste0(x17$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$sampleSizes)), c(10, 4.0457324, 12.5, 10, 19.967039, 22.222222, 10, 10, 20, 10, 10, 0, 10, 19.695361, 37.5, 10, 26.51119, 22.222222, 10, 0, 0, 10, 13.162215, 5.2861403, 10, 12.866081, 12.5, 10, 12.191217, 7.912455, 10, 34.361222, 100, 10, 22.260169, 4.5719555, 10, 25.175673, 50, 10, 13.444855, 20.228255, 10, 23.167319, 20, 10, 26.747723, 42.182062, 10, 56.607175, 87.5, 10, 55.457645, 66.439578, 10, 47.701679, 100, 10, 59.007892, 46.754018), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x17$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[2, ], c(0.023398344, 0.099222073, 0.15711506, 0.067612991), tolerance = 1e-07, label = paste0("c(", paste0(x17$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[3, ], c(0.1871272, 0.27439376, 0.15636561, 0.58056032), tolerance = 1e-07, label = paste0("c(", paste0(x17$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x17), NA)))
- expect_output(print(x17)$show())
- invisible(capture.output(expect_error(summary(x17), NA)))
- expect_output(summary(x17)$show())
- x17CodeBased <- eval(parse(text = getObjectRCode(x17, stringWrapParagraphWidth = NULL)))
- expect_equal(x17CodeBased$iterations, x17$iterations, tolerance = 1e-07)
- expect_equal(x17CodeBased$rejectAtLeastOne, x17$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x17CodeBased$rejectedArmsPerStage, x17$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$futilityStop, x17$futilityStop, tolerance = 1e-07)
- expect_equal(x17CodeBased$futilityPerStage, x17$futilityPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$earlyStop, x17$earlyStop, tolerance = 1e-07)
- expect_equal(x17CodeBased$successPerStage, x17$successPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$selectedArms, x17$selectedArms, tolerance = 1e-07)
- expect_equal(x17CodeBased$numberOfActiveArms, x17$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x17CodeBased$expectedNumberOfSubjects, x17$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x17CodeBased$sampleSizes, x17$sampleSizes, tolerance = 1e-07)
- expect_equal(x17CodeBased$conditionalPowerAchieved, x17$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x17), "character")
- df <- as.data.frame(x17)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x17)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x18 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Simes",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x18' with expected results
- expect_equal(x18$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x18$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x18$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x18$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x18$iterations[3, ], c(7, 8, 1, 4), label = paste0("c(", paste0(x18$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x18$rejectAtLeastOne, c(0.3, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x18$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0.2, 0, 0, 0.1, 0, 0.2, 0.3, 0, 0.1, 0.3, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x18$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityStop, collapse = ", "), ")"))
- expect_equal(x18$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x18$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x18$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x18$earlyStop[2, ], c(0.3, 0.2, 0.9, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x18$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[2, ], c(0.3, 0.2, 0.9, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x18$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0, 1, 0.4, 0.3, 1, 0.5, 0.2, 1, 0.2, 0.1, 1, 0.6, 0.1, 1, 0.4, 0, 1, 1, 0.7, 1, 1, 0.8, 1, 1, 0.1, 1, 1, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$selectedArms)), collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x18$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[2, ], c(1, 0.9, 0.8, 1), tolerance = 1e-07, label = paste0("c(", paste0(x18$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x18$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x18$expectedNumberOfSubjects, c(179.95701, 273.63073, 113.26043, 249.89211), tolerance = 1e-07, label = paste0("c(", paste0(x18$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$sampleSizes)), c(10, 1.1167748, 1.5953926, 10, 5.3747099, 6.7183874, 10, 0.4, 0, 10, 10, 25, 10, 6.7277808, 9.6111155, 10, 33.823466, 42.279332, 10, 0, 0, 10, 10, 0, 10, 2.4005123, 3.4293032, 10, 7.6599811, 9.5749763, 10, 9.203124, 0, 10, 32.126443, 55.316107, 10, 28.865098, 22.318956, 10, 14.049526, 5.061908, 10, 19.260309, 27.667829, 10, 15.693169, 0, 10, 39.110166, 36.954767, 10, 60.907683, 63.634604, 10, 28.863433, 27.667829, 10, 67.819612, 80.316107), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x18$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[2, ], c(0.064552587, 0.045828659, 0.10685317, 0.098246228), tolerance = 1e-07, label = paste0("c(", paste0(x18$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[3, ], c(0.1164829, 0.22353174, 0.16556673, 0.12567304), tolerance = 1e-07, label = paste0("c(", paste0(x18$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x18), NA)))
- expect_output(print(x18)$show())
- invisible(capture.output(expect_error(summary(x18), NA)))
- expect_output(summary(x18)$show())
- x18CodeBased <- eval(parse(text = getObjectRCode(x18, stringWrapParagraphWidth = NULL)))
- expect_equal(x18CodeBased$iterations, x18$iterations, tolerance = 1e-07)
- expect_equal(x18CodeBased$rejectAtLeastOne, x18$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x18CodeBased$rejectedArmsPerStage, x18$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$futilityStop, x18$futilityStop, tolerance = 1e-07)
- expect_equal(x18CodeBased$futilityPerStage, x18$futilityPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$earlyStop, x18$earlyStop, tolerance = 1e-07)
- expect_equal(x18CodeBased$successPerStage, x18$successPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$selectedArms, x18$selectedArms, tolerance = 1e-07)
- expect_equal(x18CodeBased$numberOfActiveArms, x18$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x18CodeBased$expectedNumberOfSubjects, x18$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x18CodeBased$sampleSizes, x18$sampleSizes, tolerance = 1e-07)
- expect_equal(x18CodeBased$conditionalPowerAchieved, x18$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x18), "character")
- df <- as.data.frame(x18)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x18)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x19 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x19' with expected results
- expect_equal(x19$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x19$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x19$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x19$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x19$iterations[3, ], c(6, 3, 4, 6), label = paste0("c(", paste0(x19$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x19$rejectAtLeastOne, c(0.1, 0, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x19$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$rejectedArmsPerStage)), c(0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x19$futilityStop, c(0.4, 0.4, 0.5, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x19$futilityStop, collapse = ", "), ")"))
- expect_equal(x19$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x19$futilityPerStage[2, ], c(0.4, 0.4, 0.5, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x19$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x19$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x19$earlyStop[2, ], c(0.4, 0.7, 0.6, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x19$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[2, ], c(0, 0.3, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x19$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[3, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x19$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$selectedArms)), c(1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.6, 0.6, 1, 0.6, 0.4, 1, 0.5, 0.2, 1, 0.7, 0.3, 1, 1, 0.6, 1, 0.6, 0.4, 1, 0.7, 0.3, 1, 0.7, 0.4, 1, 0.7, 0.4, 1, 0.7, 0.3, 1, 0.5, 0.2, 1, 0.9, 0.4, 1, 0.8, 0.5, 1, 1, 0.6, 1, 1, 0.3, 1, 1, 0.4, 1, 1, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$selectedArms)), collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x19$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[2, ], c(2.5, 2, 2.7, 3.1), tolerance = 1e-07, label = paste0("c(", paste0(x19$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[3, ], c(2.8333333, 3.3333333, 3.75, 3.5), tolerance = 1e-07, label = paste0("c(", paste0(x19$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x19$expectedNumberOfSubjects, c(600.66781, 398.09964, 600, 634), tolerance = 1e-07, label = paste0("c(", paste0(x19$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$sampleSizes)), c(10, 56.333476, 93.889127, 10, 30, 100, 10, 40, 100, 10, 50.4, 84, 10, 56.333476, 60.555794, 10, 37.024911, 66.666667, 10, 70, 75, 10, 90.4, 84, 10, 60, 66.666667, 10, 57.024911, 100, 10, 70, 100, 10, 60.4, 50.666667, 10, 66.333476, 43.889127, 10, 37.024911, 66.666667, 10, 90, 100, 10, 70.4, 67.333333, 10, 96.333476, 93.889127, 10, 57.024911, 100, 10, 90, 100, 10, 90.4, 84), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x19$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[2, ], c(0.014835699, 0.058493392, 0.079579319, 0.18689602), tolerance = 1e-07, label = paste0("c(", paste0(x19$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[3, ], c(0.35039062, 0.35957167, 0.84477407, 0.62586447), tolerance = 1e-07, label = paste0("c(", paste0(x19$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x19), NA)))
- expect_output(print(x19)$show())
- invisible(capture.output(expect_error(summary(x19), NA)))
- expect_output(summary(x19)$show())
- x19CodeBased <- eval(parse(text = getObjectRCode(x19, stringWrapParagraphWidth = NULL)))
- expect_equal(x19CodeBased$iterations, x19$iterations, tolerance = 1e-07)
- expect_equal(x19CodeBased$rejectAtLeastOne, x19$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x19CodeBased$rejectedArmsPerStage, x19$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$futilityStop, x19$futilityStop, tolerance = 1e-07)
- expect_equal(x19CodeBased$futilityPerStage, x19$futilityPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$earlyStop, x19$earlyStop, tolerance = 1e-07)
- expect_equal(x19CodeBased$successPerStage, x19$successPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$selectedArms, x19$selectedArms, tolerance = 1e-07)
- expect_equal(x19CodeBased$numberOfActiveArms, x19$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x19CodeBased$expectedNumberOfSubjects, x19$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x19CodeBased$sampleSizes, x19$sampleSizes, tolerance = 1e-07)
- expect_equal(x19CodeBased$conditionalPowerAchieved, x19$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x19), "character")
- df <- as.data.frame(x19)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x19)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x20 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4, threshold = 0,
- typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x20' with expected results
- expect_equal(x20$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x20$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x20$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x20$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x20$iterations[3, ], c(2, 6, 3, 2), label = paste0("c(", paste0(x20$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x20$rejectAtLeastOne, c(0, 0.2, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x20$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$rejectedArmsPerStage)), c(0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x20$futilityStop, c(0.7, 0.3, 0.5, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x20$futilityStop, collapse = ", "), ")"))
- expect_equal(x20$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x20$futilityPerStage[2, ], c(0.7, 0.3, 0.5, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x20$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x20$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x20$earlyStop[2, ], c(0.8, 0.4, 0.7, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x20$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[2, ], c(0.1, 0.1, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x20$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$selectedArms)), c(1, 0.2, 0.2, 1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.3, 0.2, 1, 0.4, 0, 1, 0.1, 0, 1, 0.3, 0, 1, 0.5, 0, 1, 0.3, 0, 1, 0.3, 0.1, 1, 0.3, 0.1, 1, 0.4, 0, 1, 0.8, 0.2, 1, 0.8, 0.5, 1, 0.5, 0.2, 1, 0.8, 0.2, 1, 1, 0.2, 1, 1, 0.6, 1, 1, 0.3, 1, 1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$selectedArms)), collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x20$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[2, ], c(1.7, 1.8, 1.4, 2), tolerance = 1e-07, label = paste0("c(", paste0(x20$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x20$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x20$expectedNumberOfSubjects, c(307.09166, 377.99189, 286.78887, 300.60787), tolerance = 1e-07, label = paste0("c(", paste0(x20$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$sampleSizes)), c(10, 20, 100, 10, 42.387791, 70.646318, 10, 24.430263, 81.43421, 10, 25.370782, 76.853911, 10, 29.905482, 0, 10, 10, 0, 10, 21.806036, 0, 10, 38.448036, 0, 10, 15.987487, 0, 10, 24.555048, 16.666667, 10, 26.82395, 33.333333, 10, 22.273651, 0, 10, 62.168137, 100, 10, 56.942839, 53.979652, 10, 31.806941, 48.100877, 10, 50.237878, 76.853911, 10, 69.030553, 100, 10, 66.942839, 70.646318, 10, 58.630891, 81.43421, 10, 68.165174, 76.853911), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x20$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[2, ], c(0.04855367, 0.14023716, 0.084441455, 0.094637028), tolerance = 1e-07, label = paste0("c(", paste0(x20$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[3, ], c(0.09464551, 0.36740056, 0.23354895, 0.75738479), tolerance = 1e-07, label = paste0("c(", paste0(x20$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x20), NA)))
- expect_output(print(x20)$show())
- invisible(capture.output(expect_error(summary(x20), NA)))
- expect_output(summary(x20)$show())
- x20CodeBased <- eval(parse(text = getObjectRCode(x20, stringWrapParagraphWidth = NULL)))
- expect_equal(x20CodeBased$iterations, x20$iterations, tolerance = 1e-07)
- expect_equal(x20CodeBased$rejectAtLeastOne, x20$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x20CodeBased$rejectedArmsPerStage, x20$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$futilityStop, x20$futilityStop, tolerance = 1e-07)
- expect_equal(x20CodeBased$futilityPerStage, x20$futilityPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$earlyStop, x20$earlyStop, tolerance = 1e-07)
- expect_equal(x20CodeBased$successPerStage, x20$successPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$selectedArms, x20$selectedArms, tolerance = 1e-07)
- expect_equal(x20CodeBased$numberOfActiveArms, x20$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x20CodeBased$expectedNumberOfSubjects, x20$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x20CodeBased$sampleSizes, x20$sampleSizes, tolerance = 1e-07)
- expect_equal(x20CodeBased$conditionalPowerAchieved, x20$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x20), "character")
- df <- as.data.frame(x20)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x20)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x21 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x21' with expected results
- expect_equal(x21$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x21$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x21$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x21$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x21$iterations[3, ], c(1, 1, 3, 0), label = paste0("c(", paste0(x21$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x21$rejectAtLeastOne, c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x21$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x21$futilityStop, c(0.8, 0.8, 0.6, 1), tolerance = 1e-07, label = paste0("c(", paste0(x21$futilityStop, collapse = ", "), ")"))
- expect_equal(x21$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x21$futilityPerStage[2, ], c(0.8, 0.8, 0.6, 1), tolerance = 1e-07, label = paste0("c(", paste0(x21$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x21$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x21$earlyStop[2, ], c(0.9, 0.9, 0.7, 1), tolerance = 1e-07, label = paste0("c(", paste0(x21$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[2, ], c(0.1, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x21$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[3, ], c(0, 0.1, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x21$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0, 0, 1, 0.3, 0, 1, 0.3, 0, 1, 0, 0, 1, 0.3, 0, 1, 0.3, 0, 1, 0.2, 0, 1, 0.2, 0, 1, 0.1, 0, 1, 0.3, 0, 1, 0.5, 0, 1, 0.5, 0.1, 1, 0.6, 0, 1, 1, 0.1, 1, 1, 0.1, 1, 1, 0.3, 1, 1, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$selectedArms)), collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x21$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[2, ], c(1, 1.1, 1.1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x21$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[3, ], c(1, 1, 1.3333333, NaN), tolerance = 1e-07, label = paste0("c(", paste0(x21$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x21$expectedNumberOfSubjects, c(190.08367, 169.68391, 280.67025, NaN), tolerance = 1e-07, label = paste0("c(", paste0(x21$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$sampleSizes)), c(10, 4.0457324, 40.457324, 10, 10, 100, 10, 30.407004, 99.157615, 10, 0, NaN, 10, 17.562755, 0, 10, 19.770676, 0, 10, 0, 0, 10, 21.272121, NaN, 10, 22.866081, 0, 10, 10.368972, 0, 10, 16.622221, 0, 10, 10, NaN, 10, 23.043067, 0, 10, 18.030637, 0, 10, 38.558614, 33.333333, 10, 21.010924, NaN, 10, 64.474568, 40.457324, 10, 41.513628, 100, 10, 75.587839, 99.157615, 10, 52.283045, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x21$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[2, ], c(0.021183612, 0.1290513, 0.046563399, 0.11230633), tolerance = 1e-07, label = paste0("c(", paste0(x21$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[3, ], c(0.07537462, 0.00060378387, 0.33359002, NaN), tolerance = 1e-07, label = paste0("c(", paste0(x21$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x21), NA)))
- expect_output(print(x21)$show())
- invisible(capture.output(expect_error(summary(x21), NA)))
- expect_output(summary(x21)$show())
- x21CodeBased <- eval(parse(text = getObjectRCode(x21, stringWrapParagraphWidth = NULL)))
- expect_equal(x21CodeBased$iterations, x21$iterations, tolerance = 1e-07)
- expect_equal(x21CodeBased$rejectAtLeastOne, x21$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x21CodeBased$rejectedArmsPerStage, x21$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$futilityStop, x21$futilityStop, tolerance = 1e-07)
- expect_equal(x21CodeBased$futilityPerStage, x21$futilityPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$earlyStop, x21$earlyStop, tolerance = 1e-07)
- expect_equal(x21CodeBased$successPerStage, x21$successPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$selectedArms, x21$selectedArms, tolerance = 1e-07)
- expect_equal(x21CodeBased$numberOfActiveArms, x21$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x21CodeBased$expectedNumberOfSubjects, x21$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x21CodeBased$sampleSizes, x21$sampleSizes, tolerance = 1e-07)
- expect_equal(x21CodeBased$conditionalPowerAchieved, x21$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x21), "character")
- df <- as.data.frame(x21)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x21)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x22 <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0.1,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.1, 0.3, 0.1),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 1
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x22' with expected results
- expect_equal(x22$iterations[1, ], c(1, 1, 1), label = paste0("c(", paste0(x22$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x22$iterations[2, ], c(1, 1, 1), label = paste0("c(", paste0(x22$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x22$iterations[3, ], c(1, 1, 1), label = paste0("c(", paste0(x22$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x22$rejectAtLeastOne, c(0, 0, 0), label = paste0("c(", paste0(x22$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x22$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x22$futilityStop, c(0, 0, 0), label = paste0("c(", paste0(x22$futilityStop, collapse = ", "), ")"))
- expect_equal(x22$futilityPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x22$futilityPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x22$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x22$earlyStop[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x22$earlyStop[2, ], c(0, 0, 0), label = paste0("c(", paste0(x22$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x22$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[3, ], c(1, 0, 0), label = paste0("c(", paste0(x22$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(unlist(as.list(x22$selectedArms)), collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0("c(", paste0(x22$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0("c(", paste0(x22$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[3, ], c(0, 1, 1), label = paste0("c(", paste0(x22$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x22$expectedNumberOfSubjects, c(115.75051, 450, 148.90979), tolerance = 1e-07, label = paste0("c(", paste0(x22$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 32.875253, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 100, 100, 10, 10.358511, 39.096382, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 32.875253, 0, 10, 100, 100, 10, 10.358511, 39.096382), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x22$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x22$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[2, ], c(0.011749146, 0.0034013018, 0.045375018), tolerance = 1e-07, label = paste0("c(", paste0(x22$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[3, ], c(0.0024237291, 0.15769372, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x22$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x22), NA)))
- expect_output(print(x22)$show())
- invisible(capture.output(expect_error(summary(x22), NA)))
- expect_output(summary(x22)$show())
- x22CodeBased <- eval(parse(text = getObjectRCode(x22, stringWrapParagraphWidth = NULL)))
- expect_equal(x22CodeBased$iterations, x22$iterations, tolerance = 1e-07)
- expect_equal(x22CodeBased$rejectAtLeastOne, x22$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x22CodeBased$rejectedArmsPerStage, x22$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$futilityStop, x22$futilityStop, tolerance = 1e-07)
- expect_equal(x22CodeBased$futilityPerStage, x22$futilityPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$earlyStop, x22$earlyStop, tolerance = 1e-07)
- expect_equal(x22CodeBased$successPerStage, x22$successPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$selectedArms, x22$selectedArms, tolerance = 1e-07)
- expect_equal(x22CodeBased$numberOfActiveArms, x22$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x22CodeBased$expectedNumberOfSubjects, x22$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x22CodeBased$sampleSizes, x22$sampleSizes, tolerance = 1e-07)
- expect_equal(x22CodeBased$conditionalPowerAchieved, x22$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x22), "character")
- df <- as.data.frame(x22)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x22)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetBonferroni}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ # @refFS[Formula]{fs:adjustedPValueSubsetHierarchical}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
+ x1 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4, plannedSubjects = c(10, 30, 50), stDev = 1.2,
+ muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x1' with expected results
+ expect_equal(x1$iterations[1, ], c(10, 10, 10, 10), label = paste0(x1$iterations[1, ]))
+ expect_equal(x1$iterations[2, ], c(10, 10, 10, 10), label = paste0(x1$iterations[2, ]))
+ expect_equal(x1$iterations[3, ], c(9, 8, 8, 5), label = paste0(x1$iterations[3, ]))
+ expect_equal(x1$rejectAtLeastOne, c(0.3, 0.6, 0.8, 0.9), tolerance = 1e-07, label = paste0(x1$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x1$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.1, 0, 0.2, 0.1, 0, 0, 0.3, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0, 0.1, 0, 0.2, 0.3, 0, 0.3, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x1$rejectedArmsPerStage))))
+ expect_equal(x1$futilityStop, c(0, 0, 0, 0), label = paste0(x1$futilityStop))
+ expect_equal(x1$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x1$futilityPerStage[1, ]))
+ expect_equal(x1$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x1$futilityPerStage[2, ]))
+ expect_equal(x1$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x1$earlyStop[1, ]))
+ expect_equal(x1$earlyStop[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0(x1$earlyStop[2, ]))
+ expect_equal(x1$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x1$successPerStage[1, ]))
+ expect_equal(x1$successPerStage[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0(x1$successPerStage[2, ]))
+ expect_equal(x1$successPerStage[3, ], c(0.2, 0.4, 0.6, 0.4), tolerance = 1e-07, label = paste0(x1$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x1$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.5, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.3, 1, 0.6, 0.3, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x1$selectedArms))))
+ expect_equal(x1$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x1$numberOfActiveArms[1, ]))
+ expect_equal(x1$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x1$numberOfActiveArms[2, ]))
+ expect_equal(x1$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x1$numberOfActiveArms[3, ]))
+ expect_equal(x1$expectedNumberOfSubjects, c(268.55306, 310.74423, 296.80608, 214.56859), tolerance = 1e-07, label = paste0(x1$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x1$sampleSizes)), c(10, 1.1840544, 11.111111, 10, 10, 12.5, 10, 0.74314427, 1.9878756, 10, 0, 0, 10, 7.3350068, 25.517647, 10, 26.989766, 43.604406, 10, 0, 0, 10, 21.344686, 26.724319, 10, 2.6348908, 7.2351621, 10, 21.298615, 12.5, 10, 40, 44.643278, 10, 10, 0, 10, 33.493936, 27.945681, 10, 4.3287276, 16.089351, 10, 25.258173, 25.120998, 10, 23.39578, 28.363338, 10, 44.647888, 71.809601, 10, 62.617108, 84.693757, 10, 66.001318, 71.752151, 10, 54.740466, 55.087656), tolerance = 1e-07, label = paste0(unlist(as.list(x1$sampleSizes))))
+ expect_equal(x1$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPowerAchieved[1, ]))
+ expect_equal(x1$conditionalPowerAchieved[2, ], c(0.046651357, 0.022479034, 0.083769211, 0.082365248), tolerance = 1e-07, label = paste0(x1$conditionalPowerAchieved[2, ]))
+ expect_equal(x1$conditionalPowerAchieved[3, ], c(0.49123587, 0.2668344, 0.64496483, 0.65218675), tolerance = 1e-07, label = paste0(x1$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x1), NA)))
+ expect_output(print(x1)$show())
+ invisible(capture.output(expect_error(summary(x1), NA)))
+ expect_output(summary(x1)$show())
+ x1CodeBased <- eval(parse(text = getObjectRCode(x1, stringWrapParagraphWidth = NULL)))
+ expect_equal(x1CodeBased$iterations, x1$iterations, tolerance = 1e-07)
+ expect_equal(x1CodeBased$rejectAtLeastOne, x1$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x1CodeBased$rejectedArmsPerStage, x1$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$futilityStop, x1$futilityStop, tolerance = 1e-07)
+ expect_equal(x1CodeBased$futilityPerStage, x1$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$earlyStop, x1$earlyStop, tolerance = 1e-07)
+ expect_equal(x1CodeBased$successPerStage, x1$successPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$selectedArms, x1$selectedArms, tolerance = 1e-07)
+ expect_equal(x1CodeBased$numberOfActiveArms, x1$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x1CodeBased$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x1CodeBased$sampleSizes, x1$sampleSizes, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPowerAchieved, x1$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x1), "character")
+ df <- as.data.frame(x1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x2 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "userDefined", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, adaptations = rep(TRUE, 2),
+ effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x2' with expected results
+ expect_equal(x2$iterations[1, ], c(10, 10), label = paste0(x2$iterations[1, ]))
+ expect_equal(x2$iterations[2, ], c(10, 10), label = paste0(x2$iterations[2, ]))
+ expect_equal(x2$iterations[3, ], c(8, 8), label = paste0(x2$iterations[3, ]))
+ expect_equal(x2$rejectAtLeastOne, c(0.5, 0.6), tolerance = 1e-07, label = paste0(x2$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x2$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.3, 0, 0, 0, 0, 0.2, 0, 0, 0.2, 0.2, 0, 0, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x2$rejectedArmsPerStage))))
+ expect_equal(x2$futilityStop, c(0, 0), label = paste0(x2$futilityStop))
+ expect_equal(x2$futilityPerStage[1, ], c(0, 0), label = paste0(x2$futilityPerStage[1, ]))
+ expect_equal(x2$futilityPerStage[2, ], c(0, 0), label = paste0(x2$futilityPerStage[2, ]))
+ expect_equal(x2$earlyStop[1, ], c(0, 0), label = paste0(x2$earlyStop[1, ]))
+ expect_equal(x2$earlyStop[2, ], c(0.2, 0.2), tolerance = 1e-07, label = paste0(x2$earlyStop[2, ]))
+ expect_equal(x2$successPerStage[1, ], c(0, 0), label = paste0(x2$successPerStage[1, ]))
+ expect_equal(x2$successPerStage[2, ], c(0.2, 0.2), tolerance = 1e-07, label = paste0(x2$successPerStage[2, ]))
+ expect_equal(x2$successPerStage[3, ], c(0.3, 0.4), tolerance = 1e-07, label = paste0(x2$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x2$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.2, 0, 1, 0.5, 0.3, 1, 0.2, 0.2, 1, 1, 0.8, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x2$selectedArms))))
+ expect_equal(x2$numberOfActiveArms[1, ], c(4, 4), label = paste0(x2$numberOfActiveArms[1, ]))
+ expect_equal(x2$numberOfActiveArms[2, ], c(1, 1), label = paste0(x2$numberOfActiveArms[2, ]))
+ expect_equal(x2$numberOfActiveArms[3, ], c(1, 1), label = paste0(x2$numberOfActiveArms[3, ]))
+ expect_equal(x2$expectedNumberOfSubjects, c(238.96461, 281.13648), tolerance = 1e-07, label = paste0(x2$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x2$sampleSizes)), c(10, 1.1060693, 12.5, 10, 20, 25, 10, 4.7297328, 25.346201, 10, 18.776011, 38.686485, 10, 2.8470245, 10.408309, 10, 11.298615, 0, 10, 26.795872, 25.5, 10, 3.2314462, 14.141225, 10, 35.478699, 73.75451, 10, 53.306071, 77.82771), tolerance = 1e-07, label = paste0(unlist(as.list(x2$sampleSizes))))
+ expect_equal(x2$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0(x2$conditionalPowerAchieved[1, ]))
+ expect_equal(x2$conditionalPowerAchieved[2, ], c(0.064857702, 0.041878984), tolerance = 1e-07, label = paste0(x2$conditionalPowerAchieved[2, ]))
+ expect_equal(x2$conditionalPowerAchieved[3, ], c(0.72573181, 0.45099208), tolerance = 1e-07, label = paste0(x2$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x2), NA)))
+ expect_output(print(x2)$show())
+ invisible(capture.output(expect_error(summary(x2), NA)))
+ expect_output(summary(x2)$show())
+ x2CodeBased <- eval(parse(text = getObjectRCode(x2, stringWrapParagraphWidth = NULL)))
+ expect_equal(x2CodeBased$iterations, x2$iterations, tolerance = 1e-07)
+ expect_equal(x2CodeBased$rejectAtLeastOne, x2$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x2CodeBased$rejectedArmsPerStage, x2$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$futilityStop, x2$futilityStop, tolerance = 1e-07)
+ expect_equal(x2CodeBased$futilityPerStage, x2$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$earlyStop, x2$earlyStop, tolerance = 1e-07)
+ expect_equal(x2CodeBased$successPerStage, x2$successPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$selectedArms, x2$selectedArms, tolerance = 1e-07)
+ expect_equal(x2CodeBased$numberOfActiveArms, x2$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x2CodeBased$expectedNumberOfSubjects, x2$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x2CodeBased$sampleSizes, x2$sampleSizes, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPowerAchieved, x2$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x2), "character")
+ df <- as.data.frame(x2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x3 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x3' with expected results
+ expect_equal(x3$iterations[1, ], c(10, 10, 10, 10), label = paste0(x3$iterations[1, ]))
+ expect_equal(x3$iterations[2, ], c(10, 10, 10, 10), label = paste0(x3$iterations[2, ]))
+ expect_equal(x3$iterations[3, ], c(10, 9, 9, 8), label = paste0(x3$iterations[3, ]))
+ expect_equal(x3$rejectAtLeastOne, c(0, 0.3, 0.6, 0.7), tolerance = 1e-07, label = paste0(x3$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x3$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.2, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0, 0, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x3$rejectedArmsPerStage))))
+ expect_equal(x3$futilityStop, c(0, 0, 0, 0), label = paste0(x3$futilityStop))
+ expect_equal(x3$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x3$futilityPerStage[1, ]))
+ expect_equal(x3$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x3$futilityPerStage[2, ]))
+ expect_equal(x3$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x3$earlyStop[1, ]))
+ expect_equal(x3$earlyStop[2, ], c(0, 0.1, 0.1, 0.2), tolerance = 1e-07, label = paste0(x3$earlyStop[2, ]))
+ expect_equal(x3$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x3$successPerStage[1, ]))
+ expect_equal(x3$successPerStage[2, ], c(0, 0.1, 0.1, 0.2), tolerance = 1e-07, label = paste0(x3$successPerStage[2, ]))
+ expect_equal(x3$successPerStage[3, ], c(0, 0.2, 0.5, 0.5), tolerance = 1e-07, label = paste0(x3$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x3$selectedArms)), c(1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0, 0, 1, 0.3, 0.2, 1, 0.2, 0.2, 1, 0.2, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.4, 1, 0.6, 0.6, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x3$selectedArms))))
+ expect_equal(x3$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x3$numberOfActiveArms[1, ]))
+ expect_equal(x3$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x3$numberOfActiveArms[2, ]))
+ expect_equal(x3$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x3$numberOfActiveArms[3, ]))
+ expect_equal(x3$expectedNumberOfSubjects, c(295.76875, 343.71408, 335.10548, 281.56474), tolerance = 1e-07, label = paste0(x3$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x3$sampleSizes)), c(10, 1.0357205, 10, 10, 30, 33.333333, 10, 0.59871171, 1.0418812, 10, 0, 0, 10, 7.3350068, 22.965882, 10, 16.989766, 27.64836, 10, 0, 0, 10, 21.344686, 16.702699, 10, 13.17796, 20, 10, 15.323901, 2.6274327, 10, 40, 44.444444, 10, 10, 0, 10, 25.447372, 22.922435, 10, 7.2951578, 22.222222, 10, 38.282522, 25.259795, 10, 36.742398, 42.916408, 10, 46.996059, 75.888318, 10, 69.608825, 85.831349, 10, 78.881233, 70.74612, 10, 68.087084, 59.619107), tolerance = 1e-07, label = paste0(unlist(as.list(x3$sampleSizes))))
+ expect_equal(x3$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPowerAchieved[1, ]))
+ expect_equal(x3$conditionalPowerAchieved[2, ], c(0.042062266, 0.013174936, 0.075843331, 0.053971766), tolerance = 1e-07, label = paste0(x3$conditionalPowerAchieved[2, ]))
+ expect_equal(x3$conditionalPowerAchieved[3, ], c(0.41527426, 0.27301585, 0.35639557, 0.62491311), tolerance = 1e-07, label = paste0(x3$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x3), NA)))
+ expect_output(print(x3)$show())
+ invisible(capture.output(expect_error(summary(x3), NA)))
+ expect_output(summary(x3)$show())
+ x3CodeBased <- eval(parse(text = getObjectRCode(x3, stringWrapParagraphWidth = NULL)))
+ expect_equal(x3CodeBased$iterations, x3$iterations, tolerance = 1e-07)
+ expect_equal(x3CodeBased$rejectAtLeastOne, x3$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x3CodeBased$rejectedArmsPerStage, x3$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$futilityStop, x3$futilityStop, tolerance = 1e-07)
+ expect_equal(x3CodeBased$futilityPerStage, x3$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$earlyStop, x3$earlyStop, tolerance = 1e-07)
+ expect_equal(x3CodeBased$successPerStage, x3$successPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$selectedArms, x3$selectedArms, tolerance = 1e-07)
+ expect_equal(x3CodeBased$numberOfActiveArms, x3$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x3CodeBased$expectedNumberOfSubjects, x3$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x3CodeBased$sampleSizes, x3$sampleSizes, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPowerAchieved, x3$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x3), "character")
+ df <- as.data.frame(x3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x4 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x4' with expected results
+ expect_equal(x4$iterations[1, ], c(10, 10, 10, 10), label = paste0(x4$iterations[1, ]))
+ expect_equal(x4$iterations[2, ], c(10, 10, 10, 10), label = paste0(x4$iterations[2, ]))
+ expect_equal(x4$iterations[3, ], c(10, 10, 10, 10), label = paste0(x4$iterations[3, ]))
+ expect_equal(x4$rejectAtLeastOne, c(0.4, 0.8, 1, 1), tolerance = 1e-07, label = paste0(x4$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x4$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0.1, 0.2, 0, 0, 0.1, 0, 0, 0.3, 0, 0.2, 0.3, 0, 0.6, 0.2, 0, 0, 0.4, 0, 0.1, 0.7, 0, 0.4, 0.6, 0, 0.7, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x4$rejectedArmsPerStage))))
+ expect_equal(x4$futilityStop, c(0, 0, 0, 0), label = paste0(x4$futilityStop))
+ expect_equal(x4$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x4$futilityPerStage[1, ]))
+ expect_equal(x4$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x4$futilityPerStage[2, ]))
+ expect_equal(x4$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x4$earlyStop[1, ]))
+ expect_equal(x4$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x4$earlyStop[2, ]))
+ expect_equal(x4$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[1, ]))
+ expect_equal(x4$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[2, ]))
+ expect_equal(x4$successPerStage[3, ], c(0, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x4$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x4$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0(unlist(as.list(x4$selectedArms))))
+ expect_equal(x4$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[1, ]))
+ expect_equal(x4$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[2, ]))
+ expect_equal(x4$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[3, ]))
+ expect_equal(x4$expectedNumberOfSubjects, c(1050, 891.96665, 849.19143, 705.05343), tolerance = 1e-07, label = paste0(x4$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x4$sampleSizes)), c(10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8, 10, 100, 100, 10, 87.259377, 81.133954, 10, 94.901963, 64.936322, 10, 98.210686, 32.8), tolerance = 1e-07, label = paste0(unlist(as.list(x4$sampleSizes))))
+ expect_equal(x4$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x4$conditionalPowerAchieved[1, ]))
+ expect_equal(x4$conditionalPowerAchieved[2, ], c(0.0086377938, 0.22005253, 0.081022458, 0.15135806), tolerance = 1e-07, label = paste0(x4$conditionalPowerAchieved[2, ]))
+ expect_equal(x4$conditionalPowerAchieved[3, ], c(0.17779298, 0.23451185, 0.45925582, 0.77364695), tolerance = 1e-07, label = paste0(x4$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x4), NA)))
+ expect_output(print(x4)$show())
+ invisible(capture.output(expect_error(summary(x4), NA)))
+ expect_output(summary(x4)$show())
+ x4CodeBased <- eval(parse(text = getObjectRCode(x4, stringWrapParagraphWidth = NULL)))
+ expect_equal(x4CodeBased$iterations, x4$iterations, tolerance = 1e-07)
+ expect_equal(x4CodeBased$rejectAtLeastOne, x4$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x4CodeBased$rejectedArmsPerStage, x4$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$futilityStop, x4$futilityStop, tolerance = 1e-07)
+ expect_equal(x4CodeBased$futilityPerStage, x4$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$earlyStop, x4$earlyStop, tolerance = 1e-07)
+ expect_equal(x4CodeBased$successPerStage, x4$successPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$selectedArms, x4$selectedArms, tolerance = 1e-07)
+ expect_equal(x4CodeBased$numberOfActiveArms, x4$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x4CodeBased$expectedNumberOfSubjects, x4$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x4CodeBased$sampleSizes, x4$sampleSizes, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalPowerAchieved, x4$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x4), "character")
+ df <- as.data.frame(x4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x5 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x5' with expected results
+ expect_equal(x5$iterations[1, ], c(10, 10, 10, 10), label = paste0(x5$iterations[1, ]))
+ expect_equal(x5$iterations[2, ], c(10, 10, 10, 10), label = paste0(x5$iterations[2, ]))
+ expect_equal(x5$iterations[3, ], c(10, 9, 8, 8), label = paste0(x5$iterations[3, ]))
+ expect_equal(x5$rejectAtLeastOne, c(0.5, 0.9, 1, 0.9), tolerance = 1e-07, label = paste0(x5$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x5$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.3, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.3, 0, 0.3, 0.2, 0, 0.2, 0.2, 0, 0.1, 0.3, 0, 0.1, 0.4, 0, 0.1, 0.3, 0, 0.6, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x5$rejectedArmsPerStage))))
+ expect_equal(x5$futilityStop, c(0, 0, 0, 0), label = paste0(x5$futilityStop))
+ expect_equal(x5$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x5$futilityPerStage[1, ]))
+ expect_equal(x5$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x5$futilityPerStage[2, ]))
+ expect_equal(x5$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x5$earlyStop[1, ]))
+ expect_equal(x5$earlyStop[2, ], c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x5$earlyStop[2, ]))
+ expect_equal(x5$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x5$successPerStage[1, ]))
+ expect_equal(x5$successPerStage[2, ], c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x5$successPerStage[2, ]))
+ expect_equal(x5$successPerStage[3, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0(x5$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x5$selectedArms)), c(1, 0.5, 0.5, 1, 0.7, 0.6, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.9, 0.7, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.6, 0.4, 1, 0.4, 0.2, 1, 0.7, 0.7, 1, 0.5, 0.4, 1, 0.4, 0.4, 1, 0.9, 0.7, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x5$selectedArms))))
+ expect_equal(x5$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x5$numberOfActiveArms[1, ]))
+ expect_equal(x5$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x5$numberOfActiveArms[2, ]))
+ expect_equal(x5$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x5$numberOfActiveArms[3, ]))
+ expect_equal(x5$expectedNumberOfSubjects, c(591.09538, 503.05596, 452.93301, 405.41488), tolerance = 1e-07, label = paste0(x5$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x5$sampleSizes)), c(10, 42.50248, 47.078471, 10, 45.384313, 50.975979, 10, 10, 12.5, 10, 29.554131, 37.5, 10, 15.855942, 30, 10, 22.437029, 19.843895, 10, 72.307665, 59.768075, 10, 30.61074, 15.281075, 10, 47.430714, 50, 10, 35.976108, 53.08315, 10, 50.052941, 40.398451, 10, 31.50186, 5.7250423, 10, 60.784176, 67.078471, 10, 46.971175, 44.173288, 10, 20.632484, 31.869624, 10, 71.666731, 33.506118, 10, 83.286657, 97.078471, 10, 75.384313, 84.038156, 10, 76.496545, 72.268075, 10, 81.666731, 46.006118), tolerance = 1e-07, label = paste0(unlist(as.list(x5$sampleSizes))))
+ expect_equal(x5$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x5$conditionalPowerAchieved[1, ]))
+ expect_equal(x5$conditionalPowerAchieved[2, ], c(0.061919533, 0.10420825, 0.16753344, 0.13874821), tolerance = 1e-07, label = paste0(x5$conditionalPowerAchieved[2, ]))
+ expect_equal(x5$conditionalPowerAchieved[3, ], c(0.29816652, 0.52092951, 0.66819594, 0.56533632), tolerance = 1e-07, label = paste0(x5$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x5), NA)))
+ expect_output(print(x5)$show())
+ invisible(capture.output(expect_error(summary(x5), NA)))
+ expect_output(summary(x5)$show())
+ x5CodeBased <- eval(parse(text = getObjectRCode(x5, stringWrapParagraphWidth = NULL)))
+ expect_equal(x5CodeBased$iterations, x5$iterations, tolerance = 1e-07)
+ expect_equal(x5CodeBased$rejectAtLeastOne, x5$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x5CodeBased$rejectedArmsPerStage, x5$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$futilityStop, x5$futilityStop, tolerance = 1e-07)
+ expect_equal(x5CodeBased$futilityPerStage, x5$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$earlyStop, x5$earlyStop, tolerance = 1e-07)
+ expect_equal(x5CodeBased$successPerStage, x5$successPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$selectedArms, x5$selectedArms, tolerance = 1e-07)
+ expect_equal(x5CodeBased$numberOfActiveArms, x5$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x5CodeBased$expectedNumberOfSubjects, x5$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x5CodeBased$sampleSizes, x5$sampleSizes, tolerance = 1e-07)
+ expect_equal(x5CodeBased$conditionalPowerAchieved, x5$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x5), "character")
+ df <- as.data.frame(x5)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x5)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x6 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x6' with expected results
+ expect_equal(x6$iterations[1, ], c(10, 10, 10, 10), label = paste0(x6$iterations[1, ]))
+ expect_equal(x6$iterations[2, ], c(10, 10, 10, 10), label = paste0(x6$iterations[2, ]))
+ expect_equal(x6$iterations[3, ], c(10, 9, 7, 6), label = paste0(x6$iterations[3, ]))
+ expect_equal(x6$rejectAtLeastOne, c(0.4, 0.6, 0.8, 0.8), tolerance = 1e-07, label = paste0(x6$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x6$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.2, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.2, 0, 0.1, 0.4, 0, 0.3, 0.5, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x6$rejectedArmsPerStage))))
+ expect_equal(x6$futilityStop, c(0, 0, 0, 0), label = paste0(x6$futilityStop))
+ expect_equal(x6$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x6$futilityPerStage[1, ]))
+ expect_equal(x6$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x6$futilityPerStage[2, ]))
+ expect_equal(x6$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x6$earlyStop[1, ]))
+ expect_equal(x6$earlyStop[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0(x6$earlyStop[2, ]))
+ expect_equal(x6$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x6$successPerStage[1, ]))
+ expect_equal(x6$successPerStage[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0(x6$successPerStage[2, ]))
+ expect_equal(x6$successPerStage[3, ], c(0.4, 0.5, 0.5, 0.4), tolerance = 1e-07, label = paste0(x6$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x6$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0, 0, 1, 0.1, 0.1, 1, 0.5, 0.4, 1, 0.1, 0, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0, 0, 1, 0.1, 0, 1, 0.4, 0.4, 1, 0.6, 0.5, 1, 0.8, 0.5, 1, 0.5, 0.3, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.7, 1, 1, 0.6), tolerance = 1e-07, label = paste0(unlist(as.list(x6$selectedArms))))
+ expect_equal(x6$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x6$numberOfActiveArms[1, ]))
+ expect_equal(x6$numberOfActiveArms[2, ], c(1.3, 1.2, 1.1, 1), tolerance = 1e-07, label = paste0(x6$numberOfActiveArms[2, ]))
+ expect_equal(x6$numberOfActiveArms[3, ], c(1.2, 1, 1, 1), tolerance = 1e-07, label = paste0(x6$numberOfActiveArms[3, ]))
+ expect_equal(x6$expectedNumberOfSubjects, c(436.56282, 365.15193, 284.70045, 253.12175), tolerance = 1e-07, label = paste0(x6$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x6$sampleSizes)), c(10, 4.7999536, 10, 10, 16.971175, 11.111111, 10, 0, 0, 10, 10, 16.666667, 10, 35.332961, 40, 10, 10, 0, 10, 21.400604, 22.595075, 10, 21.344686, 22.270265, 10, 23.218148, 30, 10, 22.202225, 23.298934, 10, 0, 0, 10, 10, 0, 10, 29.860691, 40, 10, 41.405234, 49.459866, 10, 62.809861, 31.890295, 10, 22.672359, 23.636115, 10, 73.351063, 100, 10, 73.607458, 83.869911, 10, 74.210465, 54.485369, 10, 64.017046, 62.573047), tolerance = 1e-07, label = paste0(unlist(as.list(x6$sampleSizes))))
+ expect_equal(x6$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x6$conditionalPowerAchieved[1, ]))
+ expect_equal(x6$conditionalPowerAchieved[2, ], c(0.024687171, 0.015314975, 0.045856815, 0.050229622), tolerance = 1e-07, label = paste0(x6$conditionalPowerAchieved[2, ]))
+ expect_equal(x6$conditionalPowerAchieved[3, ], c(0.1883251, 0.40048173, 0.51841906, 0.54348956), tolerance = 1e-07, label = paste0(x6$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x6), NA)))
+ expect_output(print(x6)$show())
+ invisible(capture.output(expect_error(summary(x6), NA)))
+ expect_output(summary(x6)$show())
+ x6CodeBased <- eval(parse(text = getObjectRCode(x6, stringWrapParagraphWidth = NULL)))
+ expect_equal(x6CodeBased$iterations, x6$iterations, tolerance = 1e-07)
+ expect_equal(x6CodeBased$rejectAtLeastOne, x6$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x6CodeBased$rejectedArmsPerStage, x6$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$futilityStop, x6$futilityStop, tolerance = 1e-07)
+ expect_equal(x6CodeBased$futilityPerStage, x6$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$earlyStop, x6$earlyStop, tolerance = 1e-07)
+ expect_equal(x6CodeBased$successPerStage, x6$successPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$selectedArms, x6$selectedArms, tolerance = 1e-07)
+ expect_equal(x6CodeBased$numberOfActiveArms, x6$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x6CodeBased$expectedNumberOfSubjects, x6$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x6CodeBased$sampleSizes, x6$sampleSizes, tolerance = 1e-07)
+ expect_equal(x6CodeBased$conditionalPowerAchieved, x6$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x6), "character")
+ df <- as.data.frame(x6)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x6)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x7 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x7' with expected results
+ expect_equal(x7$iterations[1, ], c(10, 10, 10, 10), label = paste0(x7$iterations[1, ]))
+ expect_equal(x7$iterations[2, ], c(10, 10, 10, 10), label = paste0(x7$iterations[2, ]))
+ expect_equal(x7$iterations[3, ], c(9, 8, 8, 5), label = paste0(x7$iterations[3, ]))
+ expect_equal(x7$rejectAtLeastOne, c(0.2, 0.4, 0.7, 0.8), tolerance = 1e-07, label = paste0(x7$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x7$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.2, 0.1, 0, 0, 0.3, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.2, 0.2, 0, 0.3, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x7$rejectedArmsPerStage))))
+ expect_equal(x7$futilityStop, c(0, 0, 0, 0), label = paste0(x7$futilityStop))
+ expect_equal(x7$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x7$futilityPerStage[1, ]))
+ expect_equal(x7$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x7$futilityPerStage[2, ]))
+ expect_equal(x7$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x7$earlyStop[1, ]))
+ expect_equal(x7$earlyStop[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0(x7$earlyStop[2, ]))
+ expect_equal(x7$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x7$successPerStage[1, ]))
+ expect_equal(x7$successPerStage[2, ], c(0.1, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0(x7$successPerStage[2, ]))
+ expect_equal(x7$successPerStage[3, ], c(0.1, 0.2, 0.5, 0.3), tolerance = 1e-07, label = paste0(x7$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x7$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.5, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.3, 1, 0.6, 0.3, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x7$selectedArms))))
+ expect_equal(x7$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x7$numberOfActiveArms[1, ]))
+ expect_equal(x7$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x7$numberOfActiveArms[2, ]))
+ expect_equal(x7$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x7$numberOfActiveArms[3, ]))
+ expect_equal(x7$expectedNumberOfSubjects, c(222.21727, 277.8712, 297.53775, 227.3405), tolerance = 1e-07, label = paste0(x7$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x7$sampleSizes)), c(10, 1.1840544, 1.315616, 10, 10, 12.5, 10, 0.74314427, 0.92893034, 10, 0, 0, 10, 7.3350068, 8.1500075, 10, 26.989766, 33.737207, 10, 0, 0, 10, 21.344686, 40, 10, 2.6348908, 2.9276564, 10, 21.298615, 12.5, 10, 40, 50, 10, 10, 0, 10, 33.493936, 33.674217, 10, 4.3287276, 5.4109095, 10, 25.258173, 21.280514, 10, 23.39578, 27.859565, 10, 44.647888, 46.067497, 10, 62.617108, 64.148116, 10, 66.001318, 72.209444, 10, 54.740466, 67.859565), tolerance = 1e-07, label = paste0(unlist(as.list(x7$sampleSizes))))
+ expect_equal(x7$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x7$conditionalPowerAchieved[1, ]))
+ expect_equal(x7$conditionalPowerAchieved[2, ], c(0.046651357, 0.022479034, 0.083769211, 0.082365248), tolerance = 1e-07, label = paste0(x7$conditionalPowerAchieved[2, ]))
+ expect_equal(x7$conditionalPowerAchieved[3, ], c(0.39772697, 0.18083546, 0.60828997, 0.66318671), tolerance = 1e-07, label = paste0(x7$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x7), NA)))
+ expect_output(print(x7)$show())
+ invisible(capture.output(expect_error(summary(x7), NA)))
+ expect_output(summary(x7)$show())
+ x7CodeBased <- eval(parse(text = getObjectRCode(x7, stringWrapParagraphWidth = NULL)))
+ expect_equal(x7CodeBased$iterations, x7$iterations, tolerance = 1e-07)
+ expect_equal(x7CodeBased$rejectAtLeastOne, x7$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x7CodeBased$rejectedArmsPerStage, x7$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$futilityStop, x7$futilityStop, tolerance = 1e-07)
+ expect_equal(x7CodeBased$futilityPerStage, x7$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$earlyStop, x7$earlyStop, tolerance = 1e-07)
+ expect_equal(x7CodeBased$successPerStage, x7$successPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$selectedArms, x7$selectedArms, tolerance = 1e-07)
+ expect_equal(x7CodeBased$numberOfActiveArms, x7$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x7CodeBased$expectedNumberOfSubjects, x7$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x7CodeBased$sampleSizes, x7$sampleSizes, tolerance = 1e-07)
+ expect_equal(x7CodeBased$conditionalPowerAchieved, x7$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x7), "character")
+ df <- as.data.frame(x7)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x7)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x8 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
+ typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x8' with expected results
+ expect_equal(x8$iterations[1, ], c(10, 10, 10, 10), label = paste0(x8$iterations[1, ]))
+ expect_equal(x8$iterations[2, ], c(10, 10, 10, 10), label = paste0(x8$iterations[2, ]))
+ expect_equal(x8$iterations[3, ], c(10, 10, 10, 10), label = paste0(x8$iterations[3, ]))
+ expect_equal(x8$rejectAtLeastOne, c(0.3, 0.6, 1, 1), tolerance = 1e-07, label = paste0(x8$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x8$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0.2, 0, 0, 0.2, 0.3, 0, 0, 0, 0.1, 0, 0.2, 0, 0.4, 0.2, 0, 0.7, 0.2, 0, 0.2, 0.1, 0.1, 0.2, 0.3, 0, 0.7, 0.3, 0, 0.8, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x8$rejectedArmsPerStage))))
+ expect_equal(x8$futilityStop, c(0, 0, 0, 0), label = paste0(x8$futilityStop))
+ expect_equal(x8$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x8$futilityPerStage[1, ]))
+ expect_equal(x8$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x8$futilityPerStage[2, ]))
+ expect_equal(x8$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x8$earlyStop[1, ]))
+ expect_equal(x8$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x8$earlyStop[2, ]))
+ expect_equal(x8$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[1, ]))
+ expect_equal(x8$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[2, ]))
+ expect_equal(x8$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x8$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0(unlist(as.list(x8$selectedArms))))
+ expect_equal(x8$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[1, ]))
+ expect_equal(x8$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[2, ]))
+ expect_equal(x8$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[3, ]))
+ expect_equal(x8$expectedNumberOfSubjects, c(1050, 914.65115, 996.33236, 1027.6565), tolerance = 1e-07, label = paste0(x8$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x8$sampleSizes)), c(10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652, 10, 100, 100, 10, 86.465115, 86.465115, 10, 94.633236, 94.633236, 10, 97.765652, 97.765652), tolerance = 1e-07, label = paste0(unlist(as.list(x8$sampleSizes))))
+ expect_equal(x8$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x8$conditionalPowerAchieved[1, ]))
+ expect_equal(x8$conditionalPowerAchieved[2, ], c(0.015572779, 0.22941785, 0.084615364, 0.1668833), tolerance = 1e-07, label = paste0(x8$conditionalPowerAchieved[2, ]))
+ expect_equal(x8$conditionalPowerAchieved[3, ], c(0.10350918, 0.24229761, 0.63483372, 0.79913622), tolerance = 1e-07, label = paste0(x8$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x8), NA)))
+ expect_output(print(x8)$show())
+ invisible(capture.output(expect_error(summary(x8), NA)))
+ expect_output(summary(x8)$show())
+ x8CodeBased <- eval(parse(text = getObjectRCode(x8, stringWrapParagraphWidth = NULL)))
+ expect_equal(x8CodeBased$iterations, x8$iterations, tolerance = 1e-07)
+ expect_equal(x8CodeBased$rejectAtLeastOne, x8$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x8CodeBased$rejectedArmsPerStage, x8$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$futilityStop, x8$futilityStop, tolerance = 1e-07)
+ expect_equal(x8CodeBased$futilityPerStage, x8$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$earlyStop, x8$earlyStop, tolerance = 1e-07)
+ expect_equal(x8CodeBased$successPerStage, x8$successPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$selectedArms, x8$selectedArms, tolerance = 1e-07)
+ expect_equal(x8CodeBased$numberOfActiveArms, x8$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x8CodeBased$expectedNumberOfSubjects, x8$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x8CodeBased$sampleSizes, x8$sampleSizes, tolerance = 1e-07)
+ expect_equal(x8CodeBased$conditionalPowerAchieved, x8$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x8), "character")
+ df <- as.data.frame(x8)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x9 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
+ typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x9' with expected results
+ expect_equal(x9$iterations[1, ], c(10, 10, 10, 10), label = paste0(x9$iterations[1, ]))
+ expect_equal(x9$iterations[2, ], c(10, 10, 10, 10), label = paste0(x9$iterations[2, ]))
+ expect_equal(x9$iterations[3, ], c(10, 9, 8, 7), label = paste0(x9$iterations[3, ]))
+ expect_equal(x9$rejectAtLeastOne, c(0.4, 0.6, 0.7, 0.9), tolerance = 1e-07, label = paste0(x9$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x9$rejectedArmsPerStage)), c(0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.3, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0.5, 0, 0, 0.3, 0, 0, 0.2, 0.1, 0, 0.1, 0.1, 0, 0.1, 0, 0.1, 0.5, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x9$rejectedArmsPerStage))))
+ expect_equal(x9$futilityStop, c(0, 0, 0, 0), label = paste0(x9$futilityStop))
+ expect_equal(x9$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x9$futilityPerStage[1, ]))
+ expect_equal(x9$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x9$futilityPerStage[2, ]))
+ expect_equal(x9$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x9$earlyStop[1, ]))
+ expect_equal(x9$earlyStop[2, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0(x9$earlyStop[2, ]))
+ expect_equal(x9$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x9$successPerStage[1, ]))
+ expect_equal(x9$successPerStage[2, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0(x9$successPerStage[2, ]))
+ expect_equal(x9$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x9$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x9$selectedArms)), c(1, 0.5, 0.5, 1, 0.7, 0.6, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.9, 0.7, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.6, 0.4, 1, 0.4, 0.1, 1, 0.7, 0.7, 1, 0.5, 0.4, 1, 0.4, 0.4, 1, 0.9, 0.6, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.7), tolerance = 1e-07, label = paste0(unlist(as.list(x9$selectedArms))))
+ expect_equal(x9$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x9$numberOfActiveArms[1, ]))
+ expect_equal(x9$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x9$numberOfActiveArms[2, ]))
+ expect_equal(x9$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x9$numberOfActiveArms[3, ]))
+ expect_equal(x9$expectedNumberOfSubjects, c(541.86022, 465.03543, 438.85623, 427.93855), tolerance = 1e-07, label = paste0(x9$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x9$sampleSizes)), c(10, 42.315846, 42.315846, 10, 43.044196, 41.478749, 10, 10, 12.5, 10, 28.887554, 41.267934, 10, 15.358913, 15.358913, 10, 21.683959, 24.093288, 10, 70.857557, 63.571946, 10, 27.933797, 39.905424, 10, 46.61779, 46.61779, 10, 34.631951, 38.479946, 10, 49.194842, 36.493552, 10, 31.168408, 1.6691539, 10, 59.660857, 59.660857, 10, 44.698358, 43.316707, 10, 19.566345, 24.457932, 10, 67.989758, 54.271083, 10, 81.976703, 81.976703, 10, 72.029232, 73.684344, 10, 74.809372, 68.511715, 10, 77.989758, 68.556797), tolerance = 1e-07, label = paste0(unlist(as.list(x9$sampleSizes))))
+ expect_equal(x9$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x9$conditionalPowerAchieved[1, ]))
+ expect_equal(x9$conditionalPowerAchieved[2, ], c(0.085169097, 0.1203719, 0.19239671, 0.15260753), tolerance = 1e-07, label = paste0(x9$conditionalPowerAchieved[2, ]))
+ expect_equal(x9$conditionalPowerAchieved[3, ], c(0.20442999, 0.2985599, 0.51072411, 0.55234699), tolerance = 1e-07, label = paste0(x9$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x9), NA)))
+ expect_output(print(x9)$show())
+ invisible(capture.output(expect_error(summary(x9), NA)))
+ expect_output(summary(x9)$show())
+ x9CodeBased <- eval(parse(text = getObjectRCode(x9, stringWrapParagraphWidth = NULL)))
+ expect_equal(x9CodeBased$iterations, x9$iterations, tolerance = 1e-07)
+ expect_equal(x9CodeBased$rejectAtLeastOne, x9$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x9CodeBased$rejectedArmsPerStage, x9$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$futilityStop, x9$futilityStop, tolerance = 1e-07)
+ expect_equal(x9CodeBased$futilityPerStage, x9$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$earlyStop, x9$earlyStop, tolerance = 1e-07)
+ expect_equal(x9CodeBased$successPerStage, x9$successPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$selectedArms, x9$selectedArms, tolerance = 1e-07)
+ expect_equal(x9CodeBased$numberOfActiveArms, x9$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x9CodeBased$expectedNumberOfSubjects, x9$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x9CodeBased$sampleSizes, x9$sampleSizes, tolerance = 1e-07)
+ expect_equal(x9CodeBased$conditionalPowerAchieved, x9$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x9), "character")
+ df <- as.data.frame(x9)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x9)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x10 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4,
+ typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x10' with expected results
+ expect_equal(x10$iterations[1, ], c(10, 10, 10, 10), label = paste0(x10$iterations[1, ]))
+ expect_equal(x10$iterations[2, ], c(7, 8, 5, 9), label = paste0(x10$iterations[2, ]))
+ expect_equal(x10$iterations[3, ], c(7, 6, 4, 4), label = paste0(x10$iterations[3, ]))
+ expect_equal(x10$rejectAtLeastOne, c(0.2, 0.4, 0.2, 0.6), tolerance = 1e-07, label = paste0(x10$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x10$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0.1, 0.1, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x10$rejectedArmsPerStage))))
+ expect_equal(x10$futilityStop, c(0.3, 0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0(x10$futilityStop))
+ expect_equal(x10$futilityPerStage[1, ], c(0.3, 0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0(x10$futilityPerStage[1, ]))
+ expect_equal(x10$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x10$futilityPerStage[2, ]))
+ expect_equal(x10$earlyStop[1, ], c(0.3, 0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0(x10$earlyStop[1, ]))
+ expect_equal(x10$earlyStop[2, ], c(0, 0.2, 0.1, 0.5), tolerance = 1e-07, label = paste0(x10$earlyStop[2, ]))
+ expect_equal(x10$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x10$successPerStage[1, ]))
+ expect_equal(x10$successPerStage[2, ], c(0, 0.2, 0.1, 0.5), tolerance = 1e-07, label = paste0(x10$successPerStage[2, ]))
+ expect_equal(x10$successPerStage[3, ], c(0.2, 0.2, 0.1, 0), tolerance = 1e-07, label = paste0(x10$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x10$selectedArms)), c(1, 0.1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.1, 0, 1, 0.2, 0.2, 1, 0.2, 0, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0, 0, 1, 0.2, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.4, 0.3, 1, 0.3, 0.1, 1, 0.7, 0.7, 1, 0.8, 0.6, 1, 0.5, 0.4, 1, 0.9, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x10$selectedArms))))
+ expect_equal(x10$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x10$numberOfActiveArms[1, ]))
+ expect_equal(x10$numberOfActiveArms[2, ], c(1.2857143, 1.125, 1.2, 1.1111111), tolerance = 1e-07, label = paste0(x10$numberOfActiveArms[2, ]))
+ expect_equal(x10$numberOfActiveArms[3, ], c(1.2857143, 1.1666667, 1.25, 1.25), tolerance = 1e-07, label = paste0(x10$numberOfActiveArms[3, ]))
+ expect_equal(x10$expectedNumberOfSubjects, c(225.54374, 222.86662, 137.52897, 198.07751), tolerance = 1e-07, label = paste0(x10$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x10$sampleSizes)), c(10, 5.7796177, 5.7796177, 10, 0, 0, 10, 0, 0, 10, 21.972849, 49.43891, 10, 18.318062, 18.318062, 10, 4.015823, 0, 10, 19.919121, 24.898901, 10, 4.2855233, 0, 10, 4.0944014, 4.0944014, 10, 25.284305, 32.792226, 10, 0, 0, 10, 13.080039, 4.4300867, 10, 40.432794, 40.432794, 10, 33.32367, 44.431559, 10, 42.475692, 28.104858, 10, 18.985094, 14.869399, 10, 56.76351, 56.76351, 10, 50.123797, 60.557119, 10, 45.125964, 31.417698, 10, 51.714883, 53.868997), tolerance = 1e-07, label = paste0(unlist(as.list(x10$sampleSizes))))
+ expect_equal(x10$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x10$conditionalPowerAchieved[1, ]))
+ expect_equal(x10$conditionalPowerAchieved[2, ], c(0.051011725, 0.14528092, 0.099325934, 0.10008765), tolerance = 1e-07, label = paste0(x10$conditionalPowerAchieved[2, ]))
+ expect_equal(x10$conditionalPowerAchieved[3, ], c(0.1199627, 0.35325827, 0.33382798, 0.10956309), tolerance = 1e-07, label = paste0(x10$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x10), NA)))
+ expect_output(print(x10)$show())
+ invisible(capture.output(expect_error(summary(x10), NA)))
+ expect_output(summary(x10)$show())
+ x10CodeBased <- eval(parse(text = getObjectRCode(x10, stringWrapParagraphWidth = NULL)))
+ expect_equal(x10CodeBased$iterations, x10$iterations, tolerance = 1e-07)
+ expect_equal(x10CodeBased$rejectAtLeastOne, x10$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x10CodeBased$rejectedArmsPerStage, x10$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$futilityStop, x10$futilityStop, tolerance = 1e-07)
+ expect_equal(x10CodeBased$futilityPerStage, x10$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$earlyStop, x10$earlyStop, tolerance = 1e-07)
+ expect_equal(x10CodeBased$successPerStage, x10$successPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$selectedArms, x10$selectedArms, tolerance = 1e-07)
+ expect_equal(x10CodeBased$numberOfActiveArms, x10$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x10CodeBased$expectedNumberOfSubjects, x10$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x10CodeBased$sampleSizes, x10$sampleSizes, tolerance = 1e-07)
+ expect_equal(x10CodeBased$conditionalPowerAchieved, x10$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x10), "character")
+ df <- as.data.frame(x10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x11 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x11' with expected results
+ expect_equal(x11$iterations[1, ], c(10, 10, 10), label = paste0(x11$iterations[1, ]))
+ expect_equal(x11$iterations[2, ], c(9, 6, 6), label = paste0(x11$iterations[2, ]))
+ expect_equal(x11$iterations[3, ], c(9, 5, 4), label = paste0(x11$iterations[3, ]))
+ expect_equal(x11$rejectAtLeastOne, c(0, 0, 0.1), tolerance = 1e-07, label = paste0(x11$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x11$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x11$rejectedArmsPerStage))))
+ expect_equal(x11$futilityStop, c(0.1, 0.5, 0.6), tolerance = 1e-07, label = paste0(x11$futilityStop))
+ expect_equal(x11$futilityPerStage[1, ], c(0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0(x11$futilityPerStage[1, ]))
+ expect_equal(x11$futilityPerStage[2, ], c(0, 0.1, 0.2), tolerance = 1e-07, label = paste0(x11$futilityPerStage[2, ]))
+ expect_equal(x11$earlyStop[1, ], c(0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0(x11$earlyStop[1, ]))
+ expect_equal(x11$earlyStop[2, ], c(0, 0.1, 0.2), tolerance = 1e-07, label = paste0(x11$earlyStop[2, ]))
+ expect_equal(x11$successPerStage[1, ], c(0, 0, 0), label = paste0(x11$successPerStage[1, ]))
+ expect_equal(x11$successPerStage[2, ], c(0, 0, 0), label = paste0(x11$successPerStage[2, ]))
+ expect_equal(x11$successPerStage[3, ], c(0, 0, 0.1), tolerance = 1e-07, label = paste0(x11$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x11$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.3, 0.3, 1, 0.3, 0.2, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.9, 0.9, 1, 0.6, 0.5, 1, 0.6, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x11$selectedArms))))
+ expect_equal(x11$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0(x11$numberOfActiveArms[1, ]))
+ expect_equal(x11$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0(x11$numberOfActiveArms[2, ]))
+ expect_equal(x11$numberOfActiveArms[3, ], c(1, 1, 1), label = paste0(x11$numberOfActiveArms[3, ]))
+ expect_equal(x11$expectedNumberOfSubjects, c(293.83569, 240.03958, 175.41029), tolerance = 1e-07, label = paste0(x11$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x11$sampleSizes)), c(10, 1.428489, 11.111111, 10, 16.666667, 20, 10, 10.322237, 0, 10, 9.8699583, 33.333333, 10, 41.973847, 40, 10, 21.511686, 25, 10, 15.186109, 22.222222, 10, 6.5876644, 11.765765, 10, 17.33069, 33.465374, 10, 17.556106, 24.756944, 10, 16.666667, 20, 10, 2.0321899, 21.502286, 10, 44.040662, 91.42361, 10, 81.894844, 91.765765, 10, 51.196803, 79.96766), tolerance = 1e-07, label = paste0(unlist(as.list(x11$sampleSizes))))
+ expect_equal(x11$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x11$conditionalPowerAchieved[1, ]))
+ expect_equal(x11$conditionalPowerAchieved[2, ], c(0.038698548, 0.10704476, 0.043430379), tolerance = 1e-07, label = paste0(x11$conditionalPowerAchieved[2, ]))
+ expect_equal(x11$conditionalPowerAchieved[3, ], c(0.30869297, 0.27823314, 0.60162296), tolerance = 1e-07, label = paste0(x11$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x11), NA)))
+ expect_output(print(x11)$show())
+ invisible(capture.output(expect_error(summary(x11), NA)))
+ expect_output(summary(x11)$show())
+ x11CodeBased <- eval(parse(text = getObjectRCode(x11, stringWrapParagraphWidth = NULL)))
+ expect_equal(x11CodeBased$iterations, x11$iterations, tolerance = 1e-07)
+ expect_equal(x11CodeBased$rejectAtLeastOne, x11$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x11CodeBased$rejectedArmsPerStage, x11$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$futilityStop, x11$futilityStop, tolerance = 1e-07)
+ expect_equal(x11CodeBased$futilityPerStage, x11$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$earlyStop, x11$earlyStop, tolerance = 1e-07)
+ expect_equal(x11CodeBased$successPerStage, x11$successPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$selectedArms, x11$selectedArms, tolerance = 1e-07)
+ expect_equal(x11CodeBased$numberOfActiveArms, x11$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x11CodeBased$expectedNumberOfSubjects, x11$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x11CodeBased$sampleSizes, x11$sampleSizes, tolerance = 1e-07)
+ expect_equal(x11CodeBased$conditionalPowerAchieved, x11$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x11), "character")
+ df <- as.data.frame(x11)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x11)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x12 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x12' with expected results
+ expect_equal(x12$iterations[1, ], c(10, 10, 10, 10), label = paste0(x12$iterations[1, ]))
+ expect_equal(x12$iterations[2, ], c(10, 6, 8, 8), label = paste0(x12$iterations[2, ]))
+ expect_equal(x12$iterations[3, ], c(8, 5, 1, 2), label = paste0(x12$iterations[3, ]))
+ expect_equal(x12$rejectAtLeastOne, c(0.3, 0.1, 0.7, 0.7), tolerance = 1e-07, label = paste0(x12$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x12$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0.1, 0, 0.1, 0, 0.2, 0.3, 0, 0.1, 0.3, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x12$rejectedArmsPerStage))))
+ expect_equal(x12$futilityStop, c(0, 0.4, 0.2, 0.2), tolerance = 1e-07, label = paste0(x12$futilityStop))
+ expect_equal(x12$futilityPerStage[1, ], c(0, 0.4, 0.2, 0.2), tolerance = 1e-07, label = paste0(x12$futilityPerStage[1, ]))
+ expect_equal(x12$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x12$futilityPerStage[2, ]))
+ expect_equal(x12$earlyStop[1, ], c(0, 0.4, 0.2, 0.2), tolerance = 1e-07, label = paste0(x12$earlyStop[1, ]))
+ expect_equal(x12$earlyStop[2, ], c(0.2, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0(x12$earlyStop[2, ]))
+ expect_equal(x12$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x12$successPerStage[1, ]))
+ expect_equal(x12$successPerStage[2, ], c(0.2, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0(x12$successPerStage[2, ]))
+ expect_equal(x12$successPerStage[3, ], c(0.1, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x12$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x12$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0, 0, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0, 1, 0.3, 0.2, 1, 0.5, 0.3, 1, 0.2, 0.1, 1, 0.6, 0.1, 1, 0.4, 0, 1, 1, 0.8, 1, 0.6, 0.5, 1, 0.8, 0.1, 1, 0.8, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x12$selectedArms))))
+ expect_equal(x12$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x12$numberOfActiveArms[1, ]))
+ expect_equal(x12$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x12$numberOfActiveArms[2, ]))
+ expect_equal(x12$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x12$numberOfActiveArms[3, ]))
+ expect_equal(x12$expectedNumberOfSubjects, c(270.86167, 201.58944, 127.72687, 185.63922), tolerance = 1e-07, label = paste0(x12$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x12$sampleSizes)), c(10, 1.1167748, 12.5, 10, 8.9578499, 20, 10, 0.5, 0, 10, 0, 0, 10, 6.7277808, 32.819107, 10, 6.3724427, 20, 10, 0, 0, 10, 12.5, 0, 10, 2.4005123, 12.5, 10, 12.766635, 29.774077, 10, 11.503905, 0, 10, 27.658054, 100, 10, 28.865098, 31.331731, 10, 23.415877, 20, 10, 24.075387, 100, 10, 19.616461, 0, 10, 39.110166, 89.150838, 10, 51.512805, 89.774077, 10, 36.079292, 100, 10, 59.774515, 100), tolerance = 1e-07, label = paste0(unlist(as.list(x12$sampleSizes))))
+ expect_equal(x12$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x12$conditionalPowerAchieved[1, ]))
+ expect_equal(x12$conditionalPowerAchieved[2, ], c(0.064552587, 0.074113563, 0.13271614, 0.12195746), tolerance = 1e-07, label = paste0(x12$conditionalPowerAchieved[2, ]))
+ expect_equal(x12$conditionalPowerAchieved[3, ], c(0.41775137, 0.42792704, 0.6049542, 0.13870598), tolerance = 1e-07, label = paste0(x12$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x12), NA)))
+ expect_output(print(x12)$show())
+ invisible(capture.output(expect_error(summary(x12), NA)))
+ expect_output(summary(x12)$show())
+ x12CodeBased <- eval(parse(text = getObjectRCode(x12, stringWrapParagraphWidth = NULL)))
+ expect_equal(x12CodeBased$iterations, x12$iterations, tolerance = 1e-07)
+ expect_equal(x12CodeBased$rejectAtLeastOne, x12$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x12CodeBased$rejectedArmsPerStage, x12$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$futilityStop, x12$futilityStop, tolerance = 1e-07)
+ expect_equal(x12CodeBased$futilityPerStage, x12$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$earlyStop, x12$earlyStop, tolerance = 1e-07)
+ expect_equal(x12CodeBased$successPerStage, x12$successPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$selectedArms, x12$selectedArms, tolerance = 1e-07)
+ expect_equal(x12CodeBased$numberOfActiveArms, x12$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x12CodeBased$expectedNumberOfSubjects, x12$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x12CodeBased$sampleSizes, x12$sampleSizes, tolerance = 1e-07)
+ expect_equal(x12CodeBased$conditionalPowerAchieved, x12$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x12), "character")
+ df <- as.data.frame(x12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x13 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "userDefined", activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, adaptations = rep(TRUE, 2),
+ effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4), intersectionTest = "Sidak",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x13' with expected results
+ expect_equal(x13$iterations[1, ], c(10, 10), label = paste0(x13$iterations[1, ]))
+ expect_equal(x13$iterations[2, ], c(10, 9), label = paste0(x13$iterations[2, ]))
+ expect_equal(x13$iterations[3, ], c(7, 7), label = paste0(x13$iterations[3, ]))
+ expect_equal(x13$rejectAtLeastOne, c(0.3, 0.3), tolerance = 1e-07, label = paste0(x13$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x13$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x13$rejectedArmsPerStage))))
+ expect_equal(x13$futilityStop, c(0, 0.1), tolerance = 1e-07, label = paste0(x13$futilityStop))
+ expect_equal(x13$futilityPerStage[1, ], c(0, 0.1), tolerance = 1e-07, label = paste0(x13$futilityPerStage[1, ]))
+ expect_equal(x13$futilityPerStage[2, ], c(0, 0), label = paste0(x13$futilityPerStage[2, ]))
+ expect_equal(x13$earlyStop[1, ], c(0, 0.1), tolerance = 1e-07, label = paste0(x13$earlyStop[1, ]))
+ expect_equal(x13$earlyStop[2, ], c(0.3, 0.2), tolerance = 1e-07, label = paste0(x13$earlyStop[2, ]))
+ expect_equal(x13$successPerStage[1, ], c(0, 0), label = paste0(x13$successPerStage[1, ]))
+ expect_equal(x13$successPerStage[2, ], c(0.3, 0.2), tolerance = 1e-07, label = paste0(x13$successPerStage[2, ]))
+ expect_equal(x13$successPerStage[3, ], c(0, 0.1), tolerance = 1e-07, label = paste0(x13$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x13$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.5, 0.4, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.2, 1, 0.2, 0.1, 1, 1, 0.7, 1, 0.9, 0.7), tolerance = 1e-07, label = paste0(unlist(as.list(x13$selectedArms))))
+ expect_equal(x13$numberOfActiveArms[1, ], c(4, 4), label = paste0(x13$numberOfActiveArms[1, ]))
+ expect_equal(x13$numberOfActiveArms[2, ], c(1, 1), label = paste0(x13$numberOfActiveArms[2, ]))
+ expect_equal(x13$numberOfActiveArms[3, ], c(1, 1), label = paste0(x13$numberOfActiveArms[3, ]))
+ expect_equal(x13$expectedNumberOfSubjects, c(238.16649, 275.50348), tolerance = 1e-07, label = paste0(x13$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x13$sampleSizes)), c(10, 1.0395374, 14.285714, 10, 4.3933102, 11.199547, 10, 4.4634729, 31.899994, 10, 38.793234, 57.142857, 10, 2.5722467, 14.285714, 10, 5.3695979, 6.9814836, 10, 23.677991, 28.571429, 10, 11.241946, 8.8667681, 10, 31.753247, 89.042851, 10, 59.798088, 84.190656), tolerance = 1e-07, label = paste0(unlist(as.list(x13$sampleSizes))))
+ expect_equal(x13$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0(x13$conditionalPowerAchieved[1, ]))
+ expect_equal(x13$conditionalPowerAchieved[2, ], c(0.095374468, 0.085831831), tolerance = 1e-07, label = paste0(x13$conditionalPowerAchieved[2, ]))
+ expect_equal(x13$conditionalPowerAchieved[3, ], c(0.56669649, 0.49770257), tolerance = 1e-07, label = paste0(x13$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x13), NA)))
+ expect_output(print(x13)$show())
+ invisible(capture.output(expect_error(summary(x13), NA)))
+ expect_output(summary(x13)$show())
+ x13CodeBased <- eval(parse(text = getObjectRCode(x13, stringWrapParagraphWidth = NULL)))
+ expect_equal(x13CodeBased$iterations, x13$iterations, tolerance = 1e-07)
+ expect_equal(x13CodeBased$rejectAtLeastOne, x13$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x13CodeBased$rejectedArmsPerStage, x13$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$futilityStop, x13$futilityStop, tolerance = 1e-07)
+ expect_equal(x13CodeBased$futilityPerStage, x13$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$earlyStop, x13$earlyStop, tolerance = 1e-07)
+ expect_equal(x13CodeBased$successPerStage, x13$successPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$selectedArms, x13$selectedArms, tolerance = 1e-07)
+ expect_equal(x13CodeBased$numberOfActiveArms, x13$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x13CodeBased$expectedNumberOfSubjects, x13$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x13CodeBased$sampleSizes, x13$sampleSizes, tolerance = 1e-07)
+ expect_equal(x13CodeBased$conditionalPowerAchieved, x13$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x13), "character")
+ df <- as.data.frame(x13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x14 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x14' with expected results
+ expect_equal(x14$iterations[1, ], c(10, 10, 10, 10), label = paste0(x14$iterations[1, ]))
+ expect_equal(x14$iterations[2, ], c(10, 9, 8, 10), label = paste0(x14$iterations[2, ]))
+ expect_equal(x14$iterations[3, ], c(9, 9, 6, 7), label = paste0(x14$iterations[3, ]))
+ expect_equal(x14$rejectAtLeastOne, c(0.1, 0, 0.3, 0.4), tolerance = 1e-07, label = paste0(x14$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x14$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.1, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x14$rejectedArmsPerStage))))
+ expect_equal(x14$futilityStop, c(0, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x14$futilityStop))
+ expect_equal(x14$futilityPerStage[1, ], c(0, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x14$futilityPerStage[1, ]))
+ expect_equal(x14$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x14$futilityPerStage[2, ]))
+ expect_equal(x14$earlyStop[1, ], c(0, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x14$earlyStop[1, ]))
+ expect_equal(x14$earlyStop[2, ], c(0.1, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0(x14$earlyStop[2, ]))
+ expect_equal(x14$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[1, ]))
+ expect_equal(x14$successPerStage[2, ], c(0.1, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0(x14$successPerStage[2, ]))
+ expect_equal(x14$successPerStage[3, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x14$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x14$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.4, 0.3, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.2, 1, 1, 0.9, 1, 0.9, 0.9, 1, 0.8, 0.6, 1, 1, 0.7), tolerance = 1e-07, label = paste0(unlist(as.list(x14$selectedArms))))
+ expect_equal(x14$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x14$numberOfActiveArms[1, ]))
+ expect_equal(x14$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x14$numberOfActiveArms[2, ]))
+ expect_equal(x14$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x14$numberOfActiveArms[3, ]))
+ expect_equal(x14$expectedNumberOfSubjects, c(302.82831, 359.55539, 205.66054, 326.21609), tolerance = 1e-07, label = paste0(x14$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x14$sampleSizes)), c(10, 0.96871141, 11.111111, 10, 4.8692533, 11.111111, 10, 0.5, 0, 10, 30, 42.857143, 10, 6.7277808, 29.172539, 10, 37.581628, 44.444444, 10, 12.5, 16.666667, 10, 10, 0, 10, 12.834638, 22.222222, 10, 21.991558, 33.249006, 10, 17.610119, 16.666667, 10, 12.962323, 28.571429, 10, 24.585127, 27.825125, 10, 7.6171061, 11.111111, 10, 20.182233, 28.660644, 10, 22.561443, 17.977538, 10, 45.116257, 90.330997, 10, 72.059546, 99.915673, 10, 50.792352, 61.993977, 10, 75.523767, 89.406109), tolerance = 1e-07, label = paste0(unlist(as.list(x14$sampleSizes))))
+ expect_equal(x14$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x14$conditionalPowerAchieved[1, ]))
+ expect_equal(x14$conditionalPowerAchieved[2, ], c(0.054394525, 0.033810654, 0.16623293, 0.07472066), tolerance = 1e-07, label = paste0(x14$conditionalPowerAchieved[2, ]))
+ expect_equal(x14$conditionalPowerAchieved[3, ], c(0.39787587, 0.27550431, 0.64928935, 0.24074486), tolerance = 1e-07, label = paste0(x14$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x14), NA)))
+ expect_output(print(x14)$show())
+ invisible(capture.output(expect_error(summary(x14), NA)))
+ expect_output(summary(x14)$show())
+ x14CodeBased <- eval(parse(text = getObjectRCode(x14, stringWrapParagraphWidth = NULL)))
+ expect_equal(x14CodeBased$iterations, x14$iterations, tolerance = 1e-07)
+ expect_equal(x14CodeBased$rejectAtLeastOne, x14$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x14CodeBased$rejectedArmsPerStage, x14$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$futilityStop, x14$futilityStop, tolerance = 1e-07)
+ expect_equal(x14CodeBased$futilityPerStage, x14$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$earlyStop, x14$earlyStop, tolerance = 1e-07)
+ expect_equal(x14CodeBased$successPerStage, x14$successPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$selectedArms, x14$selectedArms, tolerance = 1e-07)
+ expect_equal(x14CodeBased$numberOfActiveArms, x14$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x14CodeBased$expectedNumberOfSubjects, x14$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x14CodeBased$sampleSizes, x14$sampleSizes, tolerance = 1e-07)
+ expect_equal(x14CodeBased$conditionalPowerAchieved, x14$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x14), "character")
+ df <- as.data.frame(x14)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x14)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x15 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x15' with expected results
+ expect_equal(x15$iterations[1, ], c(10, 10, 10, 10), label = paste0(x15$iterations[1, ]))
+ expect_equal(x15$iterations[2, ], c(10, 9, 9, 10), label = paste0(x15$iterations[2, ]))
+ expect_equal(x15$iterations[3, ], c(10, 8, 8, 10), label = paste0(x15$iterations[3, ]))
+ expect_equal(x15$rejectAtLeastOne, c(0.1, 0.6, 0.9, 1), tolerance = 1e-07, label = paste0(x15$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x15$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.2, 0, 0.1, 0.2, 0, 0, 0, 0, 0.2, 0.1, 0, 0.3, 0.3, 0, 0.3, 0.4, 0, 0.1, 0, 0, 0.3, 0.1, 0, 0.5, 0.2, 0.1, 0.4, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x15$rejectedArmsPerStage))))
+ expect_equal(x15$futilityStop, c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x15$futilityStop))
+ expect_equal(x15$futilityPerStage[1, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x15$futilityPerStage[1, ]))
+ expect_equal(x15$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x15$futilityPerStage[2, ]))
+ expect_equal(x15$earlyStop[1, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x15$earlyStop[1, ]))
+ expect_equal(x15$earlyStop[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x15$earlyStop[2, ]))
+ expect_equal(x15$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x15$successPerStage[1, ]))
+ expect_equal(x15$successPerStage[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x15$successPerStage[2, ]))
+ expect_equal(x15$successPerStage[3, ], c(0, 0, 0.3, 0.3), tolerance = 1e-07, label = paste0(x15$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x15$selectedArms)), c(1, 0.6, 0.6, 1, 0.6, 0.5, 1, 0.2, 0.1, 1, 0.7, 0.5, 1, 0.7, 0.6, 1, 0.8, 0.7, 1, 0.7, 0.7, 1, 0.7, 0.7, 1, 0.7, 0.7, 1, 0.8, 0.7, 1, 0.7, 0.7, 1, 0.9, 0.9, 1, 0.6, 0.6, 1, 0.6, 0.5, 1, 0.7, 0.6, 1, 0.8, 0.8, 1, 1, 1, 1, 0.9, 0.8, 1, 0.9, 0.8, 1, 1, 1), tolerance = 1e-07, label = paste0(unlist(as.list(x15$selectedArms))))
+ expect_equal(x15$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x15$numberOfActiveArms[1, ]))
+ expect_equal(x15$numberOfActiveArms[2, ], c(2.6, 3.1111111, 2.5555556, 3.1), tolerance = 1e-07, label = paste0(x15$numberOfActiveArms[2, ]))
+ expect_equal(x15$numberOfActiveArms[3, ], c(2.5, 3, 2.625, 2.9), tolerance = 1e-07, label = paste0(x15$numberOfActiveArms[3, ]))
+ expect_equal(x15$expectedNumberOfSubjects, c(690.38911, 619.77858, 554.02061, 670.88154), tolerance = 1e-07, label = paste0(x15$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x15$sampleSizes)), c(10, 54.180167, 50.4, 10, 57.917242, 50.5, 10, 16.188147, 12.5, 10, 64.800747, 25.135561, 10, 65.454083, 50.4, 10, 71.01474, 75.5, 10, 71.743702, 62.866861, 10, 64.800747, 45.135561, 10, 69.120607, 60.4, 10, 71.01474, 75.5, 10, 71.743702, 62.866861, 10, 84.800747, 55.535561, 10, 55.454083, 50.4, 10, 48.792518, 50.5, 10, 71.743702, 50.366861, 10, 74.800747, 45.535561, 10, 94.180167, 90.4, 10, 82.125851, 88, 10, 93.965925, 75.366861, 10, 94.800747, 65.535561), tolerance = 1e-07, label = paste0(unlist(as.list(x15$sampleSizes))))
+ expect_equal(x15$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x15$conditionalPowerAchieved[1, ]))
+ expect_equal(x15$conditionalPowerAchieved[2, ], c(0.086326519, 0.23897424, 0.15375141, 0.19252038), tolerance = 1e-07, label = paste0(x15$conditionalPowerAchieved[2, ]))
+ expect_equal(x15$conditionalPowerAchieved[3, ], c(0.19907656, 0.37086672, 0.52811383, 0.57866018), tolerance = 1e-07, label = paste0(x15$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x15), NA)))
+ expect_output(print(x15)$show())
+ invisible(capture.output(expect_error(summary(x15), NA)))
+ expect_output(summary(x15)$show())
+ x15CodeBased <- eval(parse(text = getObjectRCode(x15, stringWrapParagraphWidth = NULL)))
+ expect_equal(x15CodeBased$iterations, x15$iterations, tolerance = 1e-07)
+ expect_equal(x15CodeBased$rejectAtLeastOne, x15$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x15CodeBased$rejectedArmsPerStage, x15$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$futilityStop, x15$futilityStop, tolerance = 1e-07)
+ expect_equal(x15CodeBased$futilityPerStage, x15$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$earlyStop, x15$earlyStop, tolerance = 1e-07)
+ expect_equal(x15CodeBased$successPerStage, x15$successPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$selectedArms, x15$selectedArms, tolerance = 1e-07)
+ expect_equal(x15CodeBased$numberOfActiveArms, x15$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x15CodeBased$expectedNumberOfSubjects, x15$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x15CodeBased$sampleSizes, x15$sampleSizes, tolerance = 1e-07)
+ expect_equal(x15CodeBased$conditionalPowerAchieved, x15$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x15), "character")
+ df <- as.data.frame(x15)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x15)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x16 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Simes",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x16' with expected results
+ expect_equal(x16$iterations[1, ], c(10, 10, 10, 10), label = paste0(x16$iterations[1, ]))
+ expect_equal(x16$iterations[2, ], c(8, 8, 9, 10), label = paste0(x16$iterations[2, ]))
+ expect_equal(x16$iterations[3, ], c(8, 8, 8, 7), label = paste0(x16$iterations[3, ]))
+ expect_equal(x16$rejectAtLeastOne, c(0.1, 0.5, 0.7, 0.8), tolerance = 1e-07, label = paste0(x16$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x16$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0.2, 0.1, 0, 0.1, 0, 0.1, 0.2, 0.2, 0, 0.1, 0.4, 0.1, 0.6, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x16$rejectedArmsPerStage))))
+ expect_equal(x16$futilityStop, c(0.2, 0.2, 0.1, 0), tolerance = 1e-07, label = paste0(x16$futilityStop))
+ expect_equal(x16$futilityPerStage[1, ], c(0.2, 0.2, 0.1, 0), tolerance = 1e-07, label = paste0(x16$futilityPerStage[1, ]))
+ expect_equal(x16$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x16$futilityPerStage[2, ]))
+ expect_equal(x16$earlyStop[1, ], c(0.2, 0.2, 0.1, 0), tolerance = 1e-07, label = paste0(x16$earlyStop[1, ]))
+ expect_equal(x16$earlyStop[2, ], c(0, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0(x16$earlyStop[2, ]))
+ expect_equal(x16$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x16$successPerStage[1, ]))
+ expect_equal(x16$successPerStage[2, ], c(0, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0(x16$successPerStage[2, ]))
+ expect_equal(x16$successPerStage[3, ], c(0.1, 0.1, 0.2, 0.1), tolerance = 1e-07, label = paste0(x16$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x16$selectedArms)), c(1, 0.2, 0.1, 1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.3, 0.2, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.5, 0.3, 1, 0.8, 0.8, 1, 0.7, 0.7, 1, 0.5, 0.5, 1, 0.7, 0.4, 1, 0.8, 0.8, 1, 0.8, 0.8, 1, 0.9, 0.8, 1, 1, 0.7), tolerance = 1e-07, label = paste0(unlist(as.list(x16$selectedArms))))
+ expect_equal(x16$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x16$numberOfActiveArms[1, ]))
+ expect_equal(x16$numberOfActiveArms[2, ], c(2, 2, 1.7777778, 1.8), tolerance = 1e-07, label = paste0(x16$numberOfActiveArms[2, ]))
+ expect_equal(x16$numberOfActiveArms[3, ], c(1.875, 2, 1.75, 1.8571429), tolerance = 1e-07, label = paste0(x16$numberOfActiveArms[3, ]))
+ expect_equal(x16$expectedNumberOfSubjects, c(485.19749, 377.01763, 431.09127, 345.60572), tolerance = 1e-07, label = paste0(x16$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x16$sampleSizes)), c(10, 25, 12.5, 10, 52.984739, 51, 10, 38.255848, 50, 10, 5.1691192, 14.285714, 10, 28.803833, 37.5, 10, 25, 25, 10, 24.228929, 11.497164, 10, 28.635967, 34.757362, 10, 31.69512, 37.5, 10, 5.6938105, 1.5787961, 10, 40.9155, 37.5, 10, 42.851335, 17.605103, 10, 85.498953, 100, 10, 58.678549, 52.578796, 10, 35.341046, 48.997164, 10, 50.953751, 18.295116, 10, 85.498953, 100, 10, 71.178549, 65.078796, 10, 76.256545, 86.497164, 10, 73.805086, 49.614505), tolerance = 1e-07, label = paste0(unlist(as.list(x16$sampleSizes))))
+ expect_equal(x16$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x16$conditionalPowerAchieved[1, ]))
+ expect_equal(x16$conditionalPowerAchieved[2, ], c(0.017664185, 0.17480419, 0.093445917, 0.088580327), tolerance = 1e-07, label = paste0(x16$conditionalPowerAchieved[2, ]))
+ expect_equal(x16$conditionalPowerAchieved[3, ], c(0.16524243, 0.38443342, 0.48058247, 0.6510419), tolerance = 1e-07, label = paste0(x16$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x16), NA)))
+ expect_output(print(x16)$show())
+ invisible(capture.output(expect_error(summary(x16), NA)))
+ expect_output(summary(x16)$show())
+ x16CodeBased <- eval(parse(text = getObjectRCode(x16, stringWrapParagraphWidth = NULL)))
+ expect_equal(x16CodeBased$iterations, x16$iterations, tolerance = 1e-07)
+ expect_equal(x16CodeBased$rejectAtLeastOne, x16$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x16CodeBased$rejectedArmsPerStage, x16$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$futilityStop, x16$futilityStop, tolerance = 1e-07)
+ expect_equal(x16CodeBased$futilityPerStage, x16$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$earlyStop, x16$earlyStop, tolerance = 1e-07)
+ expect_equal(x16CodeBased$successPerStage, x16$successPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$selectedArms, x16$selectedArms, tolerance = 1e-07)
+ expect_equal(x16CodeBased$numberOfActiveArms, x16$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x16CodeBased$expectedNumberOfSubjects, x16$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x16CodeBased$sampleSizes, x16$sampleSizes, tolerance = 1e-07)
+ expect_equal(x16CodeBased$conditionalPowerAchieved, x16$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x16), "character")
+ df <- as.data.frame(x16)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x16)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x17 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Simes",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x17' with expected results
+ expect_equal(x17$iterations[1, ], c(10, 10, 10, 10), label = paste0(x17$iterations[1, ]))
+ expect_equal(x17$iterations[2, ], c(9, 10, 10, 10), label = paste0(x17$iterations[2, ]))
+ expect_equal(x17$iterations[3, ], c(7, 8, 5, 5), label = paste0(x17$iterations[3, ]))
+ expect_equal(x17$rejectAtLeastOne, c(0.3, 0.2, 0.9, 0.8), tolerance = 1e-07, label = paste0(x17$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x17$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0.2, 0, 0, 0.1, 0.4, 0, 0.2, 0, 0, 0, 0.1, 0, 0.1, 0, 0.2, 0.3, 0.1, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x17$rejectedArmsPerStage))))
+ expect_equal(x17$futilityStop, c(0.2, 0.1, 0, 0.1), tolerance = 1e-07, label = paste0(x17$futilityStop))
+ expect_equal(x17$futilityPerStage[1, ], c(0.1, 0, 0, 0), tolerance = 1e-07, label = paste0(x17$futilityPerStage[1, ]))
+ expect_equal(x17$futilityPerStage[2, ], c(0.1, 0.1, 0, 0.1), tolerance = 1e-07, label = paste0(x17$futilityPerStage[2, ]))
+ expect_equal(x17$earlyStop[1, ], c(0.1, 0, 0, 0), tolerance = 1e-07, label = paste0(x17$earlyStop[1, ]))
+ expect_equal(x17$earlyStop[2, ], c(0.2, 0.2, 0.5, 0.5), tolerance = 1e-07, label = paste0(x17$earlyStop[2, ]))
+ expect_equal(x17$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x17$successPerStage[1, ]))
+ expect_equal(x17$successPerStage[2, ], c(0.1, 0.1, 0.5, 0.4), tolerance = 1e-07, label = paste0(x17$successPerStage[2, ]))
+ expect_equal(x17$successPerStage[3, ], c(0.2, 0.1, 0.4, 0.3), tolerance = 1e-07, label = paste0(x17$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x17$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.4, 0.3, 1, 0.4, 0.2, 1, 0, 0, 1, 0.2, 0.1, 1, 0.2, 0.1, 1, 0.3, 0.2, 1, 0.6, 0.5, 1, 0.3, 0.1, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.6, 0.1, 1, 0.6, 0.4, 1, 0.9, 0.7, 1, 1, 0.8, 1, 1, 0.5, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x17$selectedArms))))
+ expect_equal(x17$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x17$numberOfActiveArms[1, ]))
+ expect_equal(x17$numberOfActiveArms[2, ], c(1.2222222, 1.2, 1.3, 1.2), tolerance = 1e-07, label = paste0(x17$numberOfActiveArms[2, ]))
+ expect_equal(x17$numberOfActiveArms[3, ], c(1.2857143, 1.125, 1.4, 1.2), tolerance = 1e-07, label = paste0(x17$numberOfActiveArms[3, ]))
+ expect_equal(x17$expectedNumberOfSubjects, c(328.39002, 302.69421, 285.23022, 240.4545), tolerance = 1e-07, label = paste0(x17$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x17$sampleSizes)), c(10, 4.4952582, 14.285714, 10, 19.967039, 25, 10, 10, 20, 10, 10, 0, 10, 21.883735, 42.857143, 10, 26.51119, 25, 10, 0, 0, 10, 13.162215, 6.3433684, 10, 14.295646, 14.285714, 10, 12.191217, 8.9015119, 10, 34.361222, 100, 10, 22.260169, 5.4863466, 10, 27.97297, 57.142857, 10, 13.444855, 22.756787, 10, 23.167319, 20, 10, 26.747723, 50.618475, 10, 62.896861, 100, 10, 55.457645, 74.744525, 10, 47.701679, 100, 10, 59.007892, 56.104821), tolerance = 1e-07, label = paste0(unlist(as.list(x17$sampleSizes))))
+ expect_equal(x17$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x17$conditionalPowerAchieved[1, ]))
+ expect_equal(x17$conditionalPowerAchieved[2, ], c(0.025620238, 0.099222073, 0.15711506, 0.067612991), tolerance = 1e-07, label = paste0(x17$conditionalPowerAchieved[2, ]))
+ expect_equal(x17$conditionalPowerAchieved[3, ], c(0.2137719, 0.30848358, 0.15636561, 0.6965125), tolerance = 1e-07, label = paste0(x17$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x17), NA)))
+ expect_output(print(x17)$show())
+ invisible(capture.output(expect_error(summary(x17), NA)))
+ expect_output(summary(x17)$show())
+ x17CodeBased <- eval(parse(text = getObjectRCode(x17, stringWrapParagraphWidth = NULL)))
+ expect_equal(x17CodeBased$iterations, x17$iterations, tolerance = 1e-07)
+ expect_equal(x17CodeBased$rejectAtLeastOne, x17$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x17CodeBased$rejectedArmsPerStage, x17$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$futilityStop, x17$futilityStop, tolerance = 1e-07)
+ expect_equal(x17CodeBased$futilityPerStage, x17$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$earlyStop, x17$earlyStop, tolerance = 1e-07)
+ expect_equal(x17CodeBased$successPerStage, x17$successPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$selectedArms, x17$selectedArms, tolerance = 1e-07)
+ expect_equal(x17CodeBased$numberOfActiveArms, x17$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x17CodeBased$expectedNumberOfSubjects, x17$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x17CodeBased$sampleSizes, x17$sampleSizes, tolerance = 1e-07)
+ expect_equal(x17CodeBased$conditionalPowerAchieved, x17$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x17), "character")
+ df <- as.data.frame(x17)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x17)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x18 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Simes",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x18' with expected results
+ expect_equal(x18$iterations[1, ], c(10, 10, 10, 10), label = paste0(x18$iterations[1, ]))
+ expect_equal(x18$iterations[2, ], c(10, 9, 8, 10), label = paste0(x18$iterations[2, ]))
+ expect_equal(x18$iterations[3, ], c(7, 8, 1, 4), label = paste0(x18$iterations[3, ]))
+ expect_equal(x18$rejectAtLeastOne, c(0.3, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0(x18$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x18$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0.2, 0, 0, 0.1, 0, 0.2, 0.3, 0, 0.1, 0.3, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x18$rejectedArmsPerStage))))
+ expect_equal(x18$futilityStop, c(0, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x18$futilityStop))
+ expect_equal(x18$futilityPerStage[1, ], c(0, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x18$futilityPerStage[1, ]))
+ expect_equal(x18$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x18$futilityPerStage[2, ]))
+ expect_equal(x18$earlyStop[1, ], c(0, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x18$earlyStop[1, ]))
+ expect_equal(x18$earlyStop[2, ], c(0.3, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0(x18$earlyStop[2, ]))
+ expect_equal(x18$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x18$successPerStage[1, ]))
+ expect_equal(x18$successPerStage[2, ], c(0.3, 0.1, 0.7, 0.6), tolerance = 1e-07, label = paste0(x18$successPerStage[2, ]))
+ expect_equal(x18$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x18$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x18$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0, 1, 0.4, 0.3, 1, 0.5, 0.2, 1, 0.2, 0.1, 1, 0.6, 0.1, 1, 0.4, 0, 1, 1, 0.7, 1, 0.9, 0.8, 1, 0.8, 0.1, 1, 1, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x18$selectedArms))))
+ expect_equal(x18$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x18$numberOfActiveArms[1, ]))
+ expect_equal(x18$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x18$numberOfActiveArms[2, ]))
+ expect_equal(x18$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x18$numberOfActiveArms[3, ]))
+ expect_equal(x18$expectedNumberOfSubjects, c(179.95701, 273.63073, 113.26043, 249.89211), tolerance = 1e-07, label = paste0(x18$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x18$sampleSizes)), c(10, 1.1167748, 1.5953926, 10, 5.9718999, 6.7183874, 10, 0.5, 0, 10, 10, 25, 10, 6.7277808, 9.6111155, 10, 37.581628, 42.279332, 10, 0, 0, 10, 10, 0, 10, 2.4005123, 3.4293032, 10, 8.5110901, 9.5749763, 10, 11.503905, 0, 10, 32.126443, 55.316107, 10, 28.865098, 22.318956, 10, 15.610585, 5.061908, 10, 24.075387, 27.667829, 10, 15.693169, 0, 10, 39.110166, 36.954767, 10, 67.675203, 63.634604, 10, 36.079292, 27.667829, 10, 67.819612, 80.316107), tolerance = 1e-07, label = paste0(unlist(as.list(x18$sampleSizes))))
+ expect_equal(x18$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x18$conditionalPowerAchieved[1, ]))
+ expect_equal(x18$conditionalPowerAchieved[2, ], c(0.064552587, 0.050542809, 0.13271614, 0.098246228), tolerance = 1e-07, label = paste0(x18$conditionalPowerAchieved[2, ]))
+ expect_equal(x18$conditionalPowerAchieved[3, ], c(0.1164829, 0.22353174, 0.16556673, 0.12567304), tolerance = 1e-07, label = paste0(x18$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x18), NA)))
+ expect_output(print(x18)$show())
+ invisible(capture.output(expect_error(summary(x18), NA)))
+ expect_output(summary(x18)$show())
+ x18CodeBased <- eval(parse(text = getObjectRCode(x18, stringWrapParagraphWidth = NULL)))
+ expect_equal(x18CodeBased$iterations, x18$iterations, tolerance = 1e-07)
+ expect_equal(x18CodeBased$rejectAtLeastOne, x18$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x18CodeBased$rejectedArmsPerStage, x18$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$futilityStop, x18$futilityStop, tolerance = 1e-07)
+ expect_equal(x18CodeBased$futilityPerStage, x18$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$earlyStop, x18$earlyStop, tolerance = 1e-07)
+ expect_equal(x18CodeBased$successPerStage, x18$successPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$selectedArms, x18$selectedArms, tolerance = 1e-07)
+ expect_equal(x18CodeBased$numberOfActiveArms, x18$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x18CodeBased$expectedNumberOfSubjects, x18$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x18CodeBased$sampleSizes, x18$sampleSizes, tolerance = 1e-07)
+ expect_equal(x18CodeBased$conditionalPowerAchieved, x18$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x18), "character")
+ df <- as.data.frame(x18)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x18)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x19 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x19' with expected results
+ expect_equal(x19$iterations[1, ], c(10, 10, 10, 10), label = paste0(x19$iterations[1, ]))
+ expect_equal(x19$iterations[2, ], c(10, 7, 9, 10), label = paste0(x19$iterations[2, ]))
+ expect_equal(x19$iterations[3, ], c(6, 3, 4, 6), label = paste0(x19$iterations[3, ]))
+ expect_equal(x19$rejectAtLeastOne, c(0.1, 0, 0.1, 0), tolerance = 1e-07, label = paste0(x19$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x19$rejectedArmsPerStage)), c(0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x19$rejectedArmsPerStage))))
+ expect_equal(x19$futilityStop, c(0.4, 0.7, 0.6, 0.4), tolerance = 1e-07, label = paste0(x19$futilityStop))
+ expect_equal(x19$futilityPerStage[1, ], c(0, 0.3, 0.1, 0), tolerance = 1e-07, label = paste0(x19$futilityPerStage[1, ]))
+ expect_equal(x19$futilityPerStage[2, ], c(0.4, 0.4, 0.5, 0.4), tolerance = 1e-07, label = paste0(x19$futilityPerStage[2, ]))
+ expect_equal(x19$earlyStop[1, ], c(0, 0.3, 0.1, 0), tolerance = 1e-07, label = paste0(x19$earlyStop[1, ]))
+ expect_equal(x19$earlyStop[2, ], c(0.4, 0.4, 0.5, 0.4), tolerance = 1e-07, label = paste0(x19$earlyStop[2, ]))
+ expect_equal(x19$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x19$successPerStage[1, ]))
+ expect_equal(x19$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x19$successPerStage[2, ]))
+ expect_equal(x19$successPerStage[3, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0(x19$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x19$selectedArms)), c(1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.6, 0.6, 1, 0.6, 0.4, 1, 0.5, 0.2, 1, 0.7, 0.3, 1, 1, 0.6, 1, 0.6, 0.4, 1, 0.7, 0.3, 1, 0.7, 0.4, 1, 0.7, 0.4, 1, 0.7, 0.3, 1, 0.5, 0.2, 1, 0.9, 0.4, 1, 0.8, 0.5, 1, 1, 0.6, 1, 0.7, 0.3, 1, 0.9, 0.4, 1, 1, 0.6), tolerance = 1e-07, label = paste0(unlist(as.list(x19$selectedArms))))
+ expect_equal(x19$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x19$numberOfActiveArms[1, ]))
+ expect_equal(x19$numberOfActiveArms[2, ], c(2.5, 2.8571429, 3, 3.1), tolerance = 1e-07, label = paste0(x19$numberOfActiveArms[2, ]))
+ expect_equal(x19$numberOfActiveArms[3, ], c(2.8333333, 3.3333333, 3.75, 3.5), tolerance = 1e-07, label = paste0(x19$numberOfActiveArms[3, ]))
+ expect_equal(x19$expectedNumberOfSubjects, c(600.66781, 398.09964, 600, 634), tolerance = 1e-07, label = paste0(x19$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x19$sampleSizes)), c(10, 56.333476, 93.889127, 10, 42.857143, 100, 10, 44.444444, 100, 10, 50.4, 84, 10, 56.333476, 60.555794, 10, 52.89273, 66.666667, 10, 77.777778, 75, 10, 90.4, 84, 10, 60, 66.666667, 10, 81.464159, 100, 10, 77.777778, 100, 10, 60.4, 50.666667, 10, 66.333476, 43.889127, 10, 52.89273, 66.666667, 10, 100, 100, 10, 70.4, 67.333333, 10, 96.333476, 93.889127, 10, 81.464159, 100, 10, 100, 100, 10, 90.4, 84), tolerance = 1e-07, label = paste0(unlist(as.list(x19$sampleSizes))))
+ expect_equal(x19$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x19$conditionalPowerAchieved[1, ]))
+ expect_equal(x19$conditionalPowerAchieved[2, ], c(0.014835699, 0.082104288, 0.088043543, 0.18689602), tolerance = 1e-07, label = paste0(x19$conditionalPowerAchieved[2, ]))
+ expect_equal(x19$conditionalPowerAchieved[3, ], c(0.35039062, 0.35957167, 0.84477407, 0.62586447), tolerance = 1e-07, label = paste0(x19$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x19), NA)))
+ expect_output(print(x19)$show())
+ invisible(capture.output(expect_error(summary(x19), NA)))
+ expect_output(summary(x19)$show())
+ x19CodeBased <- eval(parse(text = getObjectRCode(x19, stringWrapParagraphWidth = NULL)))
+ expect_equal(x19CodeBased$iterations, x19$iterations, tolerance = 1e-07)
+ expect_equal(x19CodeBased$rejectAtLeastOne, x19$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x19CodeBased$rejectedArmsPerStage, x19$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$futilityStop, x19$futilityStop, tolerance = 1e-07)
+ expect_equal(x19CodeBased$futilityPerStage, x19$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$earlyStop, x19$earlyStop, tolerance = 1e-07)
+ expect_equal(x19CodeBased$successPerStage, x19$successPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$selectedArms, x19$selectedArms, tolerance = 1e-07)
+ expect_equal(x19CodeBased$numberOfActiveArms, x19$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x19CodeBased$expectedNumberOfSubjects, x19$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x19CodeBased$sampleSizes, x19$sampleSizes, tolerance = 1e-07)
+ expect_equal(x19CodeBased$conditionalPowerAchieved, x19$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x19), "character")
+ df <- as.data.frame(x19)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x19)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x20 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), activeArms = 4, threshold = 0,
+ typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x20' with expected results
+ expect_equal(x20$iterations[1, ], c(10, 10, 10, 10), label = paste0(x20$iterations[1, ]))
+ expect_equal(x20$iterations[2, ], c(9, 9, 8, 10), label = paste0(x20$iterations[2, ]))
+ expect_equal(x20$iterations[3, ], c(2, 6, 3, 2), label = paste0(x20$iterations[3, ]))
+ expect_equal(x20$rejectAtLeastOne, c(0, 0.2, 0, 0.1), tolerance = 1e-07, label = paste0(x20$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x20$rejectedArmsPerStage)), c(0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x20$rejectedArmsPerStage))))
+ expect_equal(x20$futilityStop, c(0.8, 0.4, 0.7, 0.7), tolerance = 1e-07, label = paste0(x20$futilityStop))
+ expect_equal(x20$futilityPerStage[1, ], c(0.1, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x20$futilityPerStage[1, ]))
+ expect_equal(x20$futilityPerStage[2, ], c(0.7, 0.3, 0.5, 0.7), tolerance = 1e-07, label = paste0(x20$futilityPerStage[2, ]))
+ expect_equal(x20$earlyStop[1, ], c(0.1, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x20$earlyStop[1, ]))
+ expect_equal(x20$earlyStop[2, ], c(0.7, 0.3, 0.5, 0.8), tolerance = 1e-07, label = paste0(x20$earlyStop[2, ]))
+ expect_equal(x20$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[1, ]))
+ expect_equal(x20$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x20$successPerStage[2, ]))
+ expect_equal(x20$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x20$selectedArms)), c(1, 0.2, 0.2, 1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.3, 0.2, 1, 0.4, 0, 1, 0.1, 0, 1, 0.3, 0, 1, 0.5, 0, 1, 0.3, 0, 1, 0.3, 0.1, 1, 0.3, 0.1, 1, 0.4, 0, 1, 0.8, 0.2, 1, 0.8, 0.5, 1, 0.5, 0.2, 1, 0.8, 0.2, 1, 0.9, 0.2, 1, 0.9, 0.6, 1, 0.8, 0.3, 1, 1, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x20$selectedArms))))
+ expect_equal(x20$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x20$numberOfActiveArms[1, ]))
+ expect_equal(x20$numberOfActiveArms[2, ], c(1.8888889, 2, 1.75, 2), tolerance = 1e-07, label = paste0(x20$numberOfActiveArms[2, ]))
+ expect_equal(x20$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x20$numberOfActiveArms[3, ]))
+ expect_equal(x20$expectedNumberOfSubjects, c(307.09166, 377.99189, 286.78887, 300.60787), tolerance = 1e-07, label = paste0(x20$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x20$sampleSizes)), c(10, 22.222222, 100, 10, 47.097546, 70.646318, 10, 30.537829, 81.43421, 10, 25.370782, 76.853911, 10, 33.228314, 0, 10, 11.111111, 0, 10, 27.257545, 0, 10, 38.448036, 0, 10, 17.763874, 0, 10, 27.283387, 16.666667, 10, 33.529937, 33.333333, 10, 22.273651, 0, 10, 69.075708, 100, 10, 63.269822, 53.979652, 10, 39.758676, 48.100877, 10, 50.237878, 76.853911, 10, 76.700615, 100, 10, 74.380933, 70.646318, 10, 73.288614, 81.43421, 10, 68.165174, 76.853911), tolerance = 1e-07, label = paste0(unlist(as.list(x20$sampleSizes))))
+ expect_equal(x20$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x20$conditionalPowerAchieved[1, ]))
+ expect_equal(x20$conditionalPowerAchieved[2, ], c(0.0535706, 0.15544115, 0.10470149, 0.094637028), tolerance = 1e-07, label = paste0(x20$conditionalPowerAchieved[2, ]))
+ expect_equal(x20$conditionalPowerAchieved[3, ], c(0.09464551, 0.36740056, 0.23354895, 0.75738479), tolerance = 1e-07, label = paste0(x20$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x20), NA)))
+ expect_output(print(x20)$show())
+ invisible(capture.output(expect_error(summary(x20), NA)))
+ expect_output(summary(x20)$show())
+ x20CodeBased <- eval(parse(text = getObjectRCode(x20, stringWrapParagraphWidth = NULL)))
+ expect_equal(x20CodeBased$iterations, x20$iterations, tolerance = 1e-07)
+ expect_equal(x20CodeBased$rejectAtLeastOne, x20$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x20CodeBased$rejectedArmsPerStage, x20$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$futilityStop, x20$futilityStop, tolerance = 1e-07)
+ expect_equal(x20CodeBased$futilityPerStage, x20$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$earlyStop, x20$earlyStop, tolerance = 1e-07)
+ expect_equal(x20CodeBased$successPerStage, x20$successPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$selectedArms, x20$selectedArms, tolerance = 1e-07)
+ expect_equal(x20CodeBased$numberOfActiveArms, x20$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x20CodeBased$expectedNumberOfSubjects, x20$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x20CodeBased$sampleSizes, x20$sampleSizes, tolerance = 1e-07)
+ expect_equal(x20CodeBased$conditionalPowerAchieved, x20$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x20), "character")
+ df <- as.data.frame(x20)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x20)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x21 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x21' with expected results
+ expect_equal(x21$iterations[1, ], c(10, 10, 10, 10), label = paste0(x21$iterations[1, ]))
+ expect_equal(x21$iterations[2, ], c(9, 9, 10, 10), label = paste0(x21$iterations[2, ]))
+ expect_equal(x21$iterations[3, ], c(1, 1, 3, 0), label = paste0(x21$iterations[3, ]))
+ expect_equal(x21$rejectAtLeastOne, c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x21$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x21$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x21$rejectedArmsPerStage))))
+ expect_equal(x21$futilityStop, c(0.9, 0.9, 0.6, 1), tolerance = 1e-07, label = paste0(x21$futilityStop))
+ expect_equal(x21$futilityPerStage[1, ], c(0.1, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x21$futilityPerStage[1, ]))
+ expect_equal(x21$futilityPerStage[2, ], c(0.8, 0.8, 0.6, 1), tolerance = 1e-07, label = paste0(x21$futilityPerStage[2, ]))
+ expect_equal(x21$earlyStop[1, ], c(0.1, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x21$earlyStop[1, ]))
+ expect_equal(x21$earlyStop[2, ], c(0.8, 0.8, 0.7, 1), tolerance = 1e-07, label = paste0(x21$earlyStop[2, ]))
+ expect_equal(x21$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[1, ]))
+ expect_equal(x21$successPerStage[2, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0(x21$successPerStage[2, ]))
+ expect_equal(x21$successPerStage[3, ], c(0, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x21$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x21$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0, 0, 1, 0.3, 0, 1, 0.3, 0, 1, 0, 0, 1, 0.3, 0, 1, 0.3, 0, 1, 0.2, 0, 1, 0.2, 0, 1, 0.1, 0, 1, 0.3, 0, 1, 0.5, 0, 1, 0.5, 0.1, 1, 0.6, 0, 1, 0.9, 0.1, 1, 0.9, 0.1, 1, 1, 0.3, 1, 1, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x21$selectedArms))))
+ expect_equal(x21$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x21$numberOfActiveArms[1, ]))
+ expect_equal(x21$numberOfActiveArms[2, ], c(1.1111111, 1.2222222, 1.1, 1), tolerance = 1e-07, label = paste0(x21$numberOfActiveArms[2, ]))
+ expect_equal(x21$numberOfActiveArms[3, ], c(1, 1, 1.3333333, NaN), tolerance = 1e-07, label = paste0(x21$numberOfActiveArms[3, ]))
+ expect_equal(x21$expectedNumberOfSubjects, c(190.08367, 169.68391, 280.67025, NaN), tolerance = 1e-07, label = paste0(x21$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x21$sampleSizes)), c(10, 4.4952582, 40.457324, 10, 11.111111, 100, 10, 30.407004, 99.157615, 10, 0, NaN, 10, 19.514172, 0, 10, 21.967417, 0, 10, 0, 0, 10, 21.272121, NaN, 10, 25.406757, 0, 10, 11.52108, 0, 10, 16.622221, 0, 10, 10, NaN, 10, 25.603407, 0, 10, 20.034041, 0, 10, 38.558614, 33.333333, 10, 21.010924, NaN, 10, 71.638409, 40.457324, 10, 46.126253, 100, 10, 75.587839, 99.157615, 10, 52.283045, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x21$sampleSizes))))
+ expect_equal(x21$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x21$conditionalPowerAchieved[1, ]))
+ expect_equal(x21$conditionalPowerAchieved[2, ], c(0.023159424, 0.14301241, 0.046563399, 0.11230633), tolerance = 1e-07, label = paste0(x21$conditionalPowerAchieved[2, ]))
+ expect_equal(x21$conditionalPowerAchieved[3, ], c(0.07537462, 0.00060378387, 0.33359002, NaN), tolerance = 1e-07, label = paste0(x21$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x21), NA)))
+ expect_output(print(x21)$show())
+ invisible(capture.output(expect_error(summary(x21), NA)))
+ expect_output(summary(x21)$show())
+ x21CodeBased <- eval(parse(text = getObjectRCode(x21, stringWrapParagraphWidth = NULL)))
+ expect_equal(x21CodeBased$iterations, x21$iterations, tolerance = 1e-07)
+ expect_equal(x21CodeBased$rejectAtLeastOne, x21$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x21CodeBased$rejectedArmsPerStage, x21$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$futilityStop, x21$futilityStop, tolerance = 1e-07)
+ expect_equal(x21CodeBased$futilityPerStage, x21$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$earlyStop, x21$earlyStop, tolerance = 1e-07)
+ expect_equal(x21CodeBased$successPerStage, x21$successPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$selectedArms, x21$selectedArms, tolerance = 1e-07)
+ expect_equal(x21CodeBased$numberOfActiveArms, x21$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x21CodeBased$expectedNumberOfSubjects, x21$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x21CodeBased$sampleSizes, x21$sampleSizes, tolerance = 1e-07)
+ expect_equal(x21CodeBased$conditionalPowerAchieved, x21$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x21), "character")
+ df <- as.data.frame(x21)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x21)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x22 <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0.1,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.1, 0.3, 0.1),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 1
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x22' with expected results
+ expect_equal(x22$iterations[1, ], c(1, 1, 1), label = paste0(x22$iterations[1, ]))
+ expect_equal(x22$iterations[2, ], c(1, 1, 1), label = paste0(x22$iterations[2, ]))
+ expect_equal(x22$iterations[3, ], c(0, 1, 1), label = paste0(x22$iterations[3, ]))
+ expect_equal(x22$rejectAtLeastOne, c(0, 0, 0), label = paste0(x22$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x22$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x22$rejectedArmsPerStage))))
+ expect_equal(x22$futilityStop, c(1, 0, 0), label = paste0(x22$futilityStop))
+ expect_equal(x22$futilityPerStage[1, ], c(0, 0, 0), label = paste0(x22$futilityPerStage[1, ]))
+ expect_equal(x22$futilityPerStage[2, ], c(1, 0, 0), label = paste0(x22$futilityPerStage[2, ]))
+ expect_equal(x22$earlyStop[1, ], c(0, 0, 0), label = paste0(x22$earlyStop[1, ]))
+ expect_equal(x22$earlyStop[2, ], c(1, 0, 0), label = paste0(x22$earlyStop[2, ]))
+ expect_equal(x22$successPerStage[1, ], c(0, 0, 0), label = paste0(x22$successPerStage[1, ]))
+ expect_equal(x22$successPerStage[2, ], c(0, 0, 0), label = paste0(x22$successPerStage[2, ]))
+ expect_equal(x22$successPerStage[3, ], c(0, 0, 0), label = paste0(x22$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x22$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1), label = paste0(unlist(as.list(x22$selectedArms))))
+ expect_equal(x22$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0(x22$numberOfActiveArms[1, ]))
+ expect_equal(x22$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0(x22$numberOfActiveArms[2, ]))
+ expect_equal(x22$numberOfActiveArms[3, ], c(NaN, 1, 1), label = paste0(x22$numberOfActiveArms[3, ]))
+ expect_equal(x22$expectedNumberOfSubjects, c(NaN, 450, 148.90979), tolerance = 1e-07, label = paste0(x22$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x22$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 32.875253, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 100, 100, 10, 10.358511, 39.096382, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 32.875253, 0, 10, 100, 100, 10, 10.358511, 39.096382), tolerance = 1e-07, label = paste0(unlist(as.list(x22$sampleSizes))))
+ expect_equal(x22$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x22$conditionalPowerAchieved[1, ]))
+ expect_equal(x22$conditionalPowerAchieved[2, ], c(0.011749146, 0.0034013018, 0.045375018), tolerance = 1e-07, label = paste0(x22$conditionalPowerAchieved[2, ]))
+ expect_equal(x22$conditionalPowerAchieved[3, ], c(NaN, 0.15769372, 0.8), tolerance = 1e-07, label = paste0(x22$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x22), NA)))
+ expect_output(print(x22)$show())
+ invisible(capture.output(expect_error(summary(x22), NA)))
+ expect_output(summary(x22)$show())
+ x22CodeBased <- eval(parse(text = getObjectRCode(x22, stringWrapParagraphWidth = NULL)))
+ expect_equal(x22CodeBased$iterations, x22$iterations, tolerance = 1e-07)
+ expect_equal(x22CodeBased$rejectAtLeastOne, x22$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x22CodeBased$rejectedArmsPerStage, x22$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$futilityStop, x22$futilityStop, tolerance = 1e-07)
+ expect_equal(x22CodeBased$futilityPerStage, x22$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$earlyStop, x22$earlyStop, tolerance = 1e-07)
+ expect_equal(x22CodeBased$successPerStage, x22$successPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$selectedArms, x22$selectedArms, tolerance = 1e-07)
+ expect_equal(x22CodeBased$numberOfActiveArms, x22$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x22CodeBased$expectedNumberOfSubjects, x22$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x22CodeBased$sampleSizes, x22$sampleSizes, tolerance = 1e-07)
+ expect_equal(x22CodeBased$conditionalPowerAchieved, x22$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x22), "character")
+ df <- as.data.frame(x22)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x22)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmMeans': using calcSubjectsFunction", {
-
- .skipTestIfDisabled()
-
- calcSubjectsFunctionSimulationMultiArmMeans <- function(..., stage, minNumberOfSubjectsPerStage) {
- return(ifelse(stage == 3, 33, minNumberOfSubjectsPerStage[stage]))
- }
-
- x <- getSimulationMultiArmMeans(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), typeOfShape = "linear", activeArms = 4,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10, calcSubjectsFunction = calcSubjectsFunctionSimulationMultiArmMeans
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
- expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(9, 9, 8, 8), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.1, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.1, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0.1, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.2, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.5, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.4, 1, 0.6, 0.5, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(117.4, 117.4, 110.8, 110.8), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(10, 0.4, 3.6666667, 10, 0.4, 3.6666667, 10, 0.4, 0, 10, 0, 0, 10, 1.2, 11, 10, 1.6, 14.666667, 10, 0, 0, 10, 1.2, 8.25, 10, 0.4, 3.6666667, 10, 1.2, 7.3333333, 10, 1.6, 16.5, 10, 0.4, 4.125, 10, 2, 14.666667, 10, 0.8, 7.3333333, 10, 2, 16.5, 10, 2.4, 20.625, 10, 4, 33, 10, 4, 33, 10, 4, 33, 10, 4, 33), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.054038913, 0.015750083, 0.11207917, 0.055949011), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.44922292, 0.31010643, 0.28872426, 0.56321232), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ calcSubjectsFunctionSimulationMultiArmMeans <- function(..., stage, minNumberOfSubjectsPerStage) {
+ return(ifelse(stage == 3, 33, minNumberOfSubjectsPerStage[stage]))
+ }
+
+ x <- getSimulationMultiArmMeans(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)), typeOfShape = "linear", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10, calcSubjectsFunction = calcSubjectsFunctionSimulationMultiArmMeans
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(9, 9, 8, 8), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.1, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.1, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0.1, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0, 0, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.2, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.5, 0.4, 1, 0.2, 0.2, 1, 0.5, 0.4, 1, 0.6, 0.5, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(117.4, 117.4, 110.8, 110.8), tolerance = 1e-07, label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(10, 0.4, 3.6666667, 10, 0.4, 3.6666667, 10, 0.4, 0, 10, 0, 0, 10, 1.2, 11, 10, 1.6, 14.666667, 10, 0, 0, 10, 1.2, 8.25, 10, 0.4, 3.6666667, 10, 1.2, 7.3333333, 10, 1.6, 16.5, 10, 0.4, 4.125, 10, 2, 14.666667, 10, 0.8, 7.3333333, 10, 2, 16.5, 10, 2.4, 20.625, 10, 4, 33, 10, 4, 33, 10, 4, 33, 10, 4, 33), tolerance = 1e-07, label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.054038913, 0.015750083, 0.11207917, 0.055949011), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.44922292, 0.31010643, 0.28872426, 0.56321232), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmMeans': using selectArmsFunction", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
- # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
- # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
- selectArmsFunctionSimulationMultiArmMeans <- function(effectSizes) {
- return(c(TRUE, FALSE, FALSE, FALSE))
- }
-
- x <- getSimulationMultiArmMeans(
- seed = 1234,
- getDesignFisher(informationRates = c(0.2, 0.6, 1)), typeOfShape = "linear", activeArms = 4,
- plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- maxNumberOfIterations = 10, selectArmsFunction = selectArmsFunctionSimulationMultiArmMeans, typeOfSelection = "userDefined"
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
- expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(10, 9, 9, 10), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.1, 0.1, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 1, 1, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(130, 126, 126, 130), label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20), label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.091251689, 0.027836233, 0.13855746, 0.12908437), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.071420101, 0.027813347, 0.076509581, 0.21688562), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
+ selectArmsFunctionSimulationMultiArmMeans <- function(effectSizes) {
+ return(c(TRUE, FALSE, FALSE, FALSE))
+ }
+
+ x <- getSimulationMultiArmMeans(
+ seed = 1234,
+ getDesignFisher(informationRates = c(0.2, 0.6, 1)), typeOfShape = "linear", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), stDev = 1.2, muMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ maxNumberOfIterations = 10, selectArmsFunction = selectArmsFunctionSimulationMultiArmMeans, typeOfSelection = "userDefined"
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(10, 9, 9, 10), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.1, 0.1, 0.2, 0.1), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 1, 1, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 1), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(130, 126, 126, 130), label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20), label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.091251689, 0.027836233, 0.13855746, 0.12908437), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.071420101, 0.027813347, 0.076509581, 0.21688562), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmMeans': using intersectionTest = 'Sidak' and typeOfSelection = 'rBest'", {
-
- .skipTestIfDisabled()
-
- designIN <- getDesignInverseNormal(typeOfDesign = "P", kMax = 3, futilityBounds = c(0, 0))
- x <- getSimulationMultiArmMeans(designIN,
- activeArms = 3, typeOfShape = "sigmoidEmax",
- muMaxVector = seq(0, 1, 0.2), gED50 = 2, plannedSubjects = cumsum(rep(20, 3)),
- intersectionTest = "Sidak", typeOfSelection = "rBest", rValue = 2, threshold = -Inf,
- successCriterion = "all", maxNumberOfIterations = 100, seed = 3456
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
- expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100, 100), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(42, 52, 69, 77, 88, 87), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(30, 33, 61, 73, 80, 61), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.02, 0.03, 0.18, 0.33, 0.49, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0.01, 0, 0, 0, 0.01, 0.01, 0.02, 0.03, 0.01, 0.02, 0.01, 0.01, 0.06, 0.1, 0.04, 0.04, 0.01, 0, 0, 0.01, 0.02, 0, 0.03, 0, 0.03, 0.04, 0.06, 0.08, 0.08, 0.11, 0.1, 0.14, 0.27, 0.12, 0, 0, 0, 0, 0.01, 0, 0.02, 0.01, 0.08, 0.08, 0.05, 0.11, 0.09, 0.16, 0.13, 0.18, 0.25, 0.24), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0.7, 0.66, 0.39, 0.23, 0.11, 0.07), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0.58, 0.48, 0.31, 0.22, 0.11, 0.07), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0.12, 0.18, 0.08, 0.01, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0.58, 0.48, 0.31, 0.23, 0.12, 0.13), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.12, 0.19, 0.08, 0.04, 0.08, 0.26), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0.01, 0.01, 0.06), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0.01, 0, 0.03, 0.08, 0.26), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0, 0.03, 0.1, 0.16, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.25, 0.17, 1, 0.25, 0.16, 1, 0.31, 0.26, 1, 0.32, 0.3, 1, 0.42, 0.41, 1, 0.32, 0.26, 1, 0.32, 0.22, 1, 0.43, 0.26, 1, 0.48, 0.45, 1, 0.56, 0.54, 1, 0.63, 0.56, 1, 0.7, 0.47, 1, 0.27, 0.21, 1, 0.36, 0.24, 1, 0.59, 0.51, 1, 0.66, 0.62, 1, 0.71, 0.63, 1, 0.72, 0.49, 1, 0.42, 0.3, 1, 0.52, 0.33, 1, 0.69, 0.61, 1, 0.77, 0.73, 1, 0.88, 0.8, 1, 0.87, 0.61), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(3, 3, 3, 3, 3, 3), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(2, 2, 2, 2, 2, 2), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(2, 2, 2, 2, 2, 2), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(123.2, 131, 158, 170, 180.8, 168.8), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(20, 11.904762, 11.333333, 20, 9.6153846, 9.6969697, 20, 8.9855072, 8.5245902, 20, 8.3116883, 8.2191781, 20, 9.5454545, 10.25, 20, 7.3563218, 8.5245902, 20, 15.238095, 14.666667, 20, 16.538462, 15.757576, 20, 13.913043, 14.754098, 20, 14.545455, 14.794521, 20, 14.318182, 14, 20, 16.091954, 15.409836, 20, 12.857143, 14, 20, 13.846154, 14.545455, 20, 17.101449, 16.721311, 20, 17.142857, 16.986301, 20, 16.136364, 15.75, 20, 16.551724, 16.065574, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.058967382, 0.048523877, 0.17154294, 0.22180985, 0.2182802, 0.37414282), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.077820194, 0.14430526, 0.21266388, 0.28752608, 0.40185892, 0.5016109), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ designIN <- getDesignInverseNormal(typeOfDesign = "P", kMax = 3, futilityBounds = c(0, 0))
+ x <- getSimulationMultiArmMeans(designIN,
+ activeArms = 3, typeOfShape = "sigmoidEmax",
+ muMaxVector = seq(0, 1, 0.2), gED50 = 2, plannedSubjects = cumsum(rep(20, 3)),
+ intersectionTest = "Sidak", typeOfSelection = "rBest", rValue = 2, threshold = -Inf,
+ successCriterion = "all", maxNumberOfIterations = 100, seed = 3456
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100, 100), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(42, 52, 69, 77, 88, 87), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(30, 33, 61, 73, 80, 61), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.02, 0.03, 0.18, 0.33, 0.49, 0.8), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0.01, 0, 0, 0, 0.01, 0.01, 0.02, 0.03, 0.01, 0.02, 0.01, 0.01, 0.06, 0.1, 0.04, 0.04, 0.01, 0, 0, 0.01, 0.02, 0, 0.03, 0, 0.03, 0.04, 0.06, 0.08, 0.08, 0.11, 0.1, 0.14, 0.27, 0.12, 0, 0, 0, 0, 0.01, 0, 0.02, 0.01, 0.08, 0.08, 0.05, 0.11, 0.09, 0.16, 0.13, 0.18, 0.25, 0.24), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0.7, 0.66, 0.39, 0.23, 0.11, 0.07), tolerance = 1e-07, label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0.58, 0.48, 0.31, 0.22, 0.11, 0.07), tolerance = 1e-07, label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0.12, 0.18, 0.08, 0.01, 0, 0), tolerance = 1e-07, label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0.58, 0.48, 0.31, 0.23, 0.12, 0.13), tolerance = 1e-07, label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.12, 0.19, 0.08, 0.04, 0.08, 0.26), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0.01, 0.01, 0.06), tolerance = 1e-07, label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0.01, 0, 0.03, 0.08, 0.26), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0, 0.03, 0.1, 0.16, 0.2), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.25, 0.17, 1, 0.25, 0.16, 1, 0.31, 0.26, 1, 0.32, 0.3, 1, 0.42, 0.41, 1, 0.32, 0.26, 1, 0.32, 0.22, 1, 0.43, 0.26, 1, 0.48, 0.45, 1, 0.56, 0.54, 1, 0.63, 0.56, 1, 0.7, 0.47, 1, 0.27, 0.21, 1, 0.36, 0.24, 1, 0.59, 0.51, 1, 0.66, 0.62, 1, 0.71, 0.63, 1, 0.72, 0.49, 1, 0.42, 0.3, 1, 0.52, 0.33, 1, 0.69, 0.61, 1, 0.77, 0.73, 1, 0.88, 0.8, 1, 0.87, 0.61), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(3, 3, 3, 3, 3, 3), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(2, 2, 2, 2, 2, 2), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(2, 2, 2, 2, 2, 2), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(123.2, 131, 158, 170, 180.8, 168.8), tolerance = 1e-07, label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(20, 11.904762, 11.333333, 20, 9.6153846, 9.6969697, 20, 8.9855072, 8.5245902, 20, 8.3116883, 8.2191781, 20, 9.5454545, 10.25, 20, 7.3563218, 8.5245902, 20, 15.238095, 14.666667, 20, 16.538462, 15.757576, 20, 13.913043, 14.754098, 20, 14.545455, 14.794521, 20, 14.318182, 14, 20, 16.091954, 15.409836, 20, 12.857143, 14, 20, 13.846154, 14.545455, 20, 17.101449, 16.721311, 20, 17.142857, 16.986301, 20, 16.136364, 15.75, 20, 16.551724, 16.065574, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20), tolerance = 1e-07, label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.058967382, 0.048523877, 0.17154294, 0.22180985, 0.2182802, 0.37414282), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.077820194, 0.14430526, 0.21266388, 0.28752608, 0.40185892, 0.5016109), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmMeans': plot drift - comparison of raw values", {
-
- .skipTestIfDisabled()
-
- designPureConditionalDunnett <- getDesignInverseNormal(typeOfDesign = "asUser", userAlphaSpending = c(0, 0.025))
- designCombinationDunnett <- getDesignConditionalDunnett(informationAtInterim = 0.5, secondStageConditioning = TRUE)
-
- resultsPureConditionalDunnett <- getSimulationMultiArmMeans(designPureConditionalDunnett,
- activeArms = 3, muMaxVector = seq(0, 1, 0.2),
- typeOfShape = "linear", plannedSubjects = cumsum(rep(20, 2)), intersectionTest = "Dunnett",
- adaptations = TRUE, typeOfSelection = "best", effectMeasure = "effectEstimate",
- threshold = -Inf, maxNumberOfIterations = 100,
- allocationRatioPlanned = 1, seed = 123
- )
-
- resultsCombinationDunnett <- getSimulationMultiArmMeans(designCombinationDunnett,
- activeArms = 3, muMaxVector = seq(0, 1, 0.2),
- typeOfShape = "linear", plannedSubjects = cumsum(rep(20, 2)), intersectionTest = "Dunnett",
- adaptations = TRUE, typeOfSelection = "best", effectMeasure = "effectEstimate",
- threshold = -Inf, maxNumberOfIterations = 100,
- allocationRatioPlanned = 1, seed = 123
- )
-
- drift <- resultsPureConditionalDunnett$effectMatrix[nrow(resultsPureConditionalDunnett$effectMatrix), ]
-
- ## Comparison of the results of numeric object 'drift' with expected results
- expect_equal(drift, c(0, 0.2, 0.4, 0.6, 0.8, 1), tolerance = 1e-07, label = paste0("c(", paste0(drift, collapse = ", "), ")"))
- expect_equal(resultsPureConditionalDunnett$rejectAtLeastOne, resultsCombinationDunnett$rejectAtLeastOne, tolerance = 0.06)
-
+ .skipTestIfDisabled()
+
+ designPureConditionalDunnett <- getDesignInverseNormal(typeOfDesign = "asUser", userAlphaSpending = c(0, 0.025))
+ designCombinationDunnett <- getDesignConditionalDunnett(informationAtInterim = 0.5, secondStageConditioning = TRUE)
+
+ resultsPureConditionalDunnett <- getSimulationMultiArmMeans(designPureConditionalDunnett,
+ activeArms = 3, muMaxVector = seq(0, 1, 0.2),
+ typeOfShape = "linear", plannedSubjects = cumsum(rep(20, 2)), intersectionTest = "Dunnett",
+ adaptations = TRUE, typeOfSelection = "best", effectMeasure = "effectEstimate",
+ threshold = -Inf, maxNumberOfIterations = 100,
+ allocationRatioPlanned = 1, seed = 123
+ )
+
+ resultsCombinationDunnett <- getSimulationMultiArmMeans(designCombinationDunnett,
+ activeArms = 3, muMaxVector = seq(0, 1, 0.2),
+ typeOfShape = "linear", plannedSubjects = cumsum(rep(20, 2)), intersectionTest = "Dunnett",
+ adaptations = TRUE, typeOfSelection = "best", effectMeasure = "effectEstimate",
+ threshold = -Inf, maxNumberOfIterations = 100,
+ allocationRatioPlanned = 1, seed = 123
+ )
+
+ drift <- resultsPureConditionalDunnett$effectMatrix[nrow(resultsPureConditionalDunnett$effectMatrix), ]
+
+ ## Comparison of the results of numeric object 'drift' with expected results
+ expect_equal(drift, c(0, 0.2, 0.4, 0.6, 0.8, 1), tolerance = 1e-07, label = paste0(drift))
+ expect_equal(resultsPureConditionalDunnett$rejectAtLeastOne, resultsCombinationDunnett$rejectAtLeastOne, tolerance = 0.06)
})
test_that("'getSimulationMultiArmMeans': comparison of base and multi-arm", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
- # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- design <- getDesignInverseNormal(typeOfDesign = "WT", deltaWT = 0.15, futilityBounds = c(-0.5, 0), informationRates = c(0.4, 0.8, 1))
- x <- getSimulationMultiArmMeans(
- design = design, activeArms = 1,
- plannedSubjects = c(20, 40, 60), stDev = 1.5, muMaxVector = seq(0, 1, 0.2),
- conditionalPower = 0.80, minNumberOfSubjectsPerStage = c(NA, 20, 20),
- maxNumberOfSubjectsPerStage = c(NA, 80, 80), # thetaH1 = 0.5,
- maxNumberOfIterations = 100, allocationRatioPlanned = 2, seed = 1234
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
- expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100, 100), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(81, 88, 89, 88, 93, 79), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(53, 70, 64, 51, 37, 12), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.01, 0.11, 0.39, 0.73, 0.93, 0.98), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0.01, 0, 0.05, 0.06, 0.01, 0.22, 0.16, 0.02, 0.37, 0.34, 0.06, 0.56, 0.31, 0.2, 0.67, 0.11), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0.47, 0.25, 0.13, 0.1, 0.01, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0.19, 0.12, 0.1, 0.1, 0.01, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0.28, 0.13, 0.03, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0.19, 0.12, 0.11, 0.12, 0.07, 0.21), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.28, 0.18, 0.25, 0.37, 0.56, 0.67), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0.01, 0.02, 0.06, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0.05, 0.22, 0.37, 0.56, 0.67), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0.01, 0.06, 0.16, 0.34, 0.31, 0.11), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.81, 0.53, 1, 0.88, 0.7, 1, 0.89, 0.64, 1, 0.88, 0.51, 1, 0.93, 0.37, 1, 0.79, 0.12, 1, 0.81, 0.53, 1, 0.88, 0.7, 1, 0.89, 0.64, 1, 0.88, 0.51, 1, 0.93, 0.37, 1, 0.79, 0.12), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(182.97526, 204.64426, 195.25807, 156.41809, 139.22312, 94.296637), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(20, 74.777896, 78.138507, 20, 71.766138, 76.107578, 20, 69.720212, 75.189157, 20, 60.637889, 60.622327, 20, 55.732819, 56.713222, 20, 47.895918, 41.888746, 10, 37.388948, 39.069254, 10, 35.883069, 38.053789, 10, 34.860106, 37.594578, 10, 30.318944, 30.311164, 10, 27.86641, 28.356611, 10, 23.947959, 20.944373), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.22017652, 0.27054625, 0.3536952, 0.48224278, 0.56831776, 0.65933958), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.12006552, 0.18276066, 0.26908136, 0.50518351, 0.66786884, 0.67359844), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- allocationRatioPlanned <- 2
- factor <- 1 + 1 / allocationRatioPlanned
- y <- getSimulationMeans(design,
- plannedSubjects = round(factor * c(20, 40, 60)), normalApproximation = TRUE, stDev = 1.5,
- conditionalPower = 0.80, minNumberOfSubjectsPerStage = round(factor * c(NA, 20, 20)),
- maxNumberOfSubjectsPerStage = round(factor * c(NA, 80, 80)), alternative = seq(0, 1, 0.2), # thetaH1 = 0.5,
- maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 5678
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(0.03, 0.07, -0.04, 0.01, 0.02, -0.02), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(0, 0.02, 0.01, -0.01, 0.04, -0.09), tolerance = 1e-07, label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(0.03, 0, -0.07, 0.06, 0.02, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(0, 0.05, 0.02, -0.04, -0.04, 0.04), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(0.17, 0, 0.04, -0.04, 0, 0.02), tolerance = 1e-07, label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(-0.05, 0.01, 0, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(-2.8, -1.3, -0.3, -0.1, -1.4, 10.8), tolerance = 1e-07, label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(1.7, -3.3, -3.4, 13.2, -9.7, -6.7), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(-37.8, -8.9, -5.5, 10.1, -12.7, 15.8), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(-0.43, -0.22, -0.58, -0.5, -0.27, -0.48), tolerance = 1e-07, label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(-0.05, -0.32, -0.59, 0.04, 0.06, -0.17), tolerance = 1e-07, label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ design <- getDesignInverseNormal(typeOfDesign = "WT", deltaWT = 0.15, futilityBounds = c(-0.5, 0), informationRates = c(0.4, 0.8, 1))
+ x <- getSimulationMultiArmMeans(
+ design = design, activeArms = 1,
+ plannedSubjects = c(20, 40, 60), stDev = 1.5, muMaxVector = seq(0, 1, 0.2),
+ conditionalPower = 0.80, minNumberOfSubjectsPerStage = c(NA, 20, 20),
+ maxNumberOfSubjectsPerStage = c(NA, 80, 80), # thetaH1 = 0.5,
+ maxNumberOfIterations = 100, allocationRatioPlanned = 2, seed = 1234
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100, 100), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(81, 88, 89, 88, 93, 79), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(53, 70, 64, 51, 37, 12), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.01, 0.11, 0.39, 0.73, 0.93, 0.98), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0.01, 0, 0.05, 0.06, 0.01, 0.22, 0.16, 0.02, 0.37, 0.34, 0.06, 0.56, 0.31, 0.2, 0.67, 0.11), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0.47, 0.25, 0.13, 0.1, 0.01, 0.01), tolerance = 1e-07, label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0.19, 0.12, 0.1, 0.1, 0.01, 0.01), tolerance = 1e-07, label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0.28, 0.13, 0.03, 0, 0, 0), tolerance = 1e-07, label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0.19, 0.12, 0.11, 0.12, 0.07, 0.21), tolerance = 1e-07, label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.28, 0.18, 0.25, 0.37, 0.56, 0.67), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0.01, 0.02, 0.06, 0.2), tolerance = 1e-07, label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0.05, 0.22, 0.37, 0.56, 0.67), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0.01, 0.06, 0.16, 0.34, 0.31, 0.11), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.81, 0.53, 1, 0.88, 0.7, 1, 0.89, 0.64, 1, 0.88, 0.51, 1, 0.93, 0.37, 1, 0.79, 0.12, 1, 0.81, 0.53, 1, 0.88, 0.7, 1, 0.89, 0.64, 1, 0.88, 0.51, 1, 0.93, 0.37, 1, 0.79, 0.12), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(1, 1, 1, 1, 1, 1), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(182.97526, 204.64426, 195.25807, 156.41809, 139.22312, 94.296637), tolerance = 1e-07, label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(20, 74.777896, 78.138507, 20, 71.766138, 76.107578, 20, 69.720212, 75.189157, 20, 60.637889, 60.622327, 20, 55.732819, 56.713222, 20, 47.895918, 41.888746, 10, 37.388948, 39.069254, 10, 35.883069, 38.053789, 10, 34.860106, 37.594578, 10, 30.318944, 30.311164, 10, 27.86641, 28.356611, 10, 23.947959, 20.944373), tolerance = 1e-07, label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.22017652, 0.27054625, 0.3536952, 0.48224278, 0.56831776, 0.65933958), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.12006552, 0.18276066, 0.26908136, 0.50518351, 0.66786884, 0.67359844), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ allocationRatioPlanned <- 2
+ factor <- 1 + 1 / allocationRatioPlanned
+ y <- getSimulationMeans(design,
+ plannedSubjects = round(factor * c(20, 40, 60)), normalApproximation = TRUE, stDev = 1.5,
+ conditionalPower = 0.80, minNumberOfSubjectsPerStage = round(factor * c(NA, 20, 20)),
+ maxNumberOfSubjectsPerStage = round(factor * c(NA, 80, 80)), alternative = seq(0, 1, 0.2), # thetaH1 = 0.5,
+ maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 5678
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(0.03, 0.07, -0.04, 0.01, 0.02, -0.02), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(0, 0.02, 0.01, -0.01, 0.04, -0.09), tolerance = 1e-07, label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(0.03, 0, -0.07, 0.06, 0.02, 0.03), tolerance = 1e-07, label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(0, 0.05, 0.02, -0.04, -0.04, 0.04), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(0.17, 0, 0.04, -0.04, 0, 0.02), tolerance = 1e-07, label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(-0.05, 0.01, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0, 0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(-2.8, -1.3, -0.3, -0.1, -1.4, 10.8), tolerance = 1e-07, label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(1.7, -3.3, -3.4, 13.2, -9.7, -6.7), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(-37.8, -8.9, -5.5, 10.1, -12.7, 15.8), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(-0.43, -0.22, -0.58, -0.5, -0.27, -0.48), tolerance = 1e-07, label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(-0.05, -0.32, -0.59, 0.04, 0.06, -0.17), tolerance = 1e-07, label = paste0(comp6[2, ]))
})
test_that("'getSimulationMultiArmMeans': comparison of base and multi-arm, Fisher design", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
- # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- design <- getDesignFisher(alpha0Vec = c(0.3, 0.4), informationRates = c(0.3, 0.6, 1))
- x <- getSimulationMultiArmMeans(
- design = design, activeArms = 1,
- plannedSubjects = c(20, 40, 60), stDev = 1.5, muMaxVector = seq(0, 1, 0.2),
- conditionalPower = 0.80, minNumberOfSubjectsPerStage = c(NA, 20, 20),
- maxNumberOfSubjectsPerStage = c(NA, 80, 80), # thetaH1 = 0.5,
- maxNumberOfIterations = 100, allocationRatioPlanned = 2, seed = 1234
- )
-
- ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
- expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100, 100), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(28, 41, 50, 54, 56, 51), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(7, 24, 27, 21, 24, 7), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.03, 0.08, 0.28, 0.61, 0.75, 0.89), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0.02, 0, 0.01, 0.05, 0.01, 0.02, 0.05, 0.16, 0.07, 0.17, 0.3, 0.14, 0.24, 0.31, 0.2, 0.39, 0.44, 0.06), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0.91, 0.7, 0.52, 0.32, 0.21, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0.7, 0.54, 0.45, 0.29, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0.21, 0.16, 0.07, 0.03, 0.01, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0.72, 0.59, 0.5, 0.46, 0.44, 0.49), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.21, 0.17, 0.23, 0.33, 0.32, 0.44), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0.02, 0.05, 0.05, 0.17, 0.24, 0.39), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0.01, 0.16, 0.3, 0.31, 0.44), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0.01, 0.02, 0.07, 0.14, 0.2, 0.06), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.28, 0.07, 1, 0.41, 0.24, 1, 0.5, 0.27, 1, 0.54, 0.21, 1, 0.56, 0.24, 1, 0.51, 0.07, 1, 0.28, 0.07, 1, 0.41, 0.24, 1, 0.5, 0.27, 1, 0.54, 0.21, 1, 0.56, 0.24, 1, 0.51, 0.07), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(68.211396, 101.92536, 114.30453, 107.14861, 109.24288, 79.622055), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(20, 70.979514, 80, 20, 71.410143, 77.800325, 20, 69.572428, 79.321509, 20, 66.884783, 72.926791, 20, 62.423876, 74.4634, 20, 55.785406, 66.154471, 10, 35.489757, 40, 10, 35.705072, 38.900163, 10, 34.786214, 39.660755, 10, 33.442392, 36.463396, 10, 31.211938, 37.2317, 10, 27.892703, 33.077236), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.53965216, 0.44870166, 0.54176291, 0.51257459, 0.62161545, 0.65580386), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.33271205, 0.28302479, 0.35942136, 0.59988705, 0.63386368, 0.5469144), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- allocationRatioPlanned <- 2
- factor <- 1 + 1 / allocationRatioPlanned
- y <- getSimulationMeans(design,
- plannedSubjects = round(factor * c(20, 40, 60)), normalApproximation = TRUE, stDev = 1.5,
- conditionalPower = 0.80, minNumberOfSubjectsPerStage = round(factor * c(NA, 20, 20)),
- maxNumberOfSubjectsPerStage = round(factor * c(NA, 80, 80)), alternative = seq(0, 1, 0.2), # thetaH1 = 0.5,
- maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 5678
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(-0.01, 0.02, 0.05, -0.03, -0.04, -0.04), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(-0.01, -0.02, 0.05, -0.01, -0.05, -0.06), tolerance = 1e-07, label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(0.01, 0.03, -0.07, -0.08, 0.04, 0.05), tolerance = 1e-07, label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(-0.01, 0.01, 0.07, 0.06, -0.03, -0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(0.08, 0.03, 0.01, 0.04, 0.02, 0.04), tolerance = 1e-07, label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(-0.1, 0.03, 0, 0, 0.03, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(-3.6, -5.8, 8.4, 5.5, -3.5, 4.7), tolerance = 1e-07, label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(0, -1.8, -3.2, 7.1, -0.8, -19), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(-5.8, -11.9, -2.3, 7.1, -3.9, -0.3), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(-0.19, -0.13, -0.3, -0.45, -0.28, -0.31), tolerance = 1e-07, label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(-0.62, -0.57, -0.74, -0.5, -0.42, -0.53), tolerance = 1e-07, label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmMeans}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmMeansGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmMeansTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ design <- getDesignFisher(alpha0Vec = c(0.3, 0.4), informationRates = c(0.3, 0.6, 1))
+ x <- getSimulationMultiArmMeans(
+ design = design, activeArms = 1,
+ plannedSubjects = c(20, 40, 60), stDev = 1.5, muMaxVector = seq(0, 1, 0.2),
+ conditionalPower = 0.80, minNumberOfSubjectsPerStage = c(NA, 20, 20),
+ maxNumberOfSubjectsPerStage = c(NA, 80, 80), # thetaH1 = 0.5,
+ maxNumberOfIterations = 100, allocationRatioPlanned = 2, seed = 1234
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmMeans object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100, 100), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(28, 41, 50, 54, 56, 51), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(7, 24, 27, 21, 24, 7), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.03, 0.08, 0.28, 0.61, 0.75, 0.89), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0.02, 0, 0.01, 0.05, 0.01, 0.02, 0.05, 0.16, 0.07, 0.17, 0.3, 0.14, 0.24, 0.31, 0.2, 0.39, 0.44, 0.06), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0.91, 0.7, 0.52, 0.32, 0.21, 0.1), tolerance = 1e-07, label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0.7, 0.54, 0.45, 0.29, 0.2, 0.1), tolerance = 1e-07, label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0.21, 0.16, 0.07, 0.03, 0.01, 0), tolerance = 1e-07, label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0.72, 0.59, 0.5, 0.46, 0.44, 0.49), tolerance = 1e-07, label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.21, 0.17, 0.23, 0.33, 0.32, 0.44), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0.02, 0.05, 0.05, 0.17, 0.24, 0.39), tolerance = 1e-07, label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0.01, 0.16, 0.3, 0.31, 0.44), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0.01, 0.02, 0.07, 0.14, 0.2, 0.06), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.28, 0.07, 1, 0.41, 0.24, 1, 0.5, 0.27, 1, 0.54, 0.21, 1, 0.56, 0.24, 1, 0.51, 0.07, 1, 0.28, 0.07, 1, 0.41, 0.24, 1, 0.5, 0.27, 1, 0.54, 0.21, 1, 0.56, 0.24, 1, 0.51, 0.07), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(1, 1, 1, 1, 1, 1), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(68.211396, 101.92536, 114.30453, 107.14861, 109.24288, 79.622055), tolerance = 1e-07, label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(20, 70.979514, 80, 20, 71.410143, 77.800325, 20, 69.572428, 79.321509, 20, 66.884783, 72.926791, 20, 62.423876, 74.4634, 20, 55.785406, 66.154471, 10, 35.489757, 40, 10, 35.705072, 38.900163, 10, 34.786214, 39.660755, 10, 33.442392, 36.463396, 10, 31.211938, 37.2317, 10, 27.892703, 33.077236), tolerance = 1e-07, label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.53965216, 0.44870166, 0.54176291, 0.51257459, 0.62161545, 0.65580386), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.33271205, 0.28302479, 0.35942136, 0.59988705, 0.63386368, 0.5469144), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ allocationRatioPlanned <- 2
+ factor <- 1 + 1 / allocationRatioPlanned
+ y <- getSimulationMeans(design,
+ plannedSubjects = round(factor * c(20, 40, 60)), normalApproximation = TRUE, stDev = 1.5,
+ conditionalPower = 0.80, minNumberOfSubjectsPerStage = round(factor * c(NA, 20, 20)),
+ maxNumberOfSubjectsPerStage = round(factor * c(NA, 80, 80)), alternative = seq(0, 1, 0.2), # thetaH1 = 0.5,
+ maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 5678
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(-0.01, 0.02, 0.05, -0.03, -0.04, -0.04), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(-0.01, -0.02, 0.05, -0.01, -0.05, -0.06), tolerance = 1e-07, label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(0.01, 0.03, -0.07, -0.08, 0.04, 0.05), tolerance = 1e-07, label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(-0.01, 0.01, 0.07, 0.06, -0.03, -0.03), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(0.08, 0.03, 0.01, 0.04, 0.02, 0.04), tolerance = 1e-07, label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(-0.1, 0.03, 0, 0, 0.03, 0.01), tolerance = 1e-07, label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0, 0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(-3.6, -5.8, 8.4, 5.5, -3.5, 4.7), tolerance = 1e-07, label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(0, -1.8, -3.2, 7.1, -0.8, -19), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(-5.8, -11.9, -2.3, 7.1, -3.9, -0.3), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(-0.19, -0.13, -0.3, -0.45, -0.28, -0.31), tolerance = 1e-07, label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(-0.62, -0.57, -0.74, -0.5, -0.42, -0.53), tolerance = 1e-07, label = paste0(comp6[2, ]))
})
-
diff --git a/tests/testthat/test-f_simulation_multiarm_rates.R b/tests/testthat/test-f_simulation_multiarm_rates.R
index 9accb99d..ba28a995 100644
--- a/tests/testthat/test-f_simulation_multiarm_rates.R
+++ b/tests/testthat/test-f_simulation_multiarm_rates.R
@@ -1,1718 +1,1707 @@
-## |
+## |
## | *Unit tests*
-## |
+## |
## | This file is part of the R package rpact:
## | Confirmatory Adaptive Clinical Trial Design and Analysis
-## |
+## |
## | Author: Gernot Wassmer, PhD, and Friedrich Pahlke, PhD
## | Licensed under "GNU Lesser General Public License" version 3
## | License text can be found here: https://www.r-project.org/Licenses/LGPL-3
-## |
+## |
## | RPACT company website: https://www.rpact.com
## | RPACT package website: https://www.rpact.org
-## |
+## |
## | Contact us for information about our services: info@rpact.com
-## |
+## |
## | File name: test-f_simulation_multiarm_rates.R
-## | Creation date: 08 November 2023, 09:11:51
-## | File version: $Revision: 7560 $
-## | Last changed: $Date: 2024-01-15 14:20:32 +0100 (Mo, 15 Jan 2024) $
+## | Creation date: 09 February 2024, 10:57:39
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
-## |
+## |
test_plan_section("Testing Simulation Multi-Arm Rates Function")
test_that("'getSimulationMultiArmRates': several configurations", {
- .skipTestIfNotX64()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
- # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetBonferroni}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- # @refFS[Formula]{fs:adjustedPValueSubsetHierarchical}
- # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
- # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
- x1 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x1' with expected results
- expect_equal(x1$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x1$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x1$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x1$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x1$iterations[3, ], c(10, 10, 9, 7), label = paste0("c(", paste0(x1$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x1$rejectAtLeastOne, c(0, 0.1, 0.6, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x1$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.2, 0, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x1$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityStop, collapse = ", "), ")"))
- expect_equal(x1$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x1$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x1$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x1$earlyStop[2, ], c(0, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x1$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[2, ], c(0, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x1$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[3, ], c(0, 0.1, 0.5, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x1$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$selectedArms)), c(1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0, 0, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.3, 0.2, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.4, 0.3, 1, 0.5, 0.3, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$selectedArms)), collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x1$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x1$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x1$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x1$expectedNumberOfSubjects, c(334.8, 445, 331.8, 179.8), tolerance = 1e-07, label = paste0("c(", paste0(x1$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$sampleSizes)), c(10, 8, 10.4, 10, 10, 10, 10, 11.3, 15.333333, 10, 0, 0, 10, 10, 10, 10, 17.5, 20, 10, 0, 0, 10, 13, 19.142857, 10, 22.4, 22.5, 10, 40, 40, 10, 37.5, 36.555556, 10, 4.4, 8.5714286, 10, 20.4, 38.7, 10, 30, 30, 10, 28.2, 19.111111, 10, 17.1, 15.714286, 10, 60.8, 81.6, 10, 97.5, 100, 10, 77, 71, 10, 34.5, 43.428571), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[2, ], c(0.032197948, 0.00019444487, 0.052129075, 0.12394528), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[3, ], c(0.33607045, 0.04525892, 0.4023749, 0.68738904), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x1), NA)))
- expect_output(print(x1)$show())
- invisible(capture.output(expect_error(summary(x1), NA)))
- expect_output(summary(x1)$show())
- x1CodeBased <- eval(parse(text = getObjectRCode(x1, stringWrapParagraphWidth = NULL)))
- expect_equal(x1CodeBased$iterations, x1$iterations, tolerance = 1e-07)
- expect_equal(x1CodeBased$rejectAtLeastOne, x1$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x1CodeBased$rejectedArmsPerStage, x1$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$futilityStop, x1$futilityStop, tolerance = 1e-07)
- expect_equal(x1CodeBased$futilityPerStage, x1$futilityPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$earlyStop, x1$earlyStop, tolerance = 1e-07)
- expect_equal(x1CodeBased$successPerStage, x1$successPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$selectedArms, x1$selectedArms, tolerance = 1e-07)
- expect_equal(x1CodeBased$numberOfActiveArms, x1$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x1CodeBased$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x1CodeBased$sampleSizes, x1$sampleSizes, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPowerAchieved, x1$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x1), "character")
- df <- as.data.frame(x1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- .skipTestIfDisabled()
-
- x2 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "userDefined", activeArms = 4,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, adaptations = rep(TRUE, 2),
- effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x2' with expected results
- expect_equal(x2$iterations[1, ], c(10, 10), label = paste0("c(", paste0(x2$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x2$iterations[2, ], c(10, 10), label = paste0("c(", paste0(x2$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x2$iterations[3, ], c(10, 8), label = paste0("c(", paste0(x2$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x2$rejectAtLeastOne, c(0.2, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x2$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x2$futilityStop, c(0, 0), label = paste0("c(", paste0(x2$futilityStop, collapse = ", "), ")"))
- expect_equal(x2$futilityPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x2$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x2$futilityPerStage[2, ], c(0, 0), label = paste0("c(", paste0(x2$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x2$earlyStop[1, ], c(0, 0), label = paste0("c(", paste0(x2$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x2$earlyStop[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x2$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x2$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x2$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[3, ], c(0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x2$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0, 0, 1, 0.5, 0.5, 1, 0.7, 0.5, 1, 1, 1, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$selectedArms)), collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[1, ], c(4, 4), label = paste0("c(", paste0(x2$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[2, ], c(1, 1), label = paste0("c(", paste0(x2$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[3, ], c(1, 1), label = paste0("c(", paste0(x2$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x2$expectedNumberOfSubjects, c(397.2, 312.8), tolerance = 1e-07, label = paste0("c(", paste0(x2$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 30, 30, 10, 22.4, 37.5, 10, 13, 20, 10, 0, 0, 10, 38.8, 41.8, 10, 52.8, 32.75, 10, 81.8, 91.8, 10, 75.2, 70.25), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[2, ], c(0.0097327907, 0.021741893), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[3, ], c(0.14656813, 0.35197865), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x2), NA)))
- expect_output(print(x2)$show())
- invisible(capture.output(expect_error(summary(x2), NA)))
- expect_output(summary(x2)$show())
- x2CodeBased <- eval(parse(text = getObjectRCode(x2, stringWrapParagraphWidth = NULL)))
- expect_equal(x2CodeBased$iterations, x2$iterations, tolerance = 1e-07)
- expect_equal(x2CodeBased$rejectAtLeastOne, x2$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x2CodeBased$rejectedArmsPerStage, x2$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$futilityStop, x2$futilityStop, tolerance = 1e-07)
- expect_equal(x2CodeBased$futilityPerStage, x2$futilityPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$earlyStop, x2$earlyStop, tolerance = 1e-07)
- expect_equal(x2CodeBased$successPerStage, x2$successPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$selectedArms, x2$selectedArms, tolerance = 1e-07)
- expect_equal(x2CodeBased$numberOfActiveArms, x2$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x2CodeBased$expectedNumberOfSubjects, x2$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x2CodeBased$sampleSizes, x2$sampleSizes, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPowerAchieved, x2$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x2), "character")
- df <- as.data.frame(x2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x3 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x3' with expected results
- expect_equal(x3$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x3$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x3$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x3$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x3$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x3$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x3$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityStop, collapse = ", "), ")"))
- expect_equal(x3$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x3$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x3$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x3$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$selectedArms)), collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x3$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x3$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x3$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x3$expectedNumberOfSubjects, c(434.8, 402, 440, 425), tolerance = 1e-07, label = paste0("c(", paste0(x3$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 15, 20, 10, 10, 10, 10, 30, 30, 10, 12.7, 20, 10, 40, 40, 10, 20, 20, 10, 30, 30, 10, 29.1, 34.2, 10, 30, 30, 10, 33.4, 40, 10, 32.4, 40, 10, 40, 40, 10, 10, 10, 10, 26.7, 27.4, 10, 92.4, 100, 10, 81.8, 94.2, 10, 95, 100, 10, 90.1, 97.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[2, ], c(0.0098526063, 0.0022619481, 0.010226943, 0.0071111057), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[3, ], c(0.00025317548, 0.089328639, 4.5501958e-05, 0.12015791), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x3), NA)))
- expect_output(print(x3)$show())
- invisible(capture.output(expect_error(summary(x3), NA)))
- expect_output(summary(x3)$show())
- x3CodeBased <- eval(parse(text = getObjectRCode(x3, stringWrapParagraphWidth = NULL)))
- expect_equal(x3CodeBased$iterations, x3$iterations, tolerance = 1e-07)
- expect_equal(x3CodeBased$rejectAtLeastOne, x3$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x3CodeBased$rejectedArmsPerStage, x3$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$futilityStop, x3$futilityStop, tolerance = 1e-07)
- expect_equal(x3CodeBased$futilityPerStage, x3$futilityPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$earlyStop, x3$earlyStop, tolerance = 1e-07)
- expect_equal(x3CodeBased$successPerStage, x3$successPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$selectedArms, x3$selectedArms, tolerance = 1e-07)
- expect_equal(x3CodeBased$numberOfActiveArms, x3$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x3CodeBased$expectedNumberOfSubjects, x3$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x3CodeBased$sampleSizes, x3$sampleSizes, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPowerAchieved, x3$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x3), "character")
- df <- as.data.frame(x3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x4 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x4' with expected results
- expect_equal(x4$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x4$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x4$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x4$rejectAtLeastOne, c(0, 0.3, 0.7, 1), tolerance = 1e-07, label = paste0("c(", paste0(x4$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3, 0, 0.3, 0.4, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0.2, 0, 0.4, 0.3, 0, 0.8, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x4$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityStop, collapse = ", "), ")"))
- expect_equal(x4$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x4$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x4$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x4$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[3, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x4$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(unlist(as.list(x4$selectedArms)), collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x4$expectedNumberOfSubjects, c(1026, 1002, 924.5, 714.5), tolerance = 1e-07, label = paste0("c(", paste0(x4$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$sampleSizes)), c(10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[2, ], c(0.16336896, 3.7379108e-06, 0.18421481, 0.069788183), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[3, ], c(0.00052547754, 0.089531131, 0.32040425, 0.67566016), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x4), NA)))
- expect_output(print(x4)$show())
- invisible(capture.output(expect_error(summary(x4), NA)))
- expect_output(summary(x4)$show())
- x4CodeBased <- eval(parse(text = getObjectRCode(x4, stringWrapParagraphWidth = NULL)))
- expect_equal(x4CodeBased$iterations, x4$iterations, tolerance = 1e-07)
- expect_equal(x4CodeBased$rejectAtLeastOne, x4$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x4CodeBased$rejectedArmsPerStage, x4$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$futilityStop, x4$futilityStop, tolerance = 1e-07)
- expect_equal(x4CodeBased$futilityPerStage, x4$futilityPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$earlyStop, x4$earlyStop, tolerance = 1e-07)
- expect_equal(x4CodeBased$successPerStage, x4$successPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$selectedArms, x4$selectedArms, tolerance = 1e-07)
- expect_equal(x4CodeBased$numberOfActiveArms, x4$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x4CodeBased$expectedNumberOfSubjects, x4$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x4CodeBased$sampleSizes, x4$sampleSizes, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalPowerAchieved, x4$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x4), "character")
- df <- as.data.frame(x4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x5 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x5' with expected results
- expect_equal(x5$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x5$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x5$iterations[3, ], c(10, 10, 8, 6), label = paste0("c(", paste0(x5$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x5$rejectAtLeastOne, c(0, 0.3, 0.9, 1), tolerance = 1e-07, label = paste0("c(", paste0(x5$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0.1, 0, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.2, 0, 0.3, 0.1, 0, 0, 0, 0, 0, 0.2, 0, 0.3, 0.4, 0, 0.8, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x5$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityStop, collapse = ", "), ")"))
- expect_equal(x5$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x5$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x5$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x5$earlyStop[2, ], c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x5$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[2, ], c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x5$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[3, ], c(0, 0, 0.3, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x5$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$selectedArms)), c(1, 0.8, 0.8, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.2, 1, 0.3, 0.1, 1, 0.6, 0.6, 1, 0.5, 0.5, 1, 0.6, 0.5, 1, 0.6, 0.3, 1, 0.5, 0.5, 1, 0.8, 0.8, 1, 0.8, 0.7, 1, 0.9, 0.6, 1, 1, 1, 1, 1, 1, 1, 1, 0.8, 1, 1, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$selectedArms)), collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x5$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x5$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x5$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x5$expectedNumberOfSubjects, c(642.8, 566.9, 399.8, 265.1), tolerance = 1e-07, label = paste0("c(", paste0(x5$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$sampleSizes)), c(10, 77.6, 80, 10, 23.9, 30, 10, 20, 1, 10, 12.3, 1.3333333, 10, 10, 10, 10, 30.2, 28.6, 10, 28.6, 25, 10, 20, 3.1666667, 10, 60, 60, 10, 49.7, 41.1, 10, 37.4, 28.25, 10, 40.8, 9.8333333, 10, 47.6, 50, 10, 63.8, 77.3, 10, 61.2, 53.25, 10, 53.1, 14.333333, 10, 97.6, 100, 10, 83.8, 88.5, 10, 73.6, 53.75, 10, 63.1, 14.333333), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x5$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[2, ], c(0.080486965, 0.12759682, 0.10458054, 0.065420449), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[3, ], c(0.022470074, 0.31122739, 0.58569198, 0.85520318), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x5), NA)))
- expect_output(print(x5)$show())
- invisible(capture.output(expect_error(summary(x5), NA)))
- expect_output(summary(x5)$show())
- x5CodeBased <- eval(parse(text = getObjectRCode(x5, stringWrapParagraphWidth = NULL)))
- expect_equal(x5CodeBased$iterations, x5$iterations, tolerance = 1e-07)
- expect_equal(x5CodeBased$rejectAtLeastOne, x5$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x5CodeBased$rejectedArmsPerStage, x5$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$futilityStop, x5$futilityStop, tolerance = 1e-07)
- expect_equal(x5CodeBased$futilityPerStage, x5$futilityPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$earlyStop, x5$earlyStop, tolerance = 1e-07)
- expect_equal(x5CodeBased$successPerStage, x5$successPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$selectedArms, x5$selectedArms, tolerance = 1e-07)
- expect_equal(x5CodeBased$numberOfActiveArms, x5$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x5CodeBased$expectedNumberOfSubjects, x5$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x5CodeBased$sampleSizes, x5$sampleSizes, tolerance = 1e-07)
- expect_equal(x5CodeBased$conditionalPowerAchieved, x5$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x5), "character")
- df <- as.data.frame(x5)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x5)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x6 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x6' with expected results
- expect_equal(x6$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x6$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x6$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x6$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x6$iterations[3, ], c(10, 10, 8, 7), label = paste0("c(", paste0(x6$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x6$rejectAtLeastOne, c(0, 0.4, 0.8, 1), tolerance = 1e-07, label = paste0("c(", paste0(x6$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.2, 0, 0.3, 0.4, 0, 0, 0, 0, 0, 0.4, 0, 0.2, 0.5, 0, 0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x6$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityStop, collapse = ", "), ")"))
- expect_equal(x6$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x6$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x6$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x6$earlyStop[2, ], c(0, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x6$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[2, ], c(0, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x6$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[3, ], c(0, 0.4, 0.6, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x6$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$selectedArms)), c(1, 0.2, 0.2, 1, 0.4, 0.1, 1, 0.3, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.2, 0.1, 1, 0.2, 0, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.3, 0.2, 1, 0.9, 0.4, 1, 0.3, 0.3, 1, 0.7, 0.7, 1, 0.9, 0.7, 1, 0.9, 0.6, 1, 1, 1, 1, 1, 1, 1, 1, 0.8, 1, 1, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$selectedArms)), collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x6$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[2, ], c(1.3, 1.6, 1.7, 2.1), tolerance = 1e-07, label = paste0("c(", paste0(x6$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[3, ], c(1.3, 1.2, 1.375, 1.5714286), tolerance = 1e-07, label = paste0("c(", paste0(x6$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x6$expectedNumberOfSubjects, c(436.4, 438.6, 346.7, 372.5), tolerance = 1e-07, label = paste0("c(", paste0(x6$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$sampleSizes)), c(10, 16.7, 20, 10, 27.9, 10, 10, 9.1, 12.5, 10, 1.2, 14.285714, 10, 37.5, 40, 10, 1.2, 0, 10, 12.3, 11.625, 10, 7.9, 0, 10, 32.4, 32.5, 10, 31.2, 40, 10, 21.5, 13.375, 10, 63.2, 50.142857, 10, 15.4, 28.7, 10, 56.2, 59, 10, 60.4, 63, 10, 58, 51.714286, 10, 72, 91.2, 10, 74.1, 89, 10, 61.9, 63.875, 10, 64.7, 66), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x6$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[2, ], c(0.031688257, 0.035836944, 0.12967885, 0.10427074), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[3, ], c(0.2491354, 0.21222327, 0.47711159, 0.3978836), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x6), NA)))
- expect_output(print(x6)$show())
- invisible(capture.output(expect_error(summary(x6), NA)))
- expect_output(summary(x6)$show())
- x6CodeBased <- eval(parse(text = getObjectRCode(x6, stringWrapParagraphWidth = NULL)))
- expect_equal(x6CodeBased$iterations, x6$iterations, tolerance = 1e-07)
- expect_equal(x6CodeBased$rejectAtLeastOne, x6$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x6CodeBased$rejectedArmsPerStage, x6$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$futilityStop, x6$futilityStop, tolerance = 1e-07)
- expect_equal(x6CodeBased$futilityPerStage, x6$futilityPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$earlyStop, x6$earlyStop, tolerance = 1e-07)
- expect_equal(x6CodeBased$successPerStage, x6$successPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$selectedArms, x6$selectedArms, tolerance = 1e-07)
- expect_equal(x6CodeBased$numberOfActiveArms, x6$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x6CodeBased$expectedNumberOfSubjects, x6$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x6CodeBased$sampleSizes, x6$sampleSizes, tolerance = 1e-07)
- expect_equal(x6CodeBased$conditionalPowerAchieved, x6$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x6), "character")
- df <- as.data.frame(x6)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x6)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x7 <- getSimulationMultiArmRates(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x7' with expected results
- expect_equal(x7$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x7$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x7$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x7$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x7$iterations[3, ], c(10, 9, 8, 5), label = paste0("c(", paste0(x7$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x7$rejectAtLeastOne, c(0, 0.4, 0.5, 1), tolerance = 1e-07, label = paste0("c(", paste0(x7$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0.1, 0.2, 0, 0, 0, 0, 0.1, 0.2, 0, 0.2, 0, 0, 0.4, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x7$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityStop, collapse = ", "), ")"))
- expect_equal(x7$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x7$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x7$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x7$earlyStop[2, ], c(0, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x7$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[2, ], c(0, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x7$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[3, ], c(0, 0.3, 0.3, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x7$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$selectedArms)), c(1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.2, 1, 0, 0, 1, 0.3, 0.3, 1, 0, 0, 1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.2, 1, 0.3, 0.3, 1, 0.6, 0.5, 1, 0.4, 0.2, 1, 0.7, 0.3, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$selectedArms)), collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x7$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x7$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x7$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x7$expectedNumberOfSubjects, c(355.2, 334, 233, 193.4), tolerance = 1e-07, label = paste0("c(", paste0(x7$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$sampleSizes)), c(10, 20, 20, 10, 0, 0, 10, 20, 25, 10, 0, 0, 10, 30, 30, 10, 0, 0, 10, 3, 3.75, 10, 0, 0, 10, 12.4, 12.4, 10, 20.7, 22.777778, 10, 15, 18.75, 10, 16.2, 26.4, 10, 13.9, 13.9, 10, 54.2, 51.777778, 10, 13.1, 3, 10, 30.3, 24, 10, 76.3, 76.3, 10, 74.9, 74.555556, 10, 51.1, 50.5, 10, 46.5, 50.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x7$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[2, ], c(0.035427106, 0.012436575, 0.08338715, 0.046283385), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[3, ], c(0.076058567, 0.27636533, 0.46741694, 0.70493817), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x7), NA)))
- expect_output(print(x7)$show())
- invisible(capture.output(expect_error(summary(x7), NA)))
- expect_output(summary(x7)$show())
- x7CodeBased <- eval(parse(text = getObjectRCode(x7, stringWrapParagraphWidth = NULL)))
- expect_equal(x7CodeBased$iterations, x7$iterations, tolerance = 1e-07)
- expect_equal(x7CodeBased$rejectAtLeastOne, x7$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x7CodeBased$rejectedArmsPerStage, x7$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$futilityStop, x7$futilityStop, tolerance = 1e-07)
- expect_equal(x7CodeBased$futilityPerStage, x7$futilityPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$earlyStop, x7$earlyStop, tolerance = 1e-07)
- expect_equal(x7CodeBased$successPerStage, x7$successPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$selectedArms, x7$selectedArms, tolerance = 1e-07)
- expect_equal(x7CodeBased$numberOfActiveArms, x7$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x7CodeBased$expectedNumberOfSubjects, x7$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x7CodeBased$sampleSizes, x7$sampleSizes, tolerance = 1e-07)
- expect_equal(x7CodeBased$conditionalPowerAchieved, x7$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x7), "character")
- df <- as.data.frame(x7)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x7)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x8 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x8' with expected results
- expect_equal(x8$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x8$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x8$iterations[3, ], c(10, 10, 9, 8), label = paste0("c(", paste0(x8$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x8$rejectAtLeastOne, c(0, 0.2, 0.9, 1), tolerance = 1e-07, label = paste0("c(", paste0(x8$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.1, 0.3, 0, 0.2, 0.4, 0, 0, 0, 0, 0, 0.1, 0, 0.3, 0.3, 0.1, 0.4, 0.5, 0, 0, 0, 0, 0, 0.1, 0, 0.4, 0.5, 0.1, 0.8, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x8$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityStop, collapse = ", "), ")"))
- expect_equal(x8$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x8$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x8$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x8$earlyStop[2, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x8$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[2, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x8$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[3, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x8$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$selectedArms)), collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x8$expectedNumberOfSubjects, c(952, 1050, 909.5, 860), tolerance = 1e-07, label = paste0("c(", paste0(x8$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$sampleSizes)), c(10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x8$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[2, ], c(0.16068828, 0.022112719, 0.21849189, 0.19646842), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[3, ], c(0.0018216452, 0.044801331, 0.47086458, 0.69046124), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x8), NA)))
- expect_output(print(x8)$show())
- invisible(capture.output(expect_error(summary(x8), NA)))
- expect_output(summary(x8)$show())
- x8CodeBased <- eval(parse(text = getObjectRCode(x8, stringWrapParagraphWidth = NULL)))
- expect_equal(x8CodeBased$iterations, x8$iterations, tolerance = 1e-07)
- expect_equal(x8CodeBased$rejectAtLeastOne, x8$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x8CodeBased$rejectedArmsPerStage, x8$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$futilityStop, x8$futilityStop, tolerance = 1e-07)
- expect_equal(x8CodeBased$futilityPerStage, x8$futilityPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$earlyStop, x8$earlyStop, tolerance = 1e-07)
- expect_equal(x8CodeBased$successPerStage, x8$successPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$selectedArms, x8$selectedArms, tolerance = 1e-07)
- expect_equal(x8CodeBased$numberOfActiveArms, x8$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x8CodeBased$expectedNumberOfSubjects, x8$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x8CodeBased$sampleSizes, x8$sampleSizes, tolerance = 1e-07)
- expect_equal(x8CodeBased$conditionalPowerAchieved, x8$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x8), "character")
- df <- as.data.frame(x8)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x9 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x9' with expected results
- expect_equal(x9$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x9$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x9$iterations[3, ], c(10, 10, 10, 5), label = paste0("c(", paste0(x9$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x9$rejectAtLeastOne, c(0, 0.2, 0.7, 1), tolerance = 1e-07, label = paste0("c(", paste0(x9$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0.2, 0, 0.4, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3, 0.1, 0.6, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x9$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityStop, collapse = ", "), ")"))
- expect_equal(x9$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x9$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x9$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x9$earlyStop[2, ], c(0, 0, 0, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x9$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[2, ], c(0, 0, 0, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x9$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[3, ], c(0, 0.1, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x9$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$selectedArms)), c(1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.2, 0.1, 1, 0.7, 0.7, 1, 0.2, 0.2, 1, 0.5, 0.5, 1, 0.3, 0.2, 1, 0.5, 0.5, 1, 0.7, 0.7, 1, 0.6, 0.6, 1, 0.6, 0.3, 1, 0.2, 0.2, 1, 0.7, 0.7, 1, 0.6, 0.6, 1, 0.9, 0.4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$selectedArms)), collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x9$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x9$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x9$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x9$expectedNumberOfSubjects, c(603.2, 605.9, 453.2, 361.7), tolerance = 1e-07, label = paste0("c(", paste0(x9$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$sampleSizes)), c(10, 52.2, 52.2, 10, 33.6, 33.5, 10, 21.2, 21.2, 10, 9.2, 17.6, 10, 70, 70, 10, 20, 20, 10, 35.6, 35.3, 10, 19.7, 21.4, 10, 45.3, 45.3, 10, 62.7, 62.6, 10, 36.2, 35.8, 10, 52.8, 45.4, 10, 16.9, 16.9, 10, 69.1, 69.1, 10, 41.8, 41.7, 10, 61.7, 44.4, 10, 92.2, 92.2, 10, 92.7, 92.6, 10, 67.4, 67, 10, 71.7, 64.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x9$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[2, ], c(0.083443128, 0.076003514, 0.14647721, 0.085145955), tolerance = 1e-07, label = paste0("c(", paste0(x9$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[3, ], c(0.043093175, 0.13127607, 0.3479275, 0.64693149), tolerance = 1e-07, label = paste0("c(", paste0(x9$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x9), NA)))
- expect_output(print(x9)$show())
- invisible(capture.output(expect_error(summary(x9), NA)))
- expect_output(summary(x9)$show())
- x9CodeBased <- eval(parse(text = getObjectRCode(x9, stringWrapParagraphWidth = NULL)))
- expect_equal(x9CodeBased$iterations, x9$iterations, tolerance = 1e-07)
- expect_equal(x9CodeBased$rejectAtLeastOne, x9$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x9CodeBased$rejectedArmsPerStage, x9$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$futilityStop, x9$futilityStop, tolerance = 1e-07)
- expect_equal(x9CodeBased$futilityPerStage, x9$futilityPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$earlyStop, x9$earlyStop, tolerance = 1e-07)
- expect_equal(x9CodeBased$successPerStage, x9$successPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$selectedArms, x9$selectedArms, tolerance = 1e-07)
- expect_equal(x9CodeBased$numberOfActiveArms, x9$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x9CodeBased$expectedNumberOfSubjects, x9$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x9CodeBased$sampleSizes, x9$sampleSizes, tolerance = 1e-07)
- expect_equal(x9CodeBased$conditionalPowerAchieved, x9$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x9), "character")
- df <- as.data.frame(x9)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x9)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x10 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x10' with expected results
- expect_equal(x10$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x10$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x10$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x10$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x10$iterations[3, ], c(10, 9, 7, 6), label = paste0("c(", paste0(x10$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x10$rejectAtLeastOne, c(0, 0.2, 0.6, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x10$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0.1, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.1, 0, 0.3, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.3, 0, 0, 0.3, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x10$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x10$futilityStop, collapse = ", "), ")"))
- expect_equal(x10$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x10$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x10$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x10$earlyStop[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x10$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x10$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x10$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$selectedArms)), c(1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.5, 0.4, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.3, 1, 0.4, 0.4, 1, 0.7, 0.6, 1, 0.5, 0.3, 1, 0.5, 0.3, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.7, 1, 1, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$selectedArms)), collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x10$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[2, ], c(1.2, 1.8, 1.5, 1.6), tolerance = 1e-07, label = paste0("c(", paste0(x10$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[3, ], c(1.2, 1.7777778, 1.7142857, 1.8333333), tolerance = 1e-07, label = paste0("c(", paste0(x10$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x10$expectedNumberOfSubjects, c(313.2, 474, 363.7, 263.7), tolerance = 1e-07, label = paste0("c(", paste0(x10$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$sampleSizes)), c(10, 15.9, 15.8, 10, 35.9, 39.777778, 10, 12.7, 18, 10, 2.8, 4.6666667, 10, 22.2, 22.2, 10, 30, 22.222222, 10, 22.7, 28.571429, 10, 27.4, 43.166667, 10, 18.1, 18, 10, 32.8, 36.444444, 10, 38.6, 54.857143, 10, 26.7, 26.5, 10, 15.8, 15.8, 10, 54.9, 49.777778, 10, 37.3, 24.571429, 10, 24.9, 23.666667, 10, 59.8, 59.6, 10, 73.6, 70.444444, 10, 68.6, 65.142857, 10, 43, 50.166667), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x10$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[2, ], c(0.067103341, 0.011749166, 0.024807536, 0.13720867), tolerance = 1e-07, label = paste0("c(", paste0(x10$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[3, ], c(0.10265269, 0.46661697, 0.4198773, 0.2422132), tolerance = 1e-07, label = paste0("c(", paste0(x10$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x10), NA)))
- expect_output(print(x10)$show())
- invisible(capture.output(expect_error(summary(x10), NA)))
- expect_output(summary(x10)$show())
- x10CodeBased <- eval(parse(text = getObjectRCode(x10, stringWrapParagraphWidth = NULL)))
- expect_equal(x10CodeBased$iterations, x10$iterations, tolerance = 1e-07)
- expect_equal(x10CodeBased$rejectAtLeastOne, x10$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x10CodeBased$rejectedArmsPerStage, x10$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$futilityStop, x10$futilityStop, tolerance = 1e-07)
- expect_equal(x10CodeBased$futilityPerStage, x10$futilityPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$earlyStop, x10$earlyStop, tolerance = 1e-07)
- expect_equal(x10CodeBased$successPerStage, x10$successPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$selectedArms, x10$selectedArms, tolerance = 1e-07)
- expect_equal(x10CodeBased$numberOfActiveArms, x10$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x10CodeBased$expectedNumberOfSubjects, x10$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x10CodeBased$sampleSizes, x10$sampleSizes, tolerance = 1e-07)
- expect_equal(x10CodeBased$conditionalPowerAchieved, x10$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x10), "character")
- df <- as.data.frame(x10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x11 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100), directionUpper = FALSE,
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x11' with expected results
- expect_equal(x11$iterations[1, ], c(10, 10, 10), label = paste0("c(", paste0(x11$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x11$iterations[2, ], c(8, 5, 9), label = paste0("c(", paste0(x11$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x11$iterations[3, ], c(4, 5, 9), label = paste0("c(", paste0(x11$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x11$rejectAtLeastOne, c(0.4, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x11$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x11$futilityStop, c(0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x11$futilityStop, collapse = ", "), ")"))
- expect_equal(x11$futilityPerStage[1, ], c(0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x11$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x11$futilityPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x11$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x11$earlyStop[1, ], c(0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x11$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x11$earlyStop[2, ], c(0.4, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x11$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x11$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[2, ], c(0.4, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x11$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[3, ], c(0, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x11$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0, 0, 1, 0.2, 0.2, 1, 0.3, 0, 1, 0.1, 0.1, 1, 0.3, 0.2, 1, 0.8, 0.4, 1, 0.5, 0.5, 1, 0.9, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$selectedArms)), collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0("c(", paste0(x11$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0("c(", paste0(x11$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[3, ], c(1, 0.8, 0.66666667), tolerance = 1e-07, label = paste0("c(", paste0(x11$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x11$expectedNumberOfSubjects, c(200.6, 150, 279), tolerance = 1e-07, label = paste0("c(", paste0(x11$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$sampleSizes)), c(10, 1, 3.25, 10, 2.8, 20, 10, 17.333333, 10.444444, 10, 6.25, 50, 10, 23.2, 25.6, 10, 11.111111, 11.111111, 10, 14.5, 21, 10, 0, 0, 10, 15.777778, 22.222222, 10, 35.25, 0, 10, 8.4, 20, 10, 17, 22.222222, 10, 57, 74.25, 10, 34.4, 65.6, 10, 61.222222, 66), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x11$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[2, ], c(0.10402635, 0.15240707, 0.070533409), tolerance = 1e-07, label = paste0("c(", paste0(x11$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[3, ], c(0.68219789, NaN, NaN), tolerance = 1e-07, label = paste0("c(", paste0(x11$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x11), NA)))
- expect_output(print(x11)$show())
- invisible(capture.output(expect_error(summary(x11), NA)))
- expect_output(summary(x11)$show())
- x11CodeBased <- eval(parse(text = getObjectRCode(x11, stringWrapParagraphWidth = NULL)))
- expect_equal(x11CodeBased$iterations, x11$iterations, tolerance = 1e-07)
- expect_equal(x11CodeBased$rejectAtLeastOne, x11$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x11CodeBased$rejectedArmsPerStage, x11$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$futilityStop, x11$futilityStop, tolerance = 1e-07)
- expect_equal(x11CodeBased$futilityPerStage, x11$futilityPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$earlyStop, x11$earlyStop, tolerance = 1e-07)
- expect_equal(x11CodeBased$successPerStage, x11$successPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$selectedArms, x11$selectedArms, tolerance = 1e-07)
- expect_equal(x11CodeBased$numberOfActiveArms, x11$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x11CodeBased$expectedNumberOfSubjects, x11$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x11CodeBased$sampleSizes, x11$sampleSizes, tolerance = 1e-07)
- expect_equal(x11CodeBased$conditionalPowerAchieved, x11$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x11), "character")
- df <- as.data.frame(x11)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x11)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x12 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2), intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x12' with expected results
- expect_equal(x12$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x12$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x12$iterations[2, ], c(6, 6, 7, 9), label = paste0("c(", paste0(x12$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x12$iterations[3, ], c(6, 6, 5, 4), label = paste0("c(", paste0(x12$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x12$rejectAtLeastOne, c(0, 0, 0.5, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x12$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.3, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.2, 0.2, 0, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x12$futilityStop, c(0.4, 0.4, 0.3, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x12$futilityStop, collapse = ", "), ")"))
- expect_equal(x12$futilityPerStage[1, ], c(0.4, 0.4, 0.3, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x12$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x12$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x12$earlyStop[1, ], c(0.4, 0.4, 0.3, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x12$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x12$earlyStop[2, ], c(0, 0, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x12$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[2, ], c(0, 0, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x12$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[3, ], c(0.3, 0.2, 0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x12$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.2, 0, 1, 0.2, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.1, 1, 0.3, 0.2, 1, 0.2, 0.1, 1, 0.4, 0.2, 1, 0.4, 0.2, 1, 0.6, 0.6, 1, 0.6, 0.6, 1, 0.7, 0.5, 1, 0.9, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$selectedArms)), collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x12$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x12$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[3, ], c(0.5, 0.66666667, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x12$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x12$expectedNumberOfSubjects, c(188, 175, 176, 185), label = paste0("c(", paste0(x12$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$sampleSizes)), c(10, 9.8333333, 16, 10, 10.833333, 18.333333, 10, 14.285714, 20, 10, 5.8888889, 25, 10, 18.833333, 0, 10, 33.333333, 16.666667, 10, 2, 20, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 2, 2, 10, 13.333333, 22.75, 10, 37, 33.333333, 10, 8.3333333, 16.666667, 10, 20.857143, 29.2, 10, 18.444444, 36.25, 10, 65.666667, 49.333333, 10, 52.5, 51.666667, 10, 39.142857, 71.2, 10, 37.666667, 84), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x12$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[2, ], c(0.1067614, 0.028335233, 0.15675994, 0.029094411), tolerance = 1e-07, label = paste0("c(", paste0(x12$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[3, ], c(NaN, NaN, 0.69132205, 0.60200615), tolerance = 1e-07, label = paste0("c(", paste0(x12$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x12), NA)))
- expect_output(print(x12)$show())
- invisible(capture.output(expect_error(summary(x12), NA)))
- expect_output(summary(x12)$show())
- x12CodeBased <- eval(parse(text = getObjectRCode(x12, stringWrapParagraphWidth = NULL)))
- expect_equal(x12CodeBased$iterations, x12$iterations, tolerance = 1e-07)
- expect_equal(x12CodeBased$rejectAtLeastOne, x12$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x12CodeBased$rejectedArmsPerStage, x12$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$futilityStop, x12$futilityStop, tolerance = 1e-07)
- expect_equal(x12CodeBased$futilityPerStage, x12$futilityPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$earlyStop, x12$earlyStop, tolerance = 1e-07)
- expect_equal(x12CodeBased$successPerStage, x12$successPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$selectedArms, x12$selectedArms, tolerance = 1e-07)
- expect_equal(x12CodeBased$numberOfActiveArms, x12$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x12CodeBased$expectedNumberOfSubjects, x12$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x12CodeBased$sampleSizes, x12$sampleSizes, tolerance = 1e-07)
- expect_equal(x12CodeBased$conditionalPowerAchieved, x12$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x12), "character")
- df <- as.data.frame(x12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x13 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "userDefined", activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, adaptations = rep(TRUE, 2),
- effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4), intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x13' with expected results
- expect_equal(x13$iterations[1, ], c(10, 10), label = paste0("c(", paste0(x13$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x13$iterations[2, ], c(6, 5), label = paste0("c(", paste0(x13$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x13$iterations[3, ], c(6, 3), label = paste0("c(", paste0(x13$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x13$rejectAtLeastOne, c(0.2, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x13$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x13$futilityStop, c(0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x13$futilityStop, collapse = ", "), ")"))
- expect_equal(x13$futilityPerStage[1, ], c(0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x13$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x13$futilityPerStage[2, ], c(0, 0), label = paste0("c(", paste0(x13$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x13$earlyStop[1, ], c(0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x13$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x13$earlyStop[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x13$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x13$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x13$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[3, ], c(0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x13$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0.5, 0.5, 1, 0.4, 0.2, 1, 0.6, 0.6, 1, 0.5, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$selectedArms)), collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[1, ], c(4, 4), label = paste0("c(", paste0(x13$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[2, ], c(1, 1), label = paste0("c(", paste0(x13$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[3, ], c(1, 1), label = paste0("c(", paste0(x13$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x13$expectedNumberOfSubjects, c(203, 169.6), tolerance = 1e-07, label = paste0("c(", paste0(x13$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 9.8333333, 16.666667, 10, 11.8, 10.666667, 10, 0, 0, 10, 0, 0, 10, 34.5, 66.5, 10, 63.6, 63, 10, 44.333333, 83.166667, 10, 75.4, 73.666667), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(x13$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[2, ], c(0.045209815, 0.0014148507), tolerance = 1e-07, label = paste0("c(", paste0(x13$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[3, ], c(0.60681086, 0.72002567), tolerance = 1e-07, label = paste0("c(", paste0(x13$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x13), NA)))
- expect_output(print(x13)$show())
- invisible(capture.output(expect_error(summary(x13), NA)))
- expect_output(summary(x13)$show())
- x13CodeBased <- eval(parse(text = getObjectRCode(x13, stringWrapParagraphWidth = NULL)))
- expect_equal(x13CodeBased$iterations, x13$iterations, tolerance = 1e-07)
- expect_equal(x13CodeBased$rejectAtLeastOne, x13$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x13CodeBased$rejectedArmsPerStage, x13$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$futilityStop, x13$futilityStop, tolerance = 1e-07)
- expect_equal(x13CodeBased$futilityPerStage, x13$futilityPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$earlyStop, x13$earlyStop, tolerance = 1e-07)
- expect_equal(x13CodeBased$successPerStage, x13$successPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$selectedArms, x13$selectedArms, tolerance = 1e-07)
- expect_equal(x13CodeBased$numberOfActiveArms, x13$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x13CodeBased$expectedNumberOfSubjects, x13$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x13CodeBased$sampleSizes, x13$sampleSizes, tolerance = 1e-07)
- expect_equal(x13CodeBased$conditionalPowerAchieved, x13$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x13), "character")
- df <- as.data.frame(x13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x14 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x14' with expected results
- expect_equal(x14$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x14$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x14$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x14$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x14$iterations[3, ], c(5, 6, 9, 9), label = paste0("c(", paste0(x14$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x14$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x14$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x14$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x14$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityStop, collapse = ", "), ")"))
- expect_equal(x14$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x14$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x14$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x14$earlyStop[2, ], c(0.5, 0.4, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x14$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[2, ], c(0.5, 0.4, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x14$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[3, ], c(0.5, 0.5, 0.4, 0), tolerance = 1e-07, label = paste0("c(", paste0(x14$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$selectedArms)), c(1, 0.1, 0, 1, 0.1, 0, 1, 0.2, 0, 1, 0.1, 0.1, 1, 0.2, 0, 1, 0, 0, 1, 0.2, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0.4, 0.1, 1, 0.2, 0.1, 1, 0.3, 0.3, 1, 0.2, 0, 1, 0.1, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 1, 0.5, 1, 1, 0.6, 1, 1, 0.9, 1, 1, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$selectedArms)), collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x14$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[2, ], c(0.5, 0.6, 0.9, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x14$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[3, ], c(0, 0.16666667, 0.55555556, 1), tolerance = 1e-07, label = paste0("c(", paste0(x14$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x14$expectedNumberOfSubjects, c(148.2, 171.2, 271.2, 368.4), tolerance = 1e-07, label = paste0("c(", paste0(x14$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$sampleSizes)), c(10, 10, 0, 10, 5.3, 0, 10, 15.3, 0, 10, 5.3, 11.111111, 10, 20, 0, 10, 0, 0, 10, 8, 11.111111, 10, 2.7, 11.111111, 10, 0, 0, 10, 35.3, 16.666667, 10, 7.3, 11.111111, 10, 25.3, 33.333333, 10, 19.1, 0, 10, 10, 0, 10, 30, 33.333333, 10, 35.9, 44.444444, 10, 49.1, 0, 10, 50.6, 16.666667, 10, 60.6, 55.555556, 10, 69.2, 100), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x14$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[2, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x14$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, 0.13543053), tolerance = 1e-07, label = paste0("c(", paste0(x14$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x14), NA)))
- expect_output(print(x14)$show())
- invisible(capture.output(expect_error(summary(x14), NA)))
- expect_output(summary(x14)$show())
- x14CodeBased <- eval(parse(text = getObjectRCode(x14, stringWrapParagraphWidth = NULL)))
- expect_equal(x14CodeBased$iterations, x14$iterations, tolerance = 1e-07)
- expect_equal(x14CodeBased$rejectAtLeastOne, x14$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x14CodeBased$rejectedArmsPerStage, x14$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$futilityStop, x14$futilityStop, tolerance = 1e-07)
- expect_equal(x14CodeBased$futilityPerStage, x14$futilityPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$earlyStop, x14$earlyStop, tolerance = 1e-07)
- expect_equal(x14CodeBased$successPerStage, x14$successPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$selectedArms, x14$selectedArms, tolerance = 1e-07)
- expect_equal(x14CodeBased$numberOfActiveArms, x14$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x14CodeBased$expectedNumberOfSubjects, x14$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x14CodeBased$sampleSizes, x14$sampleSizes, tolerance = 1e-07)
- expect_equal(x14CodeBased$conditionalPowerAchieved, x14$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x14), "character")
- df <- as.data.frame(x14)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x14)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x15 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x15' with expected results
- expect_equal(x15$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x15$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x15$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x15$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x15$iterations[3, ], c(8, 9, 8, 5), label = paste0("c(", paste0(x15$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x15$rejectAtLeastOne, c(0, 0.2, 0.7, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x15$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0.1, 0, 0, 0, 0, 0.2, 0, 0, 0.3, 0, 0, 0.4, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.4, 0.3, 0, 0.6, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x15$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityStop, collapse = ", "), ")"))
- expect_equal(x15$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x15$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x15$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x15$earlyStop[2, ], c(0.2, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x15$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[2, ], c(0.2, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x15$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[3, ], c(0.4, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x15$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$selectedArms)), c(1, 0.7, 0.2, 1, 0.5, 0.2, 1, 0.7, 0.5, 1, 0.2, 0.2, 1, 0.5, 0.3, 1, 0.5, 0.4, 1, 0.3, 0.3, 1, 0.7, 0.4, 1, 0.6, 0.1, 1, 0.5, 0.4, 1, 0.7, 0.6, 1, 0.8, 0.4, 1, 0.4, 0.4, 1, 0.8, 0.8, 1, 0.8, 0.6, 1, 0.7, 0.5, 1, 1, 0.8, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$selectedArms)), collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x15$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[2, ], c(2.2, 2.3, 2.5, 2.4), tolerance = 1e-07, label = paste0("c(", paste0(x15$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[3, ], c(1.25, 2, 2.5, 3), tolerance = 1e-07, label = paste0("c(", paste0(x15$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x15$expectedNumberOfSubjects, c(460, 640, 571.4, 381.6), tolerance = 1e-07, label = paste0("c(", paste0(x15$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$sampleSizes)), c(10, 64, 25, 10, 50, 22.222222, 10, 66.8, 38.5, 10, 20, 1.6, 10, 44, 37.5, 10, 50, 44.444444, 10, 27.8, 25.5, 10, 62.8, 14.4, 10, 54, 12.5, 10, 50, 44.444444, 10, 66.8, 48, 10, 72.8, 14.4, 10, 34, 50, 10, 80, 88.888889, 10, 76.8, 48, 10, 62.8, 15.2, 10, 74, 50, 10, 90, 100, 10, 96.8, 73, 10, 82.8, 15.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x15$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[2, ], c(NaN, NaN, 0.10369686, NaN), tolerance = 1e-07, label = paste0("c(", paste0(x15$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[3, ], c(NaN, 0.15953762, 0.43788092, 0.96046919), tolerance = 1e-07, label = paste0("c(", paste0(x15$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x15), NA)))
- expect_output(print(x15)$show())
- invisible(capture.output(expect_error(summary(x15), NA)))
- expect_output(summary(x15)$show())
- x15CodeBased <- eval(parse(text = getObjectRCode(x15, stringWrapParagraphWidth = NULL)))
- expect_equal(x15CodeBased$iterations, x15$iterations, tolerance = 1e-07)
- expect_equal(x15CodeBased$rejectAtLeastOne, x15$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x15CodeBased$rejectedArmsPerStage, x15$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$futilityStop, x15$futilityStop, tolerance = 1e-07)
- expect_equal(x15CodeBased$futilityPerStage, x15$futilityPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$earlyStop, x15$earlyStop, tolerance = 1e-07)
- expect_equal(x15CodeBased$successPerStage, x15$successPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$selectedArms, x15$selectedArms, tolerance = 1e-07)
- expect_equal(x15CodeBased$numberOfActiveArms, x15$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x15CodeBased$expectedNumberOfSubjects, x15$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x15CodeBased$sampleSizes, x15$sampleSizes, tolerance = 1e-07)
- expect_equal(x15CodeBased$conditionalPowerAchieved, x15$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x15), "character")
- df <- as.data.frame(x15)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x15)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x16 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x16' with expected results
- expect_equal(x16$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x16$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x16$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x16$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x16$iterations[3, ], c(9, 9, 10, 8), label = paste0("c(", paste0(x16$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x16$rejectAtLeastOne, c(0, 0.2, 0.6, 1), tolerance = 1e-07, label = paste0("c(", paste0(x16$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0.2, 0, 0.2, 0.4, 0, 0, 0, 0, 0.1, 0.1, 0, 0.1, 0.1, 0, 0.7, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x16$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityStop, collapse = ", "), ")"))
- expect_equal(x16$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x16$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x16$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x16$earlyStop[2, ], c(0.1, 0.1, 0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x16$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[2, ], c(0.1, 0.1, 0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x16$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[3, ], c(0.2, 0.1, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x16$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$selectedArms)), c(1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.6, 0.4, 1, 0.5, 0.5, 1, 0.2, 0.2, 1, 0.2, 0.1, 1, 0.4, 0.2, 1, 0.2, 0.2, 1, 0.6, 0.6, 1, 0.8, 0.6, 1, 0.4, 0.3, 1, 0.8, 0.8, 1, 0.8, 0.8, 1, 0.9, 0.8, 1, 1, 0.9, 1, 1, 0.9, 1, 1, 1, 1, 1, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$selectedArms)), collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x16$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[2, ], c(1.7, 1.7, 1.9, 2), tolerance = 1e-07, label = paste0("c(", paste0(x16$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[3, ], c(1.3333333, 1.8888889, 1.9, 2), tolerance = 1e-07, label = paste0("c(", paste0(x16$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x16$expectedNumberOfSubjects, c(465.5, 426.3, 413.1, 244.1), tolerance = 1e-07, label = paste0("c(", paste0(x16$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$sampleSizes)), c(10, 18.5, 33.333333, 10, 5.9, 22.222222, 10, 30, 1.2, 10, 2.2, 0.5, 10, 60, 44.444444, 10, 37.9, 55.555556, 10, 4.9, 13.9, 10, 14.1, 5, 10, 31.6, 22.222222, 10, 10.6, 1.5555556, 10, 44.7, 33.8, 10, 36.6, 21.75, 10, 36.9, 33.333333, 10, 57, 68.222222, 10, 49.6, 57.3, 10, 32.9, 27.25, 10, 78.5, 77.777778, 10, 60.7, 79.333333, 10, 69.6, 58.1, 10, 42.9, 27.25), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x16$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[2, ], c(NaN, NaN, 0.11243241, 0.1746525), tolerance = 1e-07, label = paste0("c(", paste0(x16$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[3, ], c(NaN, 0.41153932, 0.67843506, 0.87119979), tolerance = 1e-07, label = paste0("c(", paste0(x16$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x16), NA)))
- expect_output(print(x16)$show())
- invisible(capture.output(expect_error(summary(x16), NA)))
- expect_output(summary(x16)$show())
- x16CodeBased <- eval(parse(text = getObjectRCode(x16, stringWrapParagraphWidth = NULL)))
- expect_equal(x16CodeBased$iterations, x16$iterations, tolerance = 1e-07)
- expect_equal(x16CodeBased$rejectAtLeastOne, x16$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x16CodeBased$rejectedArmsPerStage, x16$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$futilityStop, x16$futilityStop, tolerance = 1e-07)
- expect_equal(x16CodeBased$futilityPerStage, x16$futilityPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$earlyStop, x16$earlyStop, tolerance = 1e-07)
- expect_equal(x16CodeBased$successPerStage, x16$successPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$selectedArms, x16$selectedArms, tolerance = 1e-07)
- expect_equal(x16CodeBased$numberOfActiveArms, x16$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x16CodeBased$expectedNumberOfSubjects, x16$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x16CodeBased$sampleSizes, x16$sampleSizes, tolerance = 1e-07)
- expect_equal(x16CodeBased$conditionalPowerAchieved, x16$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x16), "character")
- df <- as.data.frame(x16)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x16)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x17 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = rep(TRUE, 2), intersectionTest = "Simes",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x17' with expected results
- expect_equal(x17$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x17$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x17$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x17$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x17$iterations[3, ], c(9, 8, 6, 5), label = paste0("c(", paste0(x17$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x17$rejectAtLeastOne, c(0, 0.3, 0.4, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x17$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0.1, 0.4, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.3, 0, 0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x17$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityStop, collapse = ", "), ")"))
- expect_equal(x17$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x17$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x17$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x17$earlyStop[2, ], c(0.1, 0.2, 0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x17$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[2, ], c(0.1, 0.2, 0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x17$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[3, ], c(0.2, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x17$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$selectedArms)), c(1, 0.3, 0.1, 1, 0.2, 0.1, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.6, 0.4, 1, 0.3, 0.1, 1, 0.3, 0.1, 1, 0.3, 0.2, 1, 0.4, 0.4, 1, 0.4, 0.2, 1, 0.7, 0.3, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.7, 0.5, 1, 0.6, 0.2, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.6, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$selectedArms)), collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x17$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[2, ], c(1.2, 1.3, 1.5, 1.7), tolerance = 1e-07, label = paste0("c(", paste0(x17$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[3, ], c(0.88888889, 1.25, 1.3333333, 1.4), tolerance = 1e-07, label = paste0("c(", paste0(x17$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x17$expectedNumberOfSubjects, c(339.9, 359.2, 222.7, 176), tolerance = 1e-07, label = paste0("c(", paste0(x17$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$sampleSizes)), c(10, 28.2, 11.111111, 10, 15.9, 8.125, 10, 10, 0, 10, 1.2, 7.4, 10, 19.1, 11.111111, 10, 32.3, 50, 10, 20.5, 16.666667, 10, 13.6, 7.4, 10, 22.2, 16.444444, 10, 29.9, 50, 10, 25.2, 17.333333, 10, 26.2, 9.8, 10, 20.2, 44.444444, 10, 4.6, 12.5, 10, 26.4, 19.833333, 10, 21.2, 12.2, 10, 60.6, 72, 10, 53.5, 95.625, 10, 36.4, 36.5, 10, 34.4, 22), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x17$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[2, ], c(NaN, NaN, NaN, 0.14296603), tolerance = 1e-07, label = paste0("c(", paste0(x17$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[3, ], c(NaN, 0.40839298, 0.6012117, 0.84313531), tolerance = 1e-07, label = paste0("c(", paste0(x17$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x17), NA)))
- expect_output(print(x17)$show())
- invisible(capture.output(expect_error(summary(x17), NA)))
- expect_output(summary(x17)$show())
- x17CodeBased <- eval(parse(text = getObjectRCode(x17, stringWrapParagraphWidth = NULL)))
- expect_equal(x17CodeBased$iterations, x17$iterations, tolerance = 1e-07)
- expect_equal(x17CodeBased$rejectAtLeastOne, x17$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x17CodeBased$rejectedArmsPerStage, x17$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$futilityStop, x17$futilityStop, tolerance = 1e-07)
- expect_equal(x17CodeBased$futilityPerStage, x17$futilityPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$earlyStop, x17$earlyStop, tolerance = 1e-07)
- expect_equal(x17CodeBased$successPerStage, x17$successPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$selectedArms, x17$selectedArms, tolerance = 1e-07)
- expect_equal(x17CodeBased$numberOfActiveArms, x17$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x17CodeBased$expectedNumberOfSubjects, x17$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x17CodeBased$sampleSizes, x17$sampleSizes, tolerance = 1e-07)
- expect_equal(x17CodeBased$conditionalPowerAchieved, x17$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x17), "character")
- df <- as.data.frame(x17)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x17)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x18 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Simes",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x18' with expected results
- expect_equal(x18$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x18$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x18$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x18$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x18$iterations[3, ], c(7, 8, 7, 5), label = paste0("c(", paste0(x18$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x18$rejectAtLeastOne, c(0.1, 0.1, 0.3, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x18$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$rejectedArmsPerStage)), c(0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.2, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x18$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityStop, collapse = ", "), ")"))
- expect_equal(x18$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x18$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x18$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x18$earlyStop[2, ], c(0.3, 0.2, 0.3, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x18$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[2, ], c(0.3, 0.2, 0.3, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x18$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[3, ], c(0.1, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x18$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$selectedArms)), c(1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.2, 0.1, 1, 0.3, 0.2, 1, 1, 0.7, 1, 1, 0.8, 1, 1, 0.7, 1, 1, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$selectedArms)), collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x18$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[2, ], c(0.7, 0.8, 0.8, 1), tolerance = 1e-07, label = paste0("c(", paste0(x18$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x18$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x18$expectedNumberOfSubjects, c(241.6, 306.8, 235.2, 156), tolerance = 1e-07, label = paste0("c(", paste0(x18$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$sampleSizes)), c(10, 19.1, 27.285714, 10, 20, 25, 10, 0, 0, 10, 2.6, 4.4, 10, 11.3, 16.142857, 10, 12.8, 16, 10, 2.8, 4, 10, 1.4, 2.8, 10, 10, 14.285714, 10, 10, 12.5, 10, 32.7, 46.571429, 10, 15.8, 5.2, 10, 7.5, 10.714286, 10, 21.4, 26.75, 10, 15.9, 8.2857143, 10, 18.6, 16.8, 10, 47.9, 68.428571, 10, 64.2, 80.25, 10, 51.4, 58.857143, 10, 38.4, 29.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x18$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[2, ], c(NaN, NaN, NaN, 0.13824332), tolerance = 1e-07, label = paste0("c(", paste0(x18$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[3, ], c(0.066989319, 0.23112098, 0.45267281, 0.52012057), tolerance = 1e-07, label = paste0("c(", paste0(x18$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x18), NA)))
- expect_output(print(x18)$show())
- invisible(capture.output(expect_error(summary(x18), NA)))
- expect_output(summary(x18)$show())
- x18CodeBased <- eval(parse(text = getObjectRCode(x18, stringWrapParagraphWidth = NULL)))
- expect_equal(x18CodeBased$iterations, x18$iterations, tolerance = 1e-07)
- expect_equal(x18CodeBased$rejectAtLeastOne, x18$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x18CodeBased$rejectedArmsPerStage, x18$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$futilityStop, x18$futilityStop, tolerance = 1e-07)
- expect_equal(x18CodeBased$futilityPerStage, x18$futilityPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$earlyStop, x18$earlyStop, tolerance = 1e-07)
- expect_equal(x18CodeBased$successPerStage, x18$successPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$selectedArms, x18$selectedArms, tolerance = 1e-07)
- expect_equal(x18CodeBased$numberOfActiveArms, x18$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x18CodeBased$expectedNumberOfSubjects, x18$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x18CodeBased$sampleSizes, x18$sampleSizes, tolerance = 1e-07)
- expect_equal(x18CodeBased$conditionalPowerAchieved, x18$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x18), "character")
- df <- as.data.frame(x18)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x18)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x19 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "all",
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Simes",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x19' with expected results
- expect_equal(x19$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x19$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x19$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x19$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x19$iterations[3, ], c(8, 8, 9, 9), label = paste0("c(", paste0(x19$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x19$rejectAtLeastOne, c(0, 0, 0.9, 1), tolerance = 1e-07, label = paste0("c(", paste0(x19$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0, 0.4, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.1, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.8, 0.1, 0, 0.7, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x19$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x19$futilityStop, collapse = ", "), ")"))
- expect_equal(x19$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x19$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x19$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x19$earlyStop[2, ], c(0.2, 0.2, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x19$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[2, ], c(0.2, 0.2, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x19$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[3, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x19$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.8, 0.8, 1, 0.6, 0.6, 1, 0.5, 0.5, 1, 0.6, 0.6, 1, 0.7, 0.6, 1, 0.9, 0.8, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.9, 0.8, 1, 0.8, 0.7, 1, 0.6, 0.6, 1, 0.5, 0.5, 1, 0.9, 0.8, 1, 0.8, 0.7, 1, 1, 0.8, 1, 1, 0.8, 1, 1, 0.9, 1, 1, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$selectedArms)), collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x19$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[2, ], c(1.9, 1.9, 3.3, 3.1), tolerance = 1e-07, label = paste0("c(", paste0(x19$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[3, ], c(2.375, 2.375, 3.3333333, 3.1111111), tolerance = 1e-07, label = paste0("c(", paste0(x19$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x19$expectedNumberOfSubjects, c(523.8, 590, 818.4, 765.4), tolerance = 1e-07, label = paste0("c(", paste0(x19$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$sampleSizes)), c(10, 22.5, 28.125, 10, 30, 37.5, 10, 73.6, 81.666667, 10, 55.2, 61.333333, 10, 46.9, 58.625, 10, 60, 75, 10, 70, 66.666667, 10, 85.2, 83.555556, 10, 42.5, 53.125, 10, 50, 62.5, 10, 83.6, 81.666667, 10, 71.1, 67.777778, 10, 52.5, 65.625, 10, 50, 62.5, 10, 83.6, 81.666667, 10, 75.2, 72.444444, 10, 72.5, 90.625, 10, 80, 100, 10, 93.6, 92.777778, 10, 91.1, 90), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x19$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[2, ], c(NaN, NaN, 0.18629752, 0.24626925), tolerance = 1e-07, label = paste0("c(", paste0(x19$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[3, ], c(0.088506618, 0.13049081, 0.60815392, 0.85577973), tolerance = 1e-07, label = paste0("c(", paste0(x19$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x19), NA)))
- expect_output(print(x19)$show())
- invisible(capture.output(expect_error(summary(x19), NA)))
- expect_output(summary(x19)$show())
- x19CodeBased <- eval(parse(text = getObjectRCode(x19, stringWrapParagraphWidth = NULL)))
- expect_equal(x19CodeBased$iterations, x19$iterations, tolerance = 1e-07)
- expect_equal(x19CodeBased$rejectAtLeastOne, x19$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x19CodeBased$rejectedArmsPerStage, x19$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$futilityStop, x19$futilityStop, tolerance = 1e-07)
- expect_equal(x19CodeBased$futilityPerStage, x19$futilityPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$earlyStop, x19$earlyStop, tolerance = 1e-07)
- expect_equal(x19CodeBased$successPerStage, x19$successPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$selectedArms, x19$selectedArms, tolerance = 1e-07)
- expect_equal(x19CodeBased$numberOfActiveArms, x19$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x19CodeBased$expectedNumberOfSubjects, x19$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x19CodeBased$sampleSizes, x19$sampleSizes, tolerance = 1e-07)
- expect_equal(x19CodeBased$conditionalPowerAchieved, x19$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x19), "character")
- df <- as.data.frame(x19)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x19)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x20 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "rBest", rValue = 2,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x20' with expected results
- expect_equal(x20$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x20$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x20$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x20$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x20$iterations[3, ], c(2, 5, 3, 1), label = paste0("c(", paste0(x20$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x20$rejectAtLeastOne, c(0, 0, 0.2, 0), tolerance = 1e-07, label = paste0("c(", paste0(x20$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x20$futilityStop, c(0.5, 0.2, 0.5, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x20$futilityStop, collapse = ", "), ")"))
- expect_equal(x20$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x20$futilityPerStage[2, ], c(0.5, 0.2, 0.5, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x20$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x20$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x20$earlyStop[2, ], c(0.8, 0.5, 0.7, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x20$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[2, ], c(0.3, 0.3, 0.2, 0), tolerance = 1e-07, label = paste0("c(", paste0(x20$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$selectedArms)), c(1, 0.2, 0.2, 1, 0.5, 0.5, 1, 0.4, 0.3, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.2, 0, 1, 0.1, 0, 1, 0.4, 0, 1, 0.2, 0, 1, 0.3, 0.3, 1, 0.5, 0.1, 1, 0.8, 0, 1, 0.5, 0.1, 1, 0.4, 0.2, 1, 0.6, 0.2, 1, 0.7, 0.1, 1, 1, 0.2, 1, 1, 0.5, 1, 1, 0.3, 1, 1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$selectedArms)), collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x20$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[2, ], c(1.2, 1.4, 1.6, 2), tolerance = 1e-07, label = paste0("c(", paste0(x20$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x20$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x20$expectedNumberOfSubjects, c(267.3, 301.1, 325.2, 315.5), tolerance = 1e-07, label = paste0("c(", paste0(x20$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$sampleSizes)), c(10, 16.9, 84.5, 10, 36.2, 72.2, 10, 35.1, 83.333333, 10, 8.8, 88, 10, 25.3, 50, 10, 11.4, 0, 10, 3.7, 0, 10, 28.2, 0, 10, 20, 0, 10, 21.1, 42.2, 10, 38.3, 33.333333, 10, 60.9, 0, 10, 42.2, 34.5, 10, 26.5, 30, 10, 49.7, 50, 10, 61.5, 88, 10, 62.2, 84.5, 10, 47.6, 72.2, 10, 73.4, 83.333333, 10, 79.7, 88), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x20$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[2, ], c(NaN, NaN, NaN, 0.1268121), tolerance = 1e-07, label = paste0("c(", paste0(x20$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[3, ], c(0.021357961, 0.35341345, 0.67128636, 1), tolerance = 1e-07, label = paste0("c(", paste0(x20$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x20), NA)))
- expect_output(print(x20)$show())
- invisible(capture.output(expect_error(summary(x20), NA)))
- expect_output(summary(x20)$show())
- x20CodeBased <- eval(parse(text = getObjectRCode(x20, stringWrapParagraphWidth = NULL)))
- expect_equal(x20CodeBased$iterations, x20$iterations, tolerance = 1e-07)
- expect_equal(x20CodeBased$rejectAtLeastOne, x20$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x20CodeBased$rejectedArmsPerStage, x20$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$futilityStop, x20$futilityStop, tolerance = 1e-07)
- expect_equal(x20CodeBased$futilityPerStage, x20$futilityPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$earlyStop, x20$earlyStop, tolerance = 1e-07)
- expect_equal(x20CodeBased$successPerStage, x20$successPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$selectedArms, x20$selectedArms, tolerance = 1e-07)
- expect_equal(x20CodeBased$numberOfActiveArms, x20$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x20CodeBased$expectedNumberOfSubjects, x20$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x20CodeBased$sampleSizes, x20$sampleSizes, tolerance = 1e-07)
- expect_equal(x20CodeBased$conditionalPowerAchieved, x20$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x20), "character")
- df <- as.data.frame(x20)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x20)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x21 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
- adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x21' with expected results
- expect_equal(x21$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x21$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x21$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x21$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x21$iterations[3, ], c(2, 4, 4, 2), label = paste0("c(", paste0(x21$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x21$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x21$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x21$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x21$futilityStop, c(0.7, 0.5, 0.5, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x21$futilityStop, collapse = ", "), ")"))
- expect_equal(x21$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x21$futilityPerStage[2, ], c(0.7, 0.5, 0.5, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x21$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x21$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x21$earlyStop[2, ], c(0.8, 0.6, 0.6, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(x21$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[2, ], c(0.1, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x21$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$selectedArms)), c(1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.2, 0, 1, 0.2, 0.1, 1, 0.3, 0.1, 1, 0.4, 0.1, 1, 0.5, 0.1, 1, 0.5, 0.2, 1, 0.2, 0.2, 1, 0.7, 0.1, 1, 0.4, 0, 1, 0.2, 0, 1, 0.7, 0.3, 1, 0.9, 0.2, 1, 1, 0.2, 1, 1, 0.4, 1, 1, 0.4, 1, 1, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$selectedArms)), collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x21$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[2, ], c(1.3, 1.3, 1.6, 2.2), tolerance = 1e-07, label = paste0("c(", paste0(x21$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[3, ], c(1.5, 1.75, 2.5, 3), tolerance = 1e-07, label = paste0("c(", paste0(x21$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x21$expectedNumberOfSubjects, c(240.6, 332.2, 346.2, 256.5), tolerance = 1e-07, label = paste0("c(", paste0(x21$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$sampleSizes)), c(10, 15.9, 79, 10, 35.3, 88.25, 10, 32.2, 80.25, 10, 7.9, 39, 10, 12.2, 0, 10, 20, 25, 10, 22.2, 5.25, 10, 17.7, 25, 10, 38.1, 50, 10, 42.8, 50, 10, 20, 50, 10, 44.9, 25, 10, 24.4, 0, 10, 12.7, 0, 10, 46.7, 55.25, 10, 50.7, 39, 10, 58.4, 79, 10, 70.8, 88.25, 10, 66.7, 80.25, 10, 51.9, 39), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x21$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[2, ], c(NaN, NaN, NaN, 0.14413714), tolerance = 1e-07, label = paste0("c(", paste0(x21$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[3, ], c(0.29927137, 0.0060466075, 0.55383829, 0.59417789), tolerance = 1e-07, label = paste0("c(", paste0(x21$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x21), NA)))
- expect_output(print(x21)$show())
- invisible(capture.output(expect_error(summary(x21), NA)))
- expect_output(summary(x21)$show())
- x21CodeBased <- eval(parse(text = getObjectRCode(x21, stringWrapParagraphWidth = NULL)))
- expect_equal(x21CodeBased$iterations, x21$iterations, tolerance = 1e-07)
- expect_equal(x21CodeBased$rejectAtLeastOne, x21$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x21CodeBased$rejectedArmsPerStage, x21$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$futilityStop, x21$futilityStop, tolerance = 1e-07)
- expect_equal(x21CodeBased$futilityPerStage, x21$futilityPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$earlyStop, x21$earlyStop, tolerance = 1e-07)
- expect_equal(x21CodeBased$successPerStage, x21$successPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$selectedArms, x21$selectedArms, tolerance = 1e-07)
- expect_equal(x21CodeBased$numberOfActiveArms, x21$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x21CodeBased$expectedNumberOfSubjects, x21$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x21CodeBased$sampleSizes, x21$sampleSizes, tolerance = 1e-07)
- expect_equal(x21CodeBased$conditionalPowerAchieved, x21$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x21), "character")
- df <- as.data.frame(x21)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x21)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x22 <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, threshold = 0.1, plannedSubjects = c(10, 30, 50), piControl = 0.3,
- piMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Hierarchical",
- conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4),
- maxNumberOfSubjectsPerStage = c(10, 100, 100), directionUpper = FALSE,
- maxNumberOfIterations = 1
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x22' with expected results
- expect_equal(x22$iterations[1, ], c(1, 1, 1), label = paste0("c(", paste0(x22$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x22$iterations[2, ], c(1, 1, 1), label = paste0("c(", paste0(x22$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x22$iterations[3, ], c(0, 0, 0), label = paste0("c(", paste0(x22$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x22$rejectAtLeastOne, c(0, 0, 0), label = paste0("c(", paste0(x22$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x22$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x22$futilityStop, c(0, 1, 0), label = paste0("c(", paste0(x22$futilityStop, collapse = ", "), ")"))
- expect_equal(x22$futilityPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x22$futilityPerStage[2, ], c(0, 1, 0), label = paste0("c(", paste0(x22$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x22$earlyStop[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x22$earlyStop[2, ], c(1, 1, 1), label = paste0("c(", paste0(x22$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[2, ], c(1, 0, 1), label = paste0("c(", paste0(x22$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[3, ], c(0, 0, 0), label = paste0("c(", paste0(x22$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0), label = paste0("c(", paste0(unlist(as.list(x22$selectedArms)), collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0("c(", paste0(x22$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[2, ], c(0, 1, 0), label = paste0("c(", paste0(x22$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[3, ], c(NaN, NaN, NaN), label = paste0("c(", paste0(x22$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x22$expectedNumberOfSubjects, c(NaN, NaN, NaN), label = paste0("c(", paste0(x22$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 0, NaN, 10, 0, 0, 10, 0, 0, 10, 0, NaN, 10, 0, 0, 10, 91, 0, 10, 0, NaN, 10, 0, 0, 10, 0, 0, 10, 0, NaN, 10, 0, 0, 10, 91, 0, 10, 0, NaN), label = paste0("c(", paste0(unlist(as.list(x22$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x22$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[2, ], c(NaN, 3.7427402e-05, NaN), tolerance = 1e-07, label = paste0("c(", paste0(x22$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN), label = paste0("c(", paste0(x22$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x22), NA)))
- expect_output(print(x22)$show())
- invisible(capture.output(expect_error(summary(x22), NA)))
- expect_output(summary(x22)$show())
- x22CodeBased <- eval(parse(text = getObjectRCode(x22, stringWrapParagraphWidth = NULL)))
- expect_equal(x22CodeBased$iterations, x22$iterations, tolerance = 1e-07)
- expect_equal(x22CodeBased$rejectAtLeastOne, x22$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x22CodeBased$rejectedArmsPerStage, x22$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$futilityStop, x22$futilityStop, tolerance = 1e-07)
- expect_equal(x22CodeBased$futilityPerStage, x22$futilityPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$earlyStop, x22$earlyStop, tolerance = 1e-07)
- expect_equal(x22CodeBased$successPerStage, x22$successPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$selectedArms, x22$selectedArms, tolerance = 1e-07)
- expect_equal(x22CodeBased$numberOfActiveArms, x22$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x22CodeBased$expectedNumberOfSubjects, x22$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(x22CodeBased$sampleSizes, x22$sampleSizes, tolerance = 1e-07)
- expect_equal(x22CodeBased$conditionalPowerAchieved, x22$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x22), "character")
- df <- as.data.frame(x22)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x22)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfNotX64()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetBonferroni}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ # @refFS[Formula]{fs:adjustedPValueSubsetHierarchical}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
+ x1 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x1' with expected results
+ expect_equal(x1$iterations[1, ], c(10, 10, 10, 10), label = paste0(x1$iterations[1, ]))
+ expect_equal(x1$iterations[2, ], c(10, 10, 10, 10), label = paste0(x1$iterations[2, ]))
+ expect_equal(x1$iterations[3, ], c(10, 10, 9, 7), label = paste0(x1$iterations[3, ]))
+ expect_equal(x1$rejectAtLeastOne, c(0, 0.1, 0.6, 0.8), tolerance = 1e-07, label = paste0(x1$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x1$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.2, 0, 0.2, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x1$rejectedArmsPerStage))))
+ expect_equal(x1$futilityStop, c(0, 0, 0, 0), label = paste0(x1$futilityStop))
+ expect_equal(x1$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x1$futilityPerStage[1, ]))
+ expect_equal(x1$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x1$futilityPerStage[2, ]))
+ expect_equal(x1$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x1$earlyStop[1, ]))
+ expect_equal(x1$earlyStop[2, ], c(0, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0(x1$earlyStop[2, ]))
+ expect_equal(x1$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x1$successPerStage[1, ]))
+ expect_equal(x1$successPerStage[2, ], c(0, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0(x1$successPerStage[2, ]))
+ expect_equal(x1$successPerStage[3, ], c(0, 0.1, 0.5, 0.5), tolerance = 1e-07, label = paste0(x1$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x1$selectedArms)), c(1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0, 0, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.3, 0.2, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.4, 0.3, 1, 0.5, 0.3, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.7), tolerance = 1e-07, label = paste0(unlist(as.list(x1$selectedArms))))
+ expect_equal(x1$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x1$numberOfActiveArms[1, ]))
+ expect_equal(x1$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x1$numberOfActiveArms[2, ]))
+ expect_equal(x1$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x1$numberOfActiveArms[3, ]))
+ expect_equal(x1$expectedNumberOfSubjects, c(334.8, 445, 331.8, 179.8), tolerance = 1e-07, label = paste0(x1$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x1$sampleSizes)), c(10, 8, 10.4, 10, 10, 10, 10, 11.3, 15.333333, 10, 0, 0, 10, 10, 10, 10, 17.5, 20, 10, 0, 0, 10, 13, 19.142857, 10, 22.4, 22.5, 10, 40, 40, 10, 37.5, 36.555556, 10, 4.4, 8.5714286, 10, 20.4, 38.7, 10, 30, 30, 10, 28.2, 19.111111, 10, 17.1, 15.714286, 10, 60.8, 81.6, 10, 97.5, 100, 10, 77, 71, 10, 34.5, 43.428571), tolerance = 1e-07, label = paste0(unlist(as.list(x1$sampleSizes))))
+ expect_equal(x1$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPowerAchieved[1, ]))
+ expect_equal(x1$conditionalPowerAchieved[2, ], c(0.032197948, 0.00019444487, 0.052129075, 0.12394528), tolerance = 1e-07, label = paste0(x1$conditionalPowerAchieved[2, ]))
+ expect_equal(x1$conditionalPowerAchieved[3, ], c(0.33607045, 0.04525892, 0.4023749, 0.68738904), tolerance = 1e-07, label = paste0(x1$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x1), NA)))
+ expect_output(print(x1)$show())
+ invisible(capture.output(expect_error(summary(x1), NA)))
+ expect_output(summary(x1)$show())
+ x1CodeBased <- eval(parse(text = getObjectRCode(x1, stringWrapParagraphWidth = NULL)))
+ expect_equal(x1CodeBased$iterations, x1$iterations, tolerance = 1e-07)
+ expect_equal(x1CodeBased$rejectAtLeastOne, x1$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x1CodeBased$rejectedArmsPerStage, x1$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$futilityStop, x1$futilityStop, tolerance = 1e-07)
+ expect_equal(x1CodeBased$futilityPerStage, x1$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$earlyStop, x1$earlyStop, tolerance = 1e-07)
+ expect_equal(x1CodeBased$successPerStage, x1$successPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$selectedArms, x1$selectedArms, tolerance = 1e-07)
+ expect_equal(x1CodeBased$numberOfActiveArms, x1$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x1CodeBased$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x1CodeBased$sampleSizes, x1$sampleSizes, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPowerAchieved, x1$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x1), "character")
+ df <- as.data.frame(x1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ .skipTestIfDisabled()
+
+ x2 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "userDefined", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, adaptations = rep(TRUE, 2),
+ effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x2' with expected results
+ expect_equal(x2$iterations[1, ], c(10, 10), label = paste0(x2$iterations[1, ]))
+ expect_equal(x2$iterations[2, ], c(10, 10), label = paste0(x2$iterations[2, ]))
+ expect_equal(x2$iterations[3, ], c(10, 8), label = paste0(x2$iterations[3, ]))
+ expect_equal(x2$rejectAtLeastOne, c(0.2, 0.7), tolerance = 1e-07, label = paste0(x2$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x2$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.2, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x2$rejectedArmsPerStage))))
+ expect_equal(x2$futilityStop, c(0, 0), label = paste0(x2$futilityStop))
+ expect_equal(x2$futilityPerStage[1, ], c(0, 0), label = paste0(x2$futilityPerStage[1, ]))
+ expect_equal(x2$futilityPerStage[2, ], c(0, 0), label = paste0(x2$futilityPerStage[2, ]))
+ expect_equal(x2$earlyStop[1, ], c(0, 0), label = paste0(x2$earlyStop[1, ]))
+ expect_equal(x2$earlyStop[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0(x2$earlyStop[2, ]))
+ expect_equal(x2$successPerStage[1, ], c(0, 0), label = paste0(x2$successPerStage[1, ]))
+ expect_equal(x2$successPerStage[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0(x2$successPerStage[2, ]))
+ expect_equal(x2$successPerStage[3, ], c(0.2, 0.5), tolerance = 1e-07, label = paste0(x2$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x2$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0, 0, 1, 0.5, 0.5, 1, 0.7, 0.5, 1, 1, 1, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x2$selectedArms))))
+ expect_equal(x2$numberOfActiveArms[1, ], c(4, 4), label = paste0(x2$numberOfActiveArms[1, ]))
+ expect_equal(x2$numberOfActiveArms[2, ], c(1, 1), label = paste0(x2$numberOfActiveArms[2, ]))
+ expect_equal(x2$numberOfActiveArms[3, ], c(1, 1), label = paste0(x2$numberOfActiveArms[3, ]))
+ expect_equal(x2$expectedNumberOfSubjects, c(397.2, 312.8), tolerance = 1e-07, label = paste0(x2$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x2$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 30, 30, 10, 22.4, 37.5, 10, 13, 20, 10, 0, 0, 10, 38.8, 41.8, 10, 52.8, 32.75, 10, 81.8, 91.8, 10, 75.2, 70.25), tolerance = 1e-07, label = paste0(unlist(as.list(x2$sampleSizes))))
+ expect_equal(x2$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0(x2$conditionalPowerAchieved[1, ]))
+ expect_equal(x2$conditionalPowerAchieved[2, ], c(0.0097327907, 0.021741893), tolerance = 1e-07, label = paste0(x2$conditionalPowerAchieved[2, ]))
+ expect_equal(x2$conditionalPowerAchieved[3, ], c(0.14656813, 0.35197865), tolerance = 1e-07, label = paste0(x2$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x2), NA)))
+ expect_output(print(x2)$show())
+ invisible(capture.output(expect_error(summary(x2), NA)))
+ expect_output(summary(x2)$show())
+ x2CodeBased <- eval(parse(text = getObjectRCode(x2, stringWrapParagraphWidth = NULL)))
+ expect_equal(x2CodeBased$iterations, x2$iterations, tolerance = 1e-07)
+ expect_equal(x2CodeBased$rejectAtLeastOne, x2$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x2CodeBased$rejectedArmsPerStage, x2$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$futilityStop, x2$futilityStop, tolerance = 1e-07)
+ expect_equal(x2CodeBased$futilityPerStage, x2$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$earlyStop, x2$earlyStop, tolerance = 1e-07)
+ expect_equal(x2CodeBased$successPerStage, x2$successPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$selectedArms, x2$selectedArms, tolerance = 1e-07)
+ expect_equal(x2CodeBased$numberOfActiveArms, x2$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x2CodeBased$expectedNumberOfSubjects, x2$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x2CodeBased$sampleSizes, x2$sampleSizes, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPowerAchieved, x2$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x2), "character")
+ df <- as.data.frame(x2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x3 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x3' with expected results
+ expect_equal(x3$iterations[1, ], c(10, 10, 10, 10), label = paste0(x3$iterations[1, ]))
+ expect_equal(x3$iterations[2, ], c(10, 10, 10, 10), label = paste0(x3$iterations[2, ]))
+ expect_equal(x3$iterations[3, ], c(10, 10, 10, 10), label = paste0(x3$iterations[3, ]))
+ expect_equal(x3$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x3$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x3$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x3$rejectedArmsPerStage))))
+ expect_equal(x3$futilityStop, c(0, 0, 0, 0), label = paste0(x3$futilityStop))
+ expect_equal(x3$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x3$futilityPerStage[1, ]))
+ expect_equal(x3$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x3$futilityPerStage[2, ]))
+ expect_equal(x3$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x3$earlyStop[1, ]))
+ expect_equal(x3$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x3$earlyStop[2, ]))
+ expect_equal(x3$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x3$successPerStage[1, ]))
+ expect_equal(x3$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x3$successPerStage[2, ]))
+ expect_equal(x3$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x3$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x3$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), tolerance = 1e-07, label = paste0(unlist(as.list(x3$selectedArms))))
+ expect_equal(x3$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x3$numberOfActiveArms[1, ]))
+ expect_equal(x3$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x3$numberOfActiveArms[2, ]))
+ expect_equal(x3$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x3$numberOfActiveArms[3, ]))
+ expect_equal(x3$expectedNumberOfSubjects, c(434.8, 402, 440, 425), tolerance = 1e-07, label = paste0(x3$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x3$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 15, 20, 10, 10, 10, 10, 30, 30, 10, 12.7, 20, 10, 40, 40, 10, 20, 20, 10, 30, 30, 10, 29.1, 34.2, 10, 30, 30, 10, 33.4, 40, 10, 32.4, 40, 10, 40, 40, 10, 10, 10, 10, 26.7, 27.4, 10, 92.4, 100, 10, 81.8, 94.2, 10, 95, 100, 10, 90.1, 97.4), tolerance = 1e-07, label = paste0(unlist(as.list(x3$sampleSizes))))
+ expect_equal(x3$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPowerAchieved[1, ]))
+ expect_equal(x3$conditionalPowerAchieved[2, ], c(0.0098526063, 0.0022619481, 0.010226943, 0.0071111057), tolerance = 1e-07, label = paste0(x3$conditionalPowerAchieved[2, ]))
+ expect_equal(x3$conditionalPowerAchieved[3, ], c(0.00025317548, 0.089328639, 4.5501958e-05, 0.12015791), tolerance = 1e-07, label = paste0(x3$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x3), NA)))
+ expect_output(print(x3)$show())
+ invisible(capture.output(expect_error(summary(x3), NA)))
+ expect_output(summary(x3)$show())
+ x3CodeBased <- eval(parse(text = getObjectRCode(x3, stringWrapParagraphWidth = NULL)))
+ expect_equal(x3CodeBased$iterations, x3$iterations, tolerance = 1e-07)
+ expect_equal(x3CodeBased$rejectAtLeastOne, x3$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x3CodeBased$rejectedArmsPerStage, x3$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$futilityStop, x3$futilityStop, tolerance = 1e-07)
+ expect_equal(x3CodeBased$futilityPerStage, x3$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$earlyStop, x3$earlyStop, tolerance = 1e-07)
+ expect_equal(x3CodeBased$successPerStage, x3$successPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$selectedArms, x3$selectedArms, tolerance = 1e-07)
+ expect_equal(x3CodeBased$numberOfActiveArms, x3$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x3CodeBased$expectedNumberOfSubjects, x3$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x3CodeBased$sampleSizes, x3$sampleSizes, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPowerAchieved, x3$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x3), "character")
+ df <- as.data.frame(x3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x4 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x4' with expected results
+ expect_equal(x4$iterations[1, ], c(10, 10, 10, 10), label = paste0(x4$iterations[1, ]))
+ expect_equal(x4$iterations[2, ], c(10, 10, 10, 10), label = paste0(x4$iterations[2, ]))
+ expect_equal(x4$iterations[3, ], c(10, 10, 10, 10), label = paste0(x4$iterations[3, ]))
+ expect_equal(x4$rejectAtLeastOne, c(0, 0.3, 0.7, 1), tolerance = 1e-07, label = paste0(x4$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x4$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3, 0, 0.3, 0.4, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0.2, 0, 0.4, 0.3, 0, 0.8, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x4$rejectedArmsPerStage))))
+ expect_equal(x4$futilityStop, c(0, 0, 0, 0), label = paste0(x4$futilityStop))
+ expect_equal(x4$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x4$futilityPerStage[1, ]))
+ expect_equal(x4$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x4$futilityPerStage[2, ]))
+ expect_equal(x4$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x4$earlyStop[1, ]))
+ expect_equal(x4$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x4$earlyStop[2, ]))
+ expect_equal(x4$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[1, ]))
+ expect_equal(x4$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[2, ]))
+ expect_equal(x4$successPerStage[3, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x4$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x4$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0(unlist(as.list(x4$selectedArms))))
+ expect_equal(x4$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[1, ]))
+ expect_equal(x4$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[2, ]))
+ expect_equal(x4$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[3, ]))
+ expect_equal(x4$expectedNumberOfSubjects, c(1026, 1002, 924.5, 714.5), tolerance = 1e-07, label = paste0(x4$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x4$sampleSizes)), c(10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9, 10, 95.2, 100, 10, 100, 90.4, 10, 91.8, 83.1, 10, 100, 32.9), tolerance = 1e-07, label = paste0(unlist(as.list(x4$sampleSizes))))
+ expect_equal(x4$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x4$conditionalPowerAchieved[1, ]))
+ expect_equal(x4$conditionalPowerAchieved[2, ], c(0.16336896, 3.7379108e-06, 0.18421481, 0.069788183), tolerance = 1e-07, label = paste0(x4$conditionalPowerAchieved[2, ]))
+ expect_equal(x4$conditionalPowerAchieved[3, ], c(0.00052547754, 0.089531131, 0.32040425, 0.67566016), tolerance = 1e-07, label = paste0(x4$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x4), NA)))
+ expect_output(print(x4)$show())
+ invisible(capture.output(expect_error(summary(x4), NA)))
+ expect_output(summary(x4)$show())
+ x4CodeBased <- eval(parse(text = getObjectRCode(x4, stringWrapParagraphWidth = NULL)))
+ expect_equal(x4CodeBased$iterations, x4$iterations, tolerance = 1e-07)
+ expect_equal(x4CodeBased$rejectAtLeastOne, x4$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x4CodeBased$rejectedArmsPerStage, x4$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$futilityStop, x4$futilityStop, tolerance = 1e-07)
+ expect_equal(x4CodeBased$futilityPerStage, x4$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$earlyStop, x4$earlyStop, tolerance = 1e-07)
+ expect_equal(x4CodeBased$successPerStage, x4$successPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$selectedArms, x4$selectedArms, tolerance = 1e-07)
+ expect_equal(x4CodeBased$numberOfActiveArms, x4$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x4CodeBased$expectedNumberOfSubjects, x4$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x4CodeBased$sampleSizes, x4$sampleSizes, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalPowerAchieved, x4$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x4), "character")
+ df <- as.data.frame(x4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x5 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x5' with expected results
+ expect_equal(x5$iterations[1, ], c(10, 10, 10, 10), label = paste0(x5$iterations[1, ]))
+ expect_equal(x5$iterations[2, ], c(10, 10, 10, 10), label = paste0(x5$iterations[2, ]))
+ expect_equal(x5$iterations[3, ], c(10, 10, 8, 6), label = paste0(x5$iterations[3, ]))
+ expect_equal(x5$rejectAtLeastOne, c(0, 0.3, 0.9, 1), tolerance = 1e-07, label = paste0(x5$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x5$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0.1, 0, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.2, 0, 0.3, 0.1, 0, 0, 0, 0, 0, 0.2, 0, 0.3, 0.4, 0, 0.8, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x5$rejectedArmsPerStage))))
+ expect_equal(x5$futilityStop, c(0, 0, 0, 0), label = paste0(x5$futilityStop))
+ expect_equal(x5$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x5$futilityPerStage[1, ]))
+ expect_equal(x5$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x5$futilityPerStage[2, ]))
+ expect_equal(x5$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x5$earlyStop[1, ]))
+ expect_equal(x5$earlyStop[2, ], c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0(x5$earlyStop[2, ]))
+ expect_equal(x5$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x5$successPerStage[1, ]))
+ expect_equal(x5$successPerStage[2, ], c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0(x5$successPerStage[2, ]))
+ expect_equal(x5$successPerStage[3, ], c(0, 0, 0.3, 0.1), tolerance = 1e-07, label = paste0(x5$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x5$selectedArms)), c(1, 0.8, 0.8, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.2, 1, 0.3, 0.1, 1, 0.6, 0.6, 1, 0.5, 0.5, 1, 0.6, 0.5, 1, 0.6, 0.3, 1, 0.5, 0.5, 1, 0.8, 0.8, 1, 0.8, 0.7, 1, 0.9, 0.6, 1, 1, 1, 1, 1, 1, 1, 1, 0.8, 1, 1, 0.6), tolerance = 1e-07, label = paste0(unlist(as.list(x5$selectedArms))))
+ expect_equal(x5$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x5$numberOfActiveArms[1, ]))
+ expect_equal(x5$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x5$numberOfActiveArms[2, ]))
+ expect_equal(x5$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x5$numberOfActiveArms[3, ]))
+ expect_equal(x5$expectedNumberOfSubjects, c(642.8, 566.9, 399.8, 265.1), tolerance = 1e-07, label = paste0(x5$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x5$sampleSizes)), c(10, 77.6, 80, 10, 23.9, 30, 10, 20, 1, 10, 12.3, 1.3333333, 10, 10, 10, 10, 30.2, 28.6, 10, 28.6, 25, 10, 20, 3.1666667, 10, 60, 60, 10, 49.7, 41.1, 10, 37.4, 28.25, 10, 40.8, 9.8333333, 10, 47.6, 50, 10, 63.8, 77.3, 10, 61.2, 53.25, 10, 53.1, 14.333333, 10, 97.6, 100, 10, 83.8, 88.5, 10, 73.6, 53.75, 10, 63.1, 14.333333), tolerance = 1e-07, label = paste0(unlist(as.list(x5$sampleSizes))))
+ expect_equal(x5$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x5$conditionalPowerAchieved[1, ]))
+ expect_equal(x5$conditionalPowerAchieved[2, ], c(0.080486965, 0.12759682, 0.10458054, 0.065420449), tolerance = 1e-07, label = paste0(x5$conditionalPowerAchieved[2, ]))
+ expect_equal(x5$conditionalPowerAchieved[3, ], c(0.022470074, 0.31122739, 0.58569198, 0.85520318), tolerance = 1e-07, label = paste0(x5$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x5), NA)))
+ expect_output(print(x5)$show())
+ invisible(capture.output(expect_error(summary(x5), NA)))
+ expect_output(summary(x5)$show())
+ x5CodeBased <- eval(parse(text = getObjectRCode(x5, stringWrapParagraphWidth = NULL)))
+ expect_equal(x5CodeBased$iterations, x5$iterations, tolerance = 1e-07)
+ expect_equal(x5CodeBased$rejectAtLeastOne, x5$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x5CodeBased$rejectedArmsPerStage, x5$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$futilityStop, x5$futilityStop, tolerance = 1e-07)
+ expect_equal(x5CodeBased$futilityPerStage, x5$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$earlyStop, x5$earlyStop, tolerance = 1e-07)
+ expect_equal(x5CodeBased$successPerStage, x5$successPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$selectedArms, x5$selectedArms, tolerance = 1e-07)
+ expect_equal(x5CodeBased$numberOfActiveArms, x5$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x5CodeBased$expectedNumberOfSubjects, x5$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x5CodeBased$sampleSizes, x5$sampleSizes, tolerance = 1e-07)
+ expect_equal(x5CodeBased$conditionalPowerAchieved, x5$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x5), "character")
+ df <- as.data.frame(x5)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x5)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x6 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x6' with expected results
+ expect_equal(x6$iterations[1, ], c(10, 10, 10, 10), label = paste0(x6$iterations[1, ]))
+ expect_equal(x6$iterations[2, ], c(10, 10, 10, 10), label = paste0(x6$iterations[2, ]))
+ expect_equal(x6$iterations[3, ], c(10, 10, 8, 7), label = paste0(x6$iterations[3, ]))
+ expect_equal(x6$rejectAtLeastOne, c(0, 0.4, 0.8, 1), tolerance = 1e-07, label = paste0(x6$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x6$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.2, 0, 0.3, 0.4, 0, 0, 0, 0, 0, 0.4, 0, 0.2, 0.5, 0, 0.4, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x6$rejectedArmsPerStage))))
+ expect_equal(x6$futilityStop, c(0, 0, 0, 0), label = paste0(x6$futilityStop))
+ expect_equal(x6$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x6$futilityPerStage[1, ]))
+ expect_equal(x6$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x6$futilityPerStage[2, ]))
+ expect_equal(x6$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x6$earlyStop[1, ]))
+ expect_equal(x6$earlyStop[2, ], c(0, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0(x6$earlyStop[2, ]))
+ expect_equal(x6$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x6$successPerStage[1, ]))
+ expect_equal(x6$successPerStage[2, ], c(0, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0(x6$successPerStage[2, ]))
+ expect_equal(x6$successPerStage[3, ], c(0, 0.4, 0.6, 0.6), tolerance = 1e-07, label = paste0(x6$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x6$selectedArms)), c(1, 0.2, 0.2, 1, 0.4, 0.1, 1, 0.3, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.1, 0, 1, 0.2, 0.1, 1, 0.2, 0, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.3, 0.2, 1, 0.9, 0.4, 1, 0.3, 0.3, 1, 0.7, 0.7, 1, 0.9, 0.7, 1, 0.9, 0.6, 1, 1, 1, 1, 1, 1, 1, 1, 0.8, 1, 1, 0.7), tolerance = 1e-07, label = paste0(unlist(as.list(x6$selectedArms))))
+ expect_equal(x6$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x6$numberOfActiveArms[1, ]))
+ expect_equal(x6$numberOfActiveArms[2, ], c(1.3, 1.6, 1.7, 2.1), tolerance = 1e-07, label = paste0(x6$numberOfActiveArms[2, ]))
+ expect_equal(x6$numberOfActiveArms[3, ], c(1.3, 1.2, 1.375, 1.5714286), tolerance = 1e-07, label = paste0(x6$numberOfActiveArms[3, ]))
+ expect_equal(x6$expectedNumberOfSubjects, c(436.4, 438.6, 346.7, 372.5), tolerance = 1e-07, label = paste0(x6$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x6$sampleSizes)), c(10, 16.7, 20, 10, 27.9, 10, 10, 9.1, 12.5, 10, 1.2, 14.285714, 10, 37.5, 40, 10, 1.2, 0, 10, 12.3, 11.625, 10, 7.9, 0, 10, 32.4, 32.5, 10, 31.2, 40, 10, 21.5, 13.375, 10, 63.2, 50.142857, 10, 15.4, 28.7, 10, 56.2, 59, 10, 60.4, 63, 10, 58, 51.714286, 10, 72, 91.2, 10, 74.1, 89, 10, 61.9, 63.875, 10, 64.7, 66), tolerance = 1e-07, label = paste0(unlist(as.list(x6$sampleSizes))))
+ expect_equal(x6$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x6$conditionalPowerAchieved[1, ]))
+ expect_equal(x6$conditionalPowerAchieved[2, ], c(0.031688257, 0.035836944, 0.12967885, 0.10427074), tolerance = 1e-07, label = paste0(x6$conditionalPowerAchieved[2, ]))
+ expect_equal(x6$conditionalPowerAchieved[3, ], c(0.2491354, 0.21222327, 0.47711159, 0.3978836), tolerance = 1e-07, label = paste0(x6$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x6), NA)))
+ expect_output(print(x6)$show())
+ invisible(capture.output(expect_error(summary(x6), NA)))
+ expect_output(summary(x6)$show())
+ x6CodeBased <- eval(parse(text = getObjectRCode(x6, stringWrapParagraphWidth = NULL)))
+ expect_equal(x6CodeBased$iterations, x6$iterations, tolerance = 1e-07)
+ expect_equal(x6CodeBased$rejectAtLeastOne, x6$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x6CodeBased$rejectedArmsPerStage, x6$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$futilityStop, x6$futilityStop, tolerance = 1e-07)
+ expect_equal(x6CodeBased$futilityPerStage, x6$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$earlyStop, x6$earlyStop, tolerance = 1e-07)
+ expect_equal(x6CodeBased$successPerStage, x6$successPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$selectedArms, x6$selectedArms, tolerance = 1e-07)
+ expect_equal(x6CodeBased$numberOfActiveArms, x6$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x6CodeBased$expectedNumberOfSubjects, x6$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x6CodeBased$sampleSizes, x6$sampleSizes, tolerance = 1e-07)
+ expect_equal(x6CodeBased$conditionalPowerAchieved, x6$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x6), "character")
+ df <- as.data.frame(x6)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x6)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x7 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x7' with expected results
+ expect_equal(x7$iterations[1, ], c(10, 10, 10, 10), label = paste0(x7$iterations[1, ]))
+ expect_equal(x7$iterations[2, ], c(10, 10, 10, 10), label = paste0(x7$iterations[2, ]))
+ expect_equal(x7$iterations[3, ], c(10, 9, 8, 5), label = paste0(x7$iterations[3, ]))
+ expect_equal(x7$rejectAtLeastOne, c(0, 0.4, 0.5, 1), tolerance = 1e-07, label = paste0(x7$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x7$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0.1, 0.2, 0, 0, 0, 0, 0.1, 0.2, 0, 0.2, 0, 0, 0.4, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x7$rejectedArmsPerStage))))
+ expect_equal(x7$futilityStop, c(0, 0, 0, 0), label = paste0(x7$futilityStop))
+ expect_equal(x7$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x7$futilityPerStage[1, ]))
+ expect_equal(x7$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x7$futilityPerStage[2, ]))
+ expect_equal(x7$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x7$earlyStop[1, ]))
+ expect_equal(x7$earlyStop[2, ], c(0, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0(x7$earlyStop[2, ]))
+ expect_equal(x7$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x7$successPerStage[1, ]))
+ expect_equal(x7$successPerStage[2, ], c(0, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0(x7$successPerStage[2, ]))
+ expect_equal(x7$successPerStage[3, ], c(0, 0.3, 0.3, 0.5), tolerance = 1e-07, label = paste0(x7$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x7$selectedArms)), c(1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.2, 1, 0, 0, 1, 0.3, 0.3, 1, 0, 0, 1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.2, 1, 0.3, 0.3, 1, 0.6, 0.5, 1, 0.4, 0.2, 1, 0.7, 0.3, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x7$selectedArms))))
+ expect_equal(x7$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x7$numberOfActiveArms[1, ]))
+ expect_equal(x7$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x7$numberOfActiveArms[2, ]))
+ expect_equal(x7$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x7$numberOfActiveArms[3, ]))
+ expect_equal(x7$expectedNumberOfSubjects, c(355.2, 334, 233, 193.4), tolerance = 1e-07, label = paste0(x7$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x7$sampleSizes)), c(10, 20, 20, 10, 0, 0, 10, 20, 25, 10, 0, 0, 10, 30, 30, 10, 0, 0, 10, 3, 3.75, 10, 0, 0, 10, 12.4, 12.4, 10, 20.7, 22.777778, 10, 15, 18.75, 10, 16.2, 26.4, 10, 13.9, 13.9, 10, 54.2, 51.777778, 10, 13.1, 3, 10, 30.3, 24, 10, 76.3, 76.3, 10, 74.9, 74.555556, 10, 51.1, 50.5, 10, 46.5, 50.4), tolerance = 1e-07, label = paste0(unlist(as.list(x7$sampleSizes))))
+ expect_equal(x7$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x7$conditionalPowerAchieved[1, ]))
+ expect_equal(x7$conditionalPowerAchieved[2, ], c(0.035427106, 0.012436575, 0.08338715, 0.046283385), tolerance = 1e-07, label = paste0(x7$conditionalPowerAchieved[2, ]))
+ expect_equal(x7$conditionalPowerAchieved[3, ], c(0.076058567, 0.27636533, 0.46741694, 0.70493817), tolerance = 1e-07, label = paste0(x7$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x7), NA)))
+ expect_output(print(x7)$show())
+ invisible(capture.output(expect_error(summary(x7), NA)))
+ expect_output(summary(x7)$show())
+ x7CodeBased <- eval(parse(text = getObjectRCode(x7, stringWrapParagraphWidth = NULL)))
+ expect_equal(x7CodeBased$iterations, x7$iterations, tolerance = 1e-07)
+ expect_equal(x7CodeBased$rejectAtLeastOne, x7$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x7CodeBased$rejectedArmsPerStage, x7$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$futilityStop, x7$futilityStop, tolerance = 1e-07)
+ expect_equal(x7CodeBased$futilityPerStage, x7$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$earlyStop, x7$earlyStop, tolerance = 1e-07)
+ expect_equal(x7CodeBased$successPerStage, x7$successPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$selectedArms, x7$selectedArms, tolerance = 1e-07)
+ expect_equal(x7CodeBased$numberOfActiveArms, x7$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x7CodeBased$expectedNumberOfSubjects, x7$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x7CodeBased$sampleSizes, x7$sampleSizes, tolerance = 1e-07)
+ expect_equal(x7CodeBased$conditionalPowerAchieved, x7$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x7), "character")
+ df <- as.data.frame(x7)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x7)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x8 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x8' with expected results
+ expect_equal(x8$iterations[1, ], c(10, 10, 10, 10), label = paste0(x8$iterations[1, ]))
+ expect_equal(x8$iterations[2, ], c(10, 10, 10, 10), label = paste0(x8$iterations[2, ]))
+ expect_equal(x8$iterations[3, ], c(10, 10, 9, 8), label = paste0(x8$iterations[3, ]))
+ expect_equal(x8$rejectAtLeastOne, c(0, 0.2, 0.9, 1), tolerance = 1e-07, label = paste0(x8$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x8$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.1, 0.3, 0, 0.2, 0.4, 0, 0, 0, 0, 0, 0.1, 0, 0.3, 0.3, 0.1, 0.4, 0.5, 0, 0, 0, 0, 0, 0.1, 0, 0.4, 0.5, 0.1, 0.8, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x8$rejectedArmsPerStage))))
+ expect_equal(x8$futilityStop, c(0, 0, 0, 0), label = paste0(x8$futilityStop))
+ expect_equal(x8$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x8$futilityPerStage[1, ]))
+ expect_equal(x8$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x8$futilityPerStage[2, ]))
+ expect_equal(x8$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x8$earlyStop[1, ]))
+ expect_equal(x8$earlyStop[2, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0(x8$earlyStop[2, ]))
+ expect_equal(x8$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[1, ]))
+ expect_equal(x8$successPerStage[2, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0(x8$successPerStage[2, ]))
+ expect_equal(x8$successPerStage[3, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0(x8$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x8$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x8$selectedArms))))
+ expect_equal(x8$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[1, ]))
+ expect_equal(x8$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[2, ]))
+ expect_equal(x8$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[3, ]))
+ expect_equal(x8$expectedNumberOfSubjects, c(952, 1050, 909.5, 860), tolerance = 1e-07, label = paste0(x8$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x8$sampleSizes)), c(10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75, 10, 90.2, 90.2, 10, 100, 100, 10, 91, 89.888889, 10, 91, 88.75), tolerance = 1e-07, label = paste0(unlist(as.list(x8$sampleSizes))))
+ expect_equal(x8$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x8$conditionalPowerAchieved[1, ]))
+ expect_equal(x8$conditionalPowerAchieved[2, ], c(0.16068828, 0.022112719, 0.21849189, 0.19646842), tolerance = 1e-07, label = paste0(x8$conditionalPowerAchieved[2, ]))
+ expect_equal(x8$conditionalPowerAchieved[3, ], c(0.0018216452, 0.044801331, 0.47086458, 0.69046124), tolerance = 1e-07, label = paste0(x8$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x8), NA)))
+ expect_output(print(x8)$show())
+ invisible(capture.output(expect_error(summary(x8), NA)))
+ expect_output(summary(x8)$show())
+ x8CodeBased <- eval(parse(text = getObjectRCode(x8, stringWrapParagraphWidth = NULL)))
+ expect_equal(x8CodeBased$iterations, x8$iterations, tolerance = 1e-07)
+ expect_equal(x8CodeBased$rejectAtLeastOne, x8$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x8CodeBased$rejectedArmsPerStage, x8$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$futilityStop, x8$futilityStop, tolerance = 1e-07)
+ expect_equal(x8CodeBased$futilityPerStage, x8$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$earlyStop, x8$earlyStop, tolerance = 1e-07)
+ expect_equal(x8CodeBased$successPerStage, x8$successPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$selectedArms, x8$selectedArms, tolerance = 1e-07)
+ expect_equal(x8CodeBased$numberOfActiveArms, x8$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x8CodeBased$expectedNumberOfSubjects, x8$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x8CodeBased$sampleSizes, x8$sampleSizes, tolerance = 1e-07)
+ expect_equal(x8CodeBased$conditionalPowerAchieved, x8$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x8), "character")
+ df <- as.data.frame(x8)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x9 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x9' with expected results
+ expect_equal(x9$iterations[1, ], c(10, 10, 10, 10), label = paste0(x9$iterations[1, ]))
+ expect_equal(x9$iterations[2, ], c(10, 10, 10, 10), label = paste0(x9$iterations[2, ]))
+ expect_equal(x9$iterations[3, ], c(10, 10, 10, 5), label = paste0(x9$iterations[3, ]))
+ expect_equal(x9$rejectAtLeastOne, c(0, 0.2, 0.7, 1), tolerance = 1e-07, label = paste0(x9$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x9$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0.1, 0.1, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0.2, 0, 0.4, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3, 0.1, 0.6, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x9$rejectedArmsPerStage))))
+ expect_equal(x9$futilityStop, c(0, 0, 0, 0), label = paste0(x9$futilityStop))
+ expect_equal(x9$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x9$futilityPerStage[1, ]))
+ expect_equal(x9$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x9$futilityPerStage[2, ]))
+ expect_equal(x9$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x9$earlyStop[1, ]))
+ expect_equal(x9$earlyStop[2, ], c(0, 0, 0, 0.5), tolerance = 1e-07, label = paste0(x9$earlyStop[2, ]))
+ expect_equal(x9$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x9$successPerStage[1, ]))
+ expect_equal(x9$successPerStage[2, ], c(0, 0, 0, 0.5), tolerance = 1e-07, label = paste0(x9$successPerStage[2, ]))
+ expect_equal(x9$successPerStage[3, ], c(0, 0.1, 0.1, 0.3), tolerance = 1e-07, label = paste0(x9$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x9$selectedArms)), c(1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.3, 0.3, 1, 0.2, 0.1, 1, 0.7, 0.7, 1, 0.2, 0.2, 1, 0.5, 0.5, 1, 0.3, 0.2, 1, 0.5, 0.5, 1, 0.7, 0.7, 1, 0.6, 0.6, 1, 0.6, 0.3, 1, 0.2, 0.2, 1, 0.7, 0.7, 1, 0.6, 0.6, 1, 0.9, 0.4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x9$selectedArms))))
+ expect_equal(x9$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x9$numberOfActiveArms[1, ]))
+ expect_equal(x9$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x9$numberOfActiveArms[2, ]))
+ expect_equal(x9$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x9$numberOfActiveArms[3, ]))
+ expect_equal(x9$expectedNumberOfSubjects, c(603.2, 605.9, 453.2, 361.7), tolerance = 1e-07, label = paste0(x9$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x9$sampleSizes)), c(10, 52.2, 52.2, 10, 33.6, 33.5, 10, 21.2, 21.2, 10, 9.2, 17.6, 10, 70, 70, 10, 20, 20, 10, 35.6, 35.3, 10, 19.7, 21.4, 10, 45.3, 45.3, 10, 62.7, 62.6, 10, 36.2, 35.8, 10, 52.8, 45.4, 10, 16.9, 16.9, 10, 69.1, 69.1, 10, 41.8, 41.7, 10, 61.7, 44.4, 10, 92.2, 92.2, 10, 92.7, 92.6, 10, 67.4, 67, 10, 71.7, 64.4), tolerance = 1e-07, label = paste0(unlist(as.list(x9$sampleSizes))))
+ expect_equal(x9$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x9$conditionalPowerAchieved[1, ]))
+ expect_equal(x9$conditionalPowerAchieved[2, ], c(0.083443128, 0.076003514, 0.14647721, 0.085145955), tolerance = 1e-07, label = paste0(x9$conditionalPowerAchieved[2, ]))
+ expect_equal(x9$conditionalPowerAchieved[3, ], c(0.043093175, 0.13127607, 0.3479275, 0.64693149), tolerance = 1e-07, label = paste0(x9$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x9), NA)))
+ expect_output(print(x9)$show())
+ invisible(capture.output(expect_error(summary(x9), NA)))
+ expect_output(summary(x9)$show())
+ x9CodeBased <- eval(parse(text = getObjectRCode(x9, stringWrapParagraphWidth = NULL)))
+ expect_equal(x9CodeBased$iterations, x9$iterations, tolerance = 1e-07)
+ expect_equal(x9CodeBased$rejectAtLeastOne, x9$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x9CodeBased$rejectedArmsPerStage, x9$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$futilityStop, x9$futilityStop, tolerance = 1e-07)
+ expect_equal(x9CodeBased$futilityPerStage, x9$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$earlyStop, x9$earlyStop, tolerance = 1e-07)
+ expect_equal(x9CodeBased$successPerStage, x9$successPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$selectedArms, x9$selectedArms, tolerance = 1e-07)
+ expect_equal(x9CodeBased$numberOfActiveArms, x9$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x9CodeBased$expectedNumberOfSubjects, x9$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x9CodeBased$sampleSizes, x9$sampleSizes, tolerance = 1e-07)
+ expect_equal(x9CodeBased$conditionalPowerAchieved, x9$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x9), "character")
+ df <- as.data.frame(x9)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x9)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x10 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x10' with expected results
+ expect_equal(x10$iterations[1, ], c(10, 10, 10, 10), label = paste0(x10$iterations[1, ]))
+ expect_equal(x10$iterations[2, ], c(10, 10, 10, 10), label = paste0(x10$iterations[2, ]))
+ expect_equal(x10$iterations[3, ], c(10, 9, 7, 6), label = paste0(x10$iterations[3, ]))
+ expect_equal(x10$rejectAtLeastOne, c(0, 0.2, 0.6, 0.6), tolerance = 1e-07, label = paste0(x10$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x10$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0.1, 0, 0.1, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0.1, 0, 0.3, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.3, 0, 0, 0.3, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x10$rejectedArmsPerStage))))
+ expect_equal(x10$futilityStop, c(0, 0, 0, 0), label = paste0(x10$futilityStop))
+ expect_equal(x10$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x10$futilityPerStage[1, ]))
+ expect_equal(x10$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x10$futilityPerStage[2, ]))
+ expect_equal(x10$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x10$earlyStop[1, ]))
+ expect_equal(x10$earlyStop[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0(x10$earlyStop[2, ]))
+ expect_equal(x10$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x10$successPerStage[1, ]))
+ expect_equal(x10$successPerStage[2, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0(x10$successPerStage[2, ]))
+ expect_equal(x10$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x10$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x10$selectedArms)), c(1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.5, 0.4, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.3, 1, 0.4, 0.4, 1, 0.7, 0.6, 1, 0.5, 0.3, 1, 0.5, 0.3, 1, 1, 1, 1, 1, 0.9, 1, 1, 0.7, 1, 1, 0.6), tolerance = 1e-07, label = paste0(unlist(as.list(x10$selectedArms))))
+ expect_equal(x10$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x10$numberOfActiveArms[1, ]))
+ expect_equal(x10$numberOfActiveArms[2, ], c(1.2, 1.8, 1.5, 1.6), tolerance = 1e-07, label = paste0(x10$numberOfActiveArms[2, ]))
+ expect_equal(x10$numberOfActiveArms[3, ], c(1.2, 1.7777778, 1.7142857, 1.8333333), tolerance = 1e-07, label = paste0(x10$numberOfActiveArms[3, ]))
+ expect_equal(x10$expectedNumberOfSubjects, c(313.2, 474, 363.7, 263.7), tolerance = 1e-07, label = paste0(x10$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x10$sampleSizes)), c(10, 15.9, 15.8, 10, 35.9, 39.777778, 10, 12.7, 18, 10, 2.8, 4.6666667, 10, 22.2, 22.2, 10, 30, 22.222222, 10, 22.7, 28.571429, 10, 27.4, 43.166667, 10, 18.1, 18, 10, 32.8, 36.444444, 10, 38.6, 54.857143, 10, 26.7, 26.5, 10, 15.8, 15.8, 10, 54.9, 49.777778, 10, 37.3, 24.571429, 10, 24.9, 23.666667, 10, 59.8, 59.6, 10, 73.6, 70.444444, 10, 68.6, 65.142857, 10, 43, 50.166667), tolerance = 1e-07, label = paste0(unlist(as.list(x10$sampleSizes))))
+ expect_equal(x10$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x10$conditionalPowerAchieved[1, ]))
+ expect_equal(x10$conditionalPowerAchieved[2, ], c(0.067103341, 0.011749166, 0.024807536, 0.13720867), tolerance = 1e-07, label = paste0(x10$conditionalPowerAchieved[2, ]))
+ expect_equal(x10$conditionalPowerAchieved[3, ], c(0.10265269, 0.46661697, 0.4198773, 0.2422132), tolerance = 1e-07, label = paste0(x10$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x10), NA)))
+ expect_output(print(x10)$show())
+ invisible(capture.output(expect_error(summary(x10), NA)))
+ expect_output(summary(x10)$show())
+ x10CodeBased <- eval(parse(text = getObjectRCode(x10, stringWrapParagraphWidth = NULL)))
+ expect_equal(x10CodeBased$iterations, x10$iterations, tolerance = 1e-07)
+ expect_equal(x10CodeBased$rejectAtLeastOne, x10$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x10CodeBased$rejectedArmsPerStage, x10$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$futilityStop, x10$futilityStop, tolerance = 1e-07)
+ expect_equal(x10CodeBased$futilityPerStage, x10$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$earlyStop, x10$earlyStop, tolerance = 1e-07)
+ expect_equal(x10CodeBased$successPerStage, x10$successPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$selectedArms, x10$selectedArms, tolerance = 1e-07)
+ expect_equal(x10CodeBased$numberOfActiveArms, x10$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x10CodeBased$expectedNumberOfSubjects, x10$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x10CodeBased$sampleSizes, x10$sampleSizes, tolerance = 1e-07)
+ expect_equal(x10CodeBased$conditionalPowerAchieved, x10$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x10), "character")
+ df <- as.data.frame(x10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x11 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100), directionUpper = FALSE,
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x11' with expected results
+ expect_equal(x11$iterations[1, ], c(10, 10, 10), label = paste0(x11$iterations[1, ]))
+ expect_equal(x11$iterations[2, ], c(8, 5, 9), label = paste0(x11$iterations[2, ]))
+ expect_equal(x11$iterations[3, ], c(4, 4, 6), label = paste0(x11$iterations[3, ]))
+ expect_equal(x11$rejectAtLeastOne, c(0.4, 0, 0), tolerance = 1e-07, label = paste0(x11$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x11$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x11$rejectedArmsPerStage))))
+ expect_equal(x11$futilityStop, c(0.2, 0.6, 0.4), tolerance = 1e-07, label = paste0(x11$futilityStop))
+ expect_equal(x11$futilityPerStage[1, ], c(0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0(x11$futilityPerStage[1, ]))
+ expect_equal(x11$futilityPerStage[2, ], c(0, 0.1, 0.3), tolerance = 1e-07, label = paste0(x11$futilityPerStage[2, ]))
+ expect_equal(x11$earlyStop[1, ], c(0.2, 0.5, 0.1), tolerance = 1e-07, label = paste0(x11$earlyStop[1, ]))
+ expect_equal(x11$earlyStop[2, ], c(0.4, 0.1, 0.3), tolerance = 1e-07, label = paste0(x11$earlyStop[2, ]))
+ expect_equal(x11$successPerStage[1, ], c(0, 0, 0), label = paste0(x11$successPerStage[1, ]))
+ expect_equal(x11$successPerStage[2, ], c(0.4, 0, 0), tolerance = 1e-07, label = paste0(x11$successPerStage[2, ]))
+ expect_equal(x11$successPerStage[3, ], c(0, 0, 0), label = paste0(x11$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x11$selectedArms)), c(1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.2, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0, 0, 1, 0.2, 0.2, 1, 0.3, 0, 1, 0.1, 0.1, 1, 0.3, 0.2, 1, 0.8, 0.4, 1, 0.5, 0.4, 1, 0.9, 0.6), tolerance = 1e-07, label = paste0(unlist(as.list(x11$selectedArms))))
+ expect_equal(x11$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0(x11$numberOfActiveArms[1, ]))
+ expect_equal(x11$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0(x11$numberOfActiveArms[2, ]))
+ expect_equal(x11$numberOfActiveArms[3, ], c(1, 1, 1), label = paste0(x11$numberOfActiveArms[3, ]))
+ expect_equal(x11$expectedNumberOfSubjects, c(200.6, 150, 279), tolerance = 1e-07, label = paste0(x11$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x11$sampleSizes)), c(10, 1, 3.25, 10, 2.8, 25, 10, 17.333333, 15.666667, 10, 6.25, 50, 10, 23.2, 32, 10, 11.111111, 16.666667, 10, 14.5, 21, 10, 0, 0, 10, 15.777778, 33.333333, 10, 35.25, 0, 10, 8.4, 25, 10, 17, 33.333333, 10, 57, 74.25, 10, 34.4, 82, 10, 61.222222, 99), tolerance = 1e-07, label = paste0(unlist(as.list(x11$sampleSizes))))
+ expect_equal(x11$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x11$conditionalPowerAchieved[1, ]))
+ expect_equal(x11$conditionalPowerAchieved[2, ], c(0.10402635, 0.15240707, 0.070533409), tolerance = 1e-07, label = paste0(x11$conditionalPowerAchieved[2, ]))
+ expect_equal(x11$conditionalPowerAchieved[3, ], c(0.68219789, 0.38677479, 0.34246832), tolerance = 1e-07, label = paste0(x11$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x11), NA)))
+ expect_output(print(x11)$show())
+ invisible(capture.output(expect_error(summary(x11), NA)))
+ expect_output(summary(x11)$show())
+ x11CodeBased <- eval(parse(text = getObjectRCode(x11, stringWrapParagraphWidth = NULL)))
+ expect_equal(x11CodeBased$iterations, x11$iterations, tolerance = 1e-07)
+ expect_equal(x11CodeBased$rejectAtLeastOne, x11$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x11CodeBased$rejectedArmsPerStage, x11$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$futilityStop, x11$futilityStop, tolerance = 1e-07)
+ expect_equal(x11CodeBased$futilityPerStage, x11$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$earlyStop, x11$earlyStop, tolerance = 1e-07)
+ expect_equal(x11CodeBased$successPerStage, x11$successPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$selectedArms, x11$selectedArms, tolerance = 1e-07)
+ expect_equal(x11CodeBased$numberOfActiveArms, x11$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x11CodeBased$expectedNumberOfSubjects, x11$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x11CodeBased$sampleSizes, x11$sampleSizes, tolerance = 1e-07)
+ expect_equal(x11CodeBased$conditionalPowerAchieved, x11$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x11), "character")
+ df <- as.data.frame(x11)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x11)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x12 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2), intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x12' with expected results
+ expect_equal(x12$iterations[1, ], c(10, 10, 10, 10), label = paste0(x12$iterations[1, ]))
+ expect_equal(x12$iterations[2, ], c(6, 6, 7, 9), label = paste0(x12$iterations[2, ]))
+ expect_equal(x12$iterations[3, ], c(3, 4, 5, 4), label = paste0(x12$iterations[3, ]))
+ expect_equal(x12$rejectAtLeastOne, c(0, 0, 0.5, 0.8), tolerance = 1e-07, label = paste0(x12$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x12$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.3, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.2, 0.2, 0, 0.2, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x12$rejectedArmsPerStage))))
+ expect_equal(x12$futilityStop, c(0.7, 0.6, 0.3, 0.1), tolerance = 1e-07, label = paste0(x12$futilityStop))
+ expect_equal(x12$futilityPerStage[1, ], c(0.4, 0.4, 0.3, 0.1), tolerance = 1e-07, label = paste0(x12$futilityPerStage[1, ]))
+ expect_equal(x12$futilityPerStage[2, ], c(0.3, 0.2, 0, 0), tolerance = 1e-07, label = paste0(x12$futilityPerStage[2, ]))
+ expect_equal(x12$earlyStop[1, ], c(0.4, 0.4, 0.3, 0.1), tolerance = 1e-07, label = paste0(x12$earlyStop[1, ]))
+ expect_equal(x12$earlyStop[2, ], c(0.3, 0.2, 0.2, 0.5), tolerance = 1e-07, label = paste0(x12$earlyStop[2, ]))
+ expect_equal(x12$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x12$successPerStage[1, ]))
+ expect_equal(x12$successPerStage[2, ], c(0, 0, 0.2, 0.5), tolerance = 1e-07, label = paste0(x12$successPerStage[2, ]))
+ expect_equal(x12$successPerStage[3, ], c(0, 0, 0.3, 0.3), tolerance = 1e-07, label = paste0(x12$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x12$selectedArms)), c(1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.2, 0, 1, 0.2, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.1, 1, 0.3, 0.2, 1, 0.2, 0.1, 1, 0.4, 0.2, 1, 0.4, 0.2, 1, 0.6, 0.3, 1, 0.6, 0.4, 1, 0.7, 0.5, 1, 0.9, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x12$selectedArms))))
+ expect_equal(x12$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x12$numberOfActiveArms[1, ]))
+ expect_equal(x12$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x12$numberOfActiveArms[2, ]))
+ expect_equal(x12$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x12$numberOfActiveArms[3, ]))
+ expect_equal(x12$expectedNumberOfSubjects, c(188, 175, 176, 185), label = paste0(x12$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x12$sampleSizes)), c(10, 9.8333333, 32, 10, 10.833333, 27.5, 10, 14.285714, 20, 10, 5.8888889, 25, 10, 18.833333, 0, 10, 33.333333, 25, 10, 2, 20, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 2, 2, 10, 13.333333, 22.75, 10, 37, 66.666667, 10, 8.3333333, 25, 10, 20.857143, 29.2, 10, 18.444444, 36.25, 10, 65.666667, 98.666667, 10, 52.5, 77.5, 10, 39.142857, 71.2, 10, 37.666667, 84), tolerance = 1e-07, label = paste0(unlist(as.list(x12$sampleSizes))))
+ expect_equal(x12$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x12$conditionalPowerAchieved[1, ]))
+ expect_equal(x12$conditionalPowerAchieved[2, ], c(0.1067614, 0.028335233, 0.15675994, 0.029094411), tolerance = 1e-07, label = paste0(x12$conditionalPowerAchieved[2, ]))
+ expect_equal(x12$conditionalPowerAchieved[3, ], c(0.43970154, 0.38730712, 0.69132205, 0.60200615), tolerance = 1e-07, label = paste0(x12$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x12), NA)))
+ expect_output(print(x12)$show())
+ invisible(capture.output(expect_error(summary(x12), NA)))
+ expect_output(summary(x12)$show())
+ x12CodeBased <- eval(parse(text = getObjectRCode(x12, stringWrapParagraphWidth = NULL)))
+ expect_equal(x12CodeBased$iterations, x12$iterations, tolerance = 1e-07)
+ expect_equal(x12CodeBased$rejectAtLeastOne, x12$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x12CodeBased$rejectedArmsPerStage, x12$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$futilityStop, x12$futilityStop, tolerance = 1e-07)
+ expect_equal(x12CodeBased$futilityPerStage, x12$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$earlyStop, x12$earlyStop, tolerance = 1e-07)
+ expect_equal(x12CodeBased$successPerStage, x12$successPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$selectedArms, x12$selectedArms, tolerance = 1e-07)
+ expect_equal(x12CodeBased$numberOfActiveArms, x12$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x12CodeBased$expectedNumberOfSubjects, x12$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x12CodeBased$sampleSizes, x12$sampleSizes, tolerance = 1e-07)
+ expect_equal(x12CodeBased$conditionalPowerAchieved, x12$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x12), "character")
+ df <- as.data.frame(x12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x13 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "userDefined", activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, adaptations = rep(TRUE, 2),
+ effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4), intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x13' with expected results
+ expect_equal(x13$iterations[1, ], c(10, 10), label = paste0(x13$iterations[1, ]))
+ expect_equal(x13$iterations[2, ], c(6, 5), label = paste0(x13$iterations[2, ]))
+ expect_equal(x13$iterations[3, ], c(6, 3), label = paste0(x13$iterations[3, ]))
+ expect_equal(x13$rejectAtLeastOne, c(0.2, 0.4), tolerance = 1e-07, label = paste0(x13$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x13$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0.2, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x13$rejectedArmsPerStage))))
+ expect_equal(x13$futilityStop, c(0.4, 0.5), tolerance = 1e-07, label = paste0(x13$futilityStop))
+ expect_equal(x13$futilityPerStage[1, ], c(0.4, 0.5), tolerance = 1e-07, label = paste0(x13$futilityPerStage[1, ]))
+ expect_equal(x13$futilityPerStage[2, ], c(0, 0), label = paste0(x13$futilityPerStage[2, ]))
+ expect_equal(x13$earlyStop[1, ], c(0.4, 0.5), tolerance = 1e-07, label = paste0(x13$earlyStop[1, ]))
+ expect_equal(x13$earlyStop[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0(x13$earlyStop[2, ]))
+ expect_equal(x13$successPerStage[1, ], c(0, 0), label = paste0(x13$successPerStage[1, ]))
+ expect_equal(x13$successPerStage[2, ], c(0, 0.2), tolerance = 1e-07, label = paste0(x13$successPerStage[2, ]))
+ expect_equal(x13$successPerStage[3, ], c(0.2, 0.2), tolerance = 1e-07, label = paste0(x13$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x13$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0, 0, 1, 0.5, 0.5, 1, 0.4, 0.2, 1, 0.6, 0.6, 1, 0.5, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x13$selectedArms))))
+ expect_equal(x13$numberOfActiveArms[1, ], c(4, 4), label = paste0(x13$numberOfActiveArms[1, ]))
+ expect_equal(x13$numberOfActiveArms[2, ], c(1, 1), label = paste0(x13$numberOfActiveArms[2, ]))
+ expect_equal(x13$numberOfActiveArms[3, ], c(1, 1), label = paste0(x13$numberOfActiveArms[3, ]))
+ expect_equal(x13$expectedNumberOfSubjects, c(203, 169.6), tolerance = 1e-07, label = paste0(x13$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x13$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, 9.8333333, 16.666667, 10, 11.8, 10.666667, 10, 0, 0, 10, 0, 0, 10, 34.5, 66.5, 10, 63.6, 63, 10, 44.333333, 83.166667, 10, 75.4, 73.666667), tolerance = 1e-07, label = paste0(unlist(as.list(x13$sampleSizes))))
+ expect_equal(x13$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0(x13$conditionalPowerAchieved[1, ]))
+ expect_equal(x13$conditionalPowerAchieved[2, ], c(0.045209815, 0.0014148507), tolerance = 1e-07, label = paste0(x13$conditionalPowerAchieved[2, ]))
+ expect_equal(x13$conditionalPowerAchieved[3, ], c(0.60681086, 0.72002567), tolerance = 1e-07, label = paste0(x13$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x13), NA)))
+ expect_output(print(x13)$show())
+ invisible(capture.output(expect_error(summary(x13), NA)))
+ expect_output(summary(x13)$show())
+ x13CodeBased <- eval(parse(text = getObjectRCode(x13, stringWrapParagraphWidth = NULL)))
+ expect_equal(x13CodeBased$iterations, x13$iterations, tolerance = 1e-07)
+ expect_equal(x13CodeBased$rejectAtLeastOne, x13$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x13CodeBased$rejectedArmsPerStage, x13$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$futilityStop, x13$futilityStop, tolerance = 1e-07)
+ expect_equal(x13CodeBased$futilityPerStage, x13$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$earlyStop, x13$earlyStop, tolerance = 1e-07)
+ expect_equal(x13CodeBased$successPerStage, x13$successPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$selectedArms, x13$selectedArms, tolerance = 1e-07)
+ expect_equal(x13CodeBased$numberOfActiveArms, x13$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x13CodeBased$expectedNumberOfSubjects, x13$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x13CodeBased$sampleSizes, x13$sampleSizes, tolerance = 1e-07)
+ expect_equal(x13CodeBased$conditionalPowerAchieved, x13$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x13), "character")
+ df <- as.data.frame(x13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x14 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x14' with expected results
+ expect_equal(x14$iterations[1, ], c(10, 10, 10, 10), label = paste0(x14$iterations[1, ]))
+ expect_equal(x14$iterations[2, ], c(5, 6, 9, 9), label = paste0(x14$iterations[2, ]))
+ expect_equal(x14$iterations[3, ], c(0, 1, 5, 9), label = paste0(x14$iterations[3, ]))
+ expect_equal(x14$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x14$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x14$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x14$rejectedArmsPerStage))))
+ expect_equal(x14$futilityStop, c(1, 0.9, 0.5, 0.1), tolerance = 1e-07, label = paste0(x14$futilityStop))
+ expect_equal(x14$futilityPerStage[1, ], c(0.5, 0.4, 0.1, 0.1), tolerance = 1e-07, label = paste0(x14$futilityPerStage[1, ]))
+ expect_equal(x14$futilityPerStage[2, ], c(0.5, 0.5, 0.4, 0), tolerance = 1e-07, label = paste0(x14$futilityPerStage[2, ]))
+ expect_equal(x14$earlyStop[1, ], c(0.5, 0.4, 0.1, 0.1), tolerance = 1e-07, label = paste0(x14$earlyStop[1, ]))
+ expect_equal(x14$earlyStop[2, ], c(0.5, 0.5, 0.4, 0), tolerance = 1e-07, label = paste0(x14$earlyStop[2, ]))
+ expect_equal(x14$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[1, ]))
+ expect_equal(x14$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[2, ]))
+ expect_equal(x14$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x14$selectedArms)), c(1, 0.1, 0, 1, 0.1, 0, 1, 0.2, 0, 1, 0.1, 0.1, 1, 0.2, 0, 1, 0, 0, 1, 0.2, 0.1, 1, 0.1, 0.1, 1, 0, 0, 1, 0.4, 0.1, 1, 0.2, 0.1, 1, 0.3, 0.3, 1, 0.2, 0, 1, 0.1, 0, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.5, 0, 1, 0.6, 0.1, 1, 0.9, 0.5, 1, 0.9, 0.9), tolerance = 1e-07, label = paste0(unlist(as.list(x14$selectedArms))))
+ expect_equal(x14$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x14$numberOfActiveArms[1, ]))
+ expect_equal(x14$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x14$numberOfActiveArms[2, ]))
+ expect_equal(x14$numberOfActiveArms[3, ], c(NaN, 1, 1, 1), label = paste0(x14$numberOfActiveArms[3, ]))
+ expect_equal(x14$expectedNumberOfSubjects, c(NaN, 171.2, 271.2, 368.4), tolerance = 1e-07, label = paste0(x14$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x14$sampleSizes)), c(10, 20, 0, 10, 8.8333333, 0, 10, 17, 0, 10, 5.8888889, 11.111111, 10, 40, 0, 10, 0, 0, 10, 8.8888889, 20, 10, 3, 11.111111, 10, 0, 0, 10, 58.833333, 100, 10, 8.1111111, 20, 10, 28.111111, 33.333333, 10, 38.2, 0, 10, 16.666667, 0, 10, 33.333333, 60, 10, 39.888889, 44.444444, 10, 98.2, 0, 10, 84.333333, 100, 10, 67.333333, 100, 10, 76.888889, 100), tolerance = 1e-07, label = paste0(unlist(as.list(x14$sampleSizes))))
+ expect_equal(x14$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x14$conditionalPowerAchieved[1, ]))
+ expect_equal(x14$conditionalPowerAchieved[2, ], c(0.0010701396, 1.0749986e-05, 0.015009054, 0.019936014), tolerance = 1e-07, label = paste0(x14$conditionalPowerAchieved[2, ]))
+ expect_equal(x14$conditionalPowerAchieved[3, ], c(NaN, 0.062530095, 0.19373785, 0.13543053), tolerance = 1e-07, label = paste0(x14$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x14), NA)))
+ expect_output(print(x14)$show())
+ invisible(capture.output(expect_error(summary(x14), NA)))
+ expect_output(summary(x14)$show())
+ x14CodeBased <- eval(parse(text = getObjectRCode(x14, stringWrapParagraphWidth = NULL)))
+ expect_equal(x14CodeBased$iterations, x14$iterations, tolerance = 1e-07)
+ expect_equal(x14CodeBased$rejectAtLeastOne, x14$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x14CodeBased$rejectedArmsPerStage, x14$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$futilityStop, x14$futilityStop, tolerance = 1e-07)
+ expect_equal(x14CodeBased$futilityPerStage, x14$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$earlyStop, x14$earlyStop, tolerance = 1e-07)
+ expect_equal(x14CodeBased$successPerStage, x14$successPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$selectedArms, x14$selectedArms, tolerance = 1e-07)
+ expect_equal(x14CodeBased$numberOfActiveArms, x14$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x14CodeBased$expectedNumberOfSubjects, x14$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x14CodeBased$sampleSizes, x14$sampleSizes, tolerance = 1e-07)
+ expect_equal(x14CodeBased$conditionalPowerAchieved, x14$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x14), "character")
+ df <- as.data.frame(x14)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x14)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x15 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x15' with expected results
+ expect_equal(x15$iterations[1, ], c(10, 10, 10, 10), label = paste0(x15$iterations[1, ]))
+ expect_equal(x15$iterations[2, ], c(8, 9, 10, 9), label = paste0(x15$iterations[2, ]))
+ expect_equal(x15$iterations[3, ], c(4, 9, 8, 5), label = paste0(x15$iterations[3, ]))
+ expect_equal(x15$rejectAtLeastOne, c(0, 0.2, 0.7, 0.9), tolerance = 1e-07, label = paste0(x15$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x15$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.3, 0.1, 0, 0, 0, 0, 0.2, 0, 0, 0.3, 0, 0, 0.4, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.4, 0.3, 0, 0.6, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x15$rejectedArmsPerStage))))
+ expect_equal(x15$futilityStop, c(0.6, 0.1, 0, 0.1), tolerance = 1e-07, label = paste0(x15$futilityStop))
+ expect_equal(x15$futilityPerStage[1, ], c(0.2, 0.1, 0, 0.1), tolerance = 1e-07, label = paste0(x15$futilityPerStage[1, ]))
+ expect_equal(x15$futilityPerStage[2, ], c(0.4, 0, 0, 0), tolerance = 1e-07, label = paste0(x15$futilityPerStage[2, ]))
+ expect_equal(x15$earlyStop[1, ], c(0.2, 0.1, 0, 0.1), tolerance = 1e-07, label = paste0(x15$earlyStop[1, ]))
+ expect_equal(x15$earlyStop[2, ], c(0.4, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0(x15$earlyStop[2, ]))
+ expect_equal(x15$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x15$successPerStage[1, ]))
+ expect_equal(x15$successPerStage[2, ], c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0(x15$successPerStage[2, ]))
+ expect_equal(x15$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x15$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x15$selectedArms)), c(1, 0.7, 0.2, 1, 0.5, 0.2, 1, 0.7, 0.5, 1, 0.2, 0.2, 1, 0.5, 0.3, 1, 0.5, 0.4, 1, 0.3, 0.3, 1, 0.7, 0.4, 1, 0.6, 0.1, 1, 0.5, 0.4, 1, 0.7, 0.6, 1, 0.8, 0.4, 1, 0.4, 0.4, 1, 0.8, 0.8, 1, 0.8, 0.6, 1, 0.7, 0.5, 1, 0.8, 0.4, 1, 0.9, 0.9, 1, 1, 0.8, 1, 0.9, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x15$selectedArms))))
+ expect_equal(x15$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x15$numberOfActiveArms[1, ]))
+ expect_equal(x15$numberOfActiveArms[2, ], c(2.75, 2.5555556, 2.5, 2.6666667), tolerance = 1e-07, label = paste0(x15$numberOfActiveArms[2, ]))
+ expect_equal(x15$numberOfActiveArms[3, ], c(2.5, 2, 2.5, 3), tolerance = 1e-07, label = paste0(x15$numberOfActiveArms[3, ]))
+ expect_equal(x15$expectedNumberOfSubjects, c(460, 640, 571.4, 381.6), tolerance = 1e-07, label = paste0(x15$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x15$sampleSizes)), c(10, 80, 50, 10, 55.555556, 22.222222, 10, 66.8, 38.5, 10, 22.222222, 1.6, 10, 55, 75, 10, 55.555556, 44.444444, 10, 27.8, 25.5, 10, 69.777778, 14.4, 10, 67.5, 25, 10, 55.555556, 44.444444, 10, 66.8, 48, 10, 80.888889, 14.4, 10, 42.5, 100, 10, 88.888889, 88.888889, 10, 76.8, 48, 10, 69.777778, 15.2, 10, 92.5, 100, 10, 100, 100, 10, 96.8, 73, 10, 92, 15.2), tolerance = 1e-07, label = paste0(unlist(as.list(x15$sampleSizes))))
+ expect_equal(x15$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x15$conditionalPowerAchieved[1, ]))
+ expect_equal(x15$conditionalPowerAchieved[2, ], c(0.26433659, 0.055206819, 0.10369686, 0.046653519), tolerance = 1e-07, label = paste0(x15$conditionalPowerAchieved[2, ]))
+ expect_equal(x15$conditionalPowerAchieved[3, ], c(0.023182671, 0.15953762, 0.43788092, 0.96046919), tolerance = 1e-07, label = paste0(x15$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x15), NA)))
+ expect_output(print(x15)$show())
+ invisible(capture.output(expect_error(summary(x15), NA)))
+ expect_output(summary(x15)$show())
+ x15CodeBased <- eval(parse(text = getObjectRCode(x15, stringWrapParagraphWidth = NULL)))
+ expect_equal(x15CodeBased$iterations, x15$iterations, tolerance = 1e-07)
+ expect_equal(x15CodeBased$rejectAtLeastOne, x15$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x15CodeBased$rejectedArmsPerStage, x15$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$futilityStop, x15$futilityStop, tolerance = 1e-07)
+ expect_equal(x15CodeBased$futilityPerStage, x15$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$earlyStop, x15$earlyStop, tolerance = 1e-07)
+ expect_equal(x15CodeBased$successPerStage, x15$successPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$selectedArms, x15$selectedArms, tolerance = 1e-07)
+ expect_equal(x15CodeBased$numberOfActiveArms, x15$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x15CodeBased$expectedNumberOfSubjects, x15$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x15CodeBased$sampleSizes, x15$sampleSizes, tolerance = 1e-07)
+ expect_equal(x15CodeBased$conditionalPowerAchieved, x15$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x15), "character")
+ df <- as.data.frame(x15)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x15)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x16 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Sidak",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x16' with expected results
+ expect_equal(x16$iterations[1, ], c(10, 10, 10, 10), label = paste0(x16$iterations[1, ]))
+ expect_equal(x16$iterations[2, ], c(9, 9, 10, 10), label = paste0(x16$iterations[2, ]))
+ expect_equal(x16$iterations[3, ], c(7, 9, 10, 8), label = paste0(x16$iterations[3, ]))
+ expect_equal(x16$rejectAtLeastOne, c(0, 0.2, 0.6, 1), tolerance = 1e-07, label = paste0(x16$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x16$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0.2, 0, 0.2, 0.4, 0, 0, 0, 0, 0.1, 0.1, 0, 0.1, 0.1, 0, 0.7, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x16$rejectedArmsPerStage))))
+ expect_equal(x16$futilityStop, c(0.3, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x16$futilityStop))
+ expect_equal(x16$futilityPerStage[1, ], c(0.1, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x16$futilityPerStage[1, ]))
+ expect_equal(x16$futilityPerStage[2, ], c(0.2, 0, 0, 0), tolerance = 1e-07, label = paste0(x16$futilityPerStage[2, ]))
+ expect_equal(x16$earlyStop[1, ], c(0.1, 0.1, 0, 0), tolerance = 1e-07, label = paste0(x16$earlyStop[1, ]))
+ expect_equal(x16$earlyStop[2, ], c(0.2, 0, 0, 0.2), tolerance = 1e-07, label = paste0(x16$earlyStop[2, ]))
+ expect_equal(x16$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x16$successPerStage[1, ]))
+ expect_equal(x16$successPerStage[2, ], c(0, 0, 0, 0.2), tolerance = 1e-07, label = paste0(x16$successPerStage[2, ]))
+ expect_equal(x16$successPerStage[3, ], c(0, 0.1, 0.1, 0.3), tolerance = 1e-07, label = paste0(x16$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x16$selectedArms)), c(1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.6, 0.4, 1, 0.5, 0.5, 1, 0.2, 0.2, 1, 0.2, 0.1, 1, 0.4, 0.2, 1, 0.2, 0.2, 1, 0.6, 0.6, 1, 0.8, 0.6, 1, 0.4, 0.3, 1, 0.8, 0.8, 1, 0.8, 0.8, 1, 0.9, 0.8, 1, 0.9, 0.7, 1, 0.9, 0.9, 1, 1, 1, 1, 1, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x16$selectedArms))))
+ expect_equal(x16$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x16$numberOfActiveArms[1, ]))
+ expect_equal(x16$numberOfActiveArms[2, ], c(1.8888889, 1.8888889, 1.9, 2), tolerance = 1e-07, label = paste0(x16$numberOfActiveArms[2, ]))
+ expect_equal(x16$numberOfActiveArms[3, ], c(1.7142857, 1.8888889, 1.9, 2), tolerance = 1e-07, label = paste0(x16$numberOfActiveArms[3, ]))
+ expect_equal(x16$expectedNumberOfSubjects, c(465.5, 426.3, 413.1, 244.1), tolerance = 1e-07, label = paste0(x16$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x16$sampleSizes)), c(10, 20.555556, 42.857143, 10, 6.5555556, 22.222222, 10, 30, 1.2, 10, 2.2, 0.5, 10, 66.666667, 57.142857, 10, 42.111111, 55.555556, 10, 4.9, 13.9, 10, 14.1, 5, 10, 35.111111, 28.571429, 10, 11.777778, 1.5555556, 10, 44.7, 33.8, 10, 36.6, 21.75, 10, 41, 42.857143, 10, 63.333333, 68.222222, 10, 49.6, 57.3, 10, 32.9, 27.25, 10, 87.222222, 100, 10, 67.444444, 79.333333, 10, 69.6, 58.1, 10, 42.9, 27.25), tolerance = 1e-07, label = paste0(unlist(as.list(x16$sampleSizes))))
+ expect_equal(x16$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x16$conditionalPowerAchieved[1, ]))
+ expect_equal(x16$conditionalPowerAchieved[2, ], c(0.096913955, 0.09039929, 0.11243241, 0.1746525), tolerance = 1e-07, label = paste0(x16$conditionalPowerAchieved[2, ]))
+ expect_equal(x16$conditionalPowerAchieved[3, ], c(0.093425176, 0.41153932, 0.67843506, 0.87119979), tolerance = 1e-07, label = paste0(x16$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x16), NA)))
+ expect_output(print(x16)$show())
+ invisible(capture.output(expect_error(summary(x16), NA)))
+ expect_output(summary(x16)$show())
+ x16CodeBased <- eval(parse(text = getObjectRCode(x16, stringWrapParagraphWidth = NULL)))
+ expect_equal(x16CodeBased$iterations, x16$iterations, tolerance = 1e-07)
+ expect_equal(x16CodeBased$rejectAtLeastOne, x16$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x16CodeBased$rejectedArmsPerStage, x16$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$futilityStop, x16$futilityStop, tolerance = 1e-07)
+ expect_equal(x16CodeBased$futilityPerStage, x16$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$earlyStop, x16$earlyStop, tolerance = 1e-07)
+ expect_equal(x16CodeBased$successPerStage, x16$successPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$selectedArms, x16$selectedArms, tolerance = 1e-07)
+ expect_equal(x16CodeBased$numberOfActiveArms, x16$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x16CodeBased$expectedNumberOfSubjects, x16$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x16CodeBased$sampleSizes, x16$sampleSizes, tolerance = 1e-07)
+ expect_equal(x16CodeBased$conditionalPowerAchieved, x16$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x16), "character")
+ df <- as.data.frame(x16)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x16)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x17 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = rep(TRUE, 2), intersectionTest = "Simes",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x17' with expected results
+ expect_equal(x17$iterations[1, ], c(10, 10, 10, 10), label = paste0(x17$iterations[1, ]))
+ expect_equal(x17$iterations[2, ], c(9, 9, 8, 10), label = paste0(x17$iterations[2, ]))
+ expect_equal(x17$iterations[3, ], c(7, 8, 6, 5), label = paste0(x17$iterations[3, ]))
+ expect_equal(x17$rejectAtLeastOne, c(0, 0.3, 0.4, 0.8), tolerance = 1e-07, label = paste0(x17$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x17$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0.1, 0.4, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.3, 0, 0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x17$rejectedArmsPerStage))))
+ expect_equal(x17$futilityStop, c(0.3, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x17$futilityStop))
+ expect_equal(x17$futilityPerStage[1, ], c(0.1, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x17$futilityPerStage[1, ]))
+ expect_equal(x17$futilityPerStage[2, ], c(0.2, 0, 0, 0), tolerance = 1e-07, label = paste0(x17$futilityPerStage[2, ]))
+ expect_equal(x17$earlyStop[1, ], c(0.1, 0.1, 0.2, 0), tolerance = 1e-07, label = paste0(x17$earlyStop[1, ]))
+ expect_equal(x17$earlyStop[2, ], c(0.2, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0(x17$earlyStop[2, ]))
+ expect_equal(x17$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x17$successPerStage[1, ]))
+ expect_equal(x17$successPerStage[2, ], c(0, 0.1, 0.2, 0.5), tolerance = 1e-07, label = paste0(x17$successPerStage[2, ]))
+ expect_equal(x17$successPerStage[3, ], c(0, 0.1, 0.2, 0.3), tolerance = 1e-07, label = paste0(x17$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x17$selectedArms)), c(1, 0.3, 0.1, 1, 0.2, 0.1, 1, 0.1, 0, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.6, 0.4, 1, 0.3, 0.1, 1, 0.3, 0.1, 1, 0.3, 0.2, 1, 0.4, 0.4, 1, 0.4, 0.2, 1, 0.7, 0.3, 1, 0.4, 0.4, 1, 0.1, 0.1, 1, 0.7, 0.5, 1, 0.6, 0.2, 1, 0.9, 0.7, 1, 0.9, 0.8, 1, 0.8, 0.6, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x17$selectedArms))))
+ expect_equal(x17$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x17$numberOfActiveArms[1, ]))
+ expect_equal(x17$numberOfActiveArms[2, ], c(1.3333333, 1.4444444, 1.875, 1.7), tolerance = 1e-07, label = paste0(x17$numberOfActiveArms[2, ]))
+ expect_equal(x17$numberOfActiveArms[3, ], c(1.1428571, 1.25, 1.3333333, 1.4), tolerance = 1e-07, label = paste0(x17$numberOfActiveArms[3, ]))
+ expect_equal(x17$expectedNumberOfSubjects, c(339.9, 359.2, 222.7, 176), tolerance = 1e-07, label = paste0(x17$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x17$sampleSizes)), c(10, 31.333333, 14.285714, 10, 17.666667, 8.125, 10, 12.5, 0, 10, 1.2, 7.4, 10, 21.222222, 14.285714, 10, 35.888889, 50, 10, 25.625, 16.666667, 10, 13.6, 7.4, 10, 24.666667, 21.142857, 10, 33.222222, 50, 10, 31.5, 17.333333, 10, 26.2, 9.8, 10, 22.444444, 57.142857, 10, 5.1111111, 12.5, 10, 33, 19.833333, 10, 21.2, 12.2, 10, 67.333333, 92.571429, 10, 59.444444, 95.625, 10, 45.5, 36.5, 10, 34.4, 22), tolerance = 1e-07, label = paste0(unlist(as.list(x17$sampleSizes))))
+ expect_equal(x17$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x17$conditionalPowerAchieved[1, ]))
+ expect_equal(x17$conditionalPowerAchieved[2, ], c(0.039329058, 0.14668797, 0.16576057, 0.14296603), tolerance = 1e-07, label = paste0(x17$conditionalPowerAchieved[2, ]))
+ expect_equal(x17$conditionalPowerAchieved[3, ], c(0.28763166, 0.40839298, 0.6012117, 0.84313531), tolerance = 1e-07, label = paste0(x17$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x17), NA)))
+ expect_output(print(x17)$show())
+ invisible(capture.output(expect_error(summary(x17), NA)))
+ expect_output(summary(x17)$show())
+ x17CodeBased <- eval(parse(text = getObjectRCode(x17, stringWrapParagraphWidth = NULL)))
+ expect_equal(x17CodeBased$iterations, x17$iterations, tolerance = 1e-07)
+ expect_equal(x17CodeBased$rejectAtLeastOne, x17$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x17CodeBased$rejectedArmsPerStage, x17$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$futilityStop, x17$futilityStop, tolerance = 1e-07)
+ expect_equal(x17CodeBased$futilityPerStage, x17$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$earlyStop, x17$earlyStop, tolerance = 1e-07)
+ expect_equal(x17CodeBased$successPerStage, x17$successPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$selectedArms, x17$selectedArms, tolerance = 1e-07)
+ expect_equal(x17CodeBased$numberOfActiveArms, x17$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x17CodeBased$expectedNumberOfSubjects, x17$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x17CodeBased$sampleSizes, x17$sampleSizes, tolerance = 1e-07)
+ expect_equal(x17CodeBased$conditionalPowerAchieved, x17$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x17), "character")
+ df <- as.data.frame(x17)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x17)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x18 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Simes",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x18' with expected results
+ expect_equal(x18$iterations[1, ], c(10, 10, 10, 10), label = paste0(x18$iterations[1, ]))
+ expect_equal(x18$iterations[2, ], c(7, 8, 8, 10), label = paste0(x18$iterations[2, ]))
+ expect_equal(x18$iterations[3, ], c(7, 8, 7, 5), label = paste0(x18$iterations[3, ]))
+ expect_equal(x18$rejectAtLeastOne, c(0.1, 0.1, 0.3, 0.7), tolerance = 1e-07, label = paste0(x18$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x18$rejectedArmsPerStage)), c(0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0.2, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.1, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x18$rejectedArmsPerStage))))
+ expect_equal(x18$futilityStop, c(0.3, 0.2, 0.2, 0), tolerance = 1e-07, label = paste0(x18$futilityStop))
+ expect_equal(x18$futilityPerStage[1, ], c(0.3, 0.2, 0.2, 0), tolerance = 1e-07, label = paste0(x18$futilityPerStage[1, ]))
+ expect_equal(x18$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x18$futilityPerStage[2, ]))
+ expect_equal(x18$earlyStop[1, ], c(0.3, 0.2, 0.2, 0), tolerance = 1e-07, label = paste0(x18$earlyStop[1, ]))
+ expect_equal(x18$earlyStop[2, ], c(0, 0, 0.1, 0.5), tolerance = 1e-07, label = paste0(x18$earlyStop[2, ]))
+ expect_equal(x18$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x18$successPerStage[1, ]))
+ expect_equal(x18$successPerStage[2, ], c(0, 0, 0.1, 0.5), tolerance = 1e-07, label = paste0(x18$successPerStage[2, ]))
+ expect_equal(x18$successPerStage[3, ], c(0.1, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x18$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x18$selectedArms)), c(1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0, 0, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.4, 0.1, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.2, 0.1, 1, 0.3, 0.2, 1, 0.7, 0.7, 1, 0.8, 0.8, 1, 0.8, 0.7, 1, 1, 0.5), tolerance = 1e-07, label = paste0(unlist(as.list(x18$selectedArms))))
+ expect_equal(x18$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x18$numberOfActiveArms[1, ]))
+ expect_equal(x18$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x18$numberOfActiveArms[2, ]))
+ expect_equal(x18$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x18$numberOfActiveArms[3, ]))
+ expect_equal(x18$expectedNumberOfSubjects, c(241.6, 306.8, 235.2, 156), tolerance = 1e-07, label = paste0(x18$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x18$sampleSizes)), c(10, 27.285714, 27.285714, 10, 25, 25, 10, 0, 0, 10, 2.6, 4.4, 10, 16.142857, 16.142857, 10, 16, 16, 10, 3.5, 4, 10, 1.4, 2.8, 10, 14.285714, 14.285714, 10, 12.5, 12.5, 10, 40.875, 46.571429, 10, 15.8, 5.2, 10, 10.714286, 10.714286, 10, 26.75, 26.75, 10, 19.875, 8.2857143, 10, 18.6, 16.8, 10, 68.428571, 68.428571, 10, 80.25, 80.25, 10, 64.25, 58.857143, 10, 38.4, 29.2), tolerance = 1e-07, label = paste0(unlist(as.list(x18$sampleSizes))))
+ expect_equal(x18$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x18$conditionalPowerAchieved[1, ]))
+ expect_equal(x18$conditionalPowerAchieved[2, ], c(0.064400041, 0.012818439, 0.075196936, 0.13824332), tolerance = 1e-07, label = paste0(x18$conditionalPowerAchieved[2, ]))
+ expect_equal(x18$conditionalPowerAchieved[3, ], c(0.066989319, 0.23112098, 0.45267281, 0.52012057), tolerance = 1e-07, label = paste0(x18$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x18), NA)))
+ expect_output(print(x18)$show())
+ invisible(capture.output(expect_error(summary(x18), NA)))
+ expect_output(summary(x18)$show())
+ x18CodeBased <- eval(parse(text = getObjectRCode(x18, stringWrapParagraphWidth = NULL)))
+ expect_equal(x18CodeBased$iterations, x18$iterations, tolerance = 1e-07)
+ expect_equal(x18CodeBased$rejectAtLeastOne, x18$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x18CodeBased$rejectedArmsPerStage, x18$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$futilityStop, x18$futilityStop, tolerance = 1e-07)
+ expect_equal(x18CodeBased$futilityPerStage, x18$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$earlyStop, x18$earlyStop, tolerance = 1e-07)
+ expect_equal(x18CodeBased$successPerStage, x18$successPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$selectedArms, x18$selectedArms, tolerance = 1e-07)
+ expect_equal(x18CodeBased$numberOfActiveArms, x18$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x18CodeBased$expectedNumberOfSubjects, x18$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x18CodeBased$sampleSizes, x18$sampleSizes, tolerance = 1e-07)
+ expect_equal(x18CodeBased$conditionalPowerAchieved, x18$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x18), "character")
+ df <- as.data.frame(x18)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x18)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x19 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "all",
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Simes",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x19' with expected results
+ expect_equal(x19$iterations[1, ], c(10, 10, 10, 10), label = paste0(x19$iterations[1, ]))
+ expect_equal(x19$iterations[2, ], c(8, 8, 10, 10), label = paste0(x19$iterations[2, ]))
+ expect_equal(x19$iterations[3, ], c(8, 8, 9, 9), label = paste0(x19$iterations[3, ]))
+ expect_equal(x19$rejectAtLeastOne, c(0, 0, 0.9, 1), tolerance = 1e-07, label = paste0(x19$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x19$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.2, 0, 0.4, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.5, 0.1, 0, 0.6, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.8, 0.1, 0, 0.7, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x19$rejectedArmsPerStage))))
+ expect_equal(x19$futilityStop, c(0.2, 0.2, 0, 0), tolerance = 1e-07, label = paste0(x19$futilityStop))
+ expect_equal(x19$futilityPerStage[1, ], c(0.2, 0.2, 0, 0), tolerance = 1e-07, label = paste0(x19$futilityPerStage[1, ]))
+ expect_equal(x19$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x19$futilityPerStage[2, ]))
+ expect_equal(x19$earlyStop[1, ], c(0.2, 0.2, 0, 0), tolerance = 1e-07, label = paste0(x19$earlyStop[1, ]))
+ expect_equal(x19$earlyStop[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x19$earlyStop[2, ]))
+ expect_equal(x19$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x19$successPerStage[1, ]))
+ expect_equal(x19$successPerStage[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x19$successPerStage[2, ]))
+ expect_equal(x19$successPerStage[3, ], c(0, 0, 0.1, 0.2), tolerance = 1e-07, label = paste0(x19$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x19$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.8, 0.8, 1, 0.6, 0.6, 1, 0.5, 0.5, 1, 0.6, 0.6, 1, 0.7, 0.6, 1, 0.9, 0.8, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.9, 0.8, 1, 0.8, 0.7, 1, 0.6, 0.6, 1, 0.5, 0.5, 1, 0.9, 0.8, 1, 0.8, 0.7, 1, 0.8, 0.8, 1, 0.8, 0.8, 1, 1, 0.9, 1, 1, 0.9), tolerance = 1e-07, label = paste0(unlist(as.list(x19$selectedArms))))
+ expect_equal(x19$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x19$numberOfActiveArms[1, ]))
+ expect_equal(x19$numberOfActiveArms[2, ], c(2.375, 2.375, 3.3, 3.1), tolerance = 1e-07, label = paste0(x19$numberOfActiveArms[2, ]))
+ expect_equal(x19$numberOfActiveArms[3, ], c(2.375, 2.375, 3.3333333, 3.1111111), tolerance = 1e-07, label = paste0(x19$numberOfActiveArms[3, ]))
+ expect_equal(x19$expectedNumberOfSubjects, c(523.8, 590, 818.4, 765.4), tolerance = 1e-07, label = paste0(x19$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x19$sampleSizes)), c(10, 28.125, 28.125, 10, 37.5, 37.5, 10, 73.6, 81.666667, 10, 55.2, 61.333333, 10, 58.625, 58.625, 10, 75, 75, 10, 70, 66.666667, 10, 85.2, 83.555556, 10, 53.125, 53.125, 10, 62.5, 62.5, 10, 83.6, 81.666667, 10, 71.1, 67.777778, 10, 65.625, 65.625, 10, 62.5, 62.5, 10, 83.6, 81.666667, 10, 75.2, 72.444444, 10, 90.625, 90.625, 10, 100, 100, 10, 93.6, 92.777778, 10, 91.1, 90), tolerance = 1e-07, label = paste0(unlist(as.list(x19$sampleSizes))))
+ expect_equal(x19$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x19$conditionalPowerAchieved[1, ]))
+ expect_equal(x19$conditionalPowerAchieved[2, ], c(0.10081958, 0.049714416, 0.18629752, 0.24626925), tolerance = 1e-07, label = paste0(x19$conditionalPowerAchieved[2, ]))
+ expect_equal(x19$conditionalPowerAchieved[3, ], c(0.088506618, 0.13049081, 0.60815392, 0.85577973), tolerance = 1e-07, label = paste0(x19$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x19), NA)))
+ expect_output(print(x19)$show())
+ invisible(capture.output(expect_error(summary(x19), NA)))
+ expect_output(summary(x19)$show())
+ x19CodeBased <- eval(parse(text = getObjectRCode(x19, stringWrapParagraphWidth = NULL)))
+ expect_equal(x19CodeBased$iterations, x19$iterations, tolerance = 1e-07)
+ expect_equal(x19CodeBased$rejectAtLeastOne, x19$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x19CodeBased$rejectedArmsPerStage, x19$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$futilityStop, x19$futilityStop, tolerance = 1e-07)
+ expect_equal(x19CodeBased$futilityPerStage, x19$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$earlyStop, x19$earlyStop, tolerance = 1e-07)
+ expect_equal(x19CodeBased$successPerStage, x19$successPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$selectedArms, x19$selectedArms, tolerance = 1e-07)
+ expect_equal(x19CodeBased$numberOfActiveArms, x19$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x19CodeBased$expectedNumberOfSubjects, x19$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x19CodeBased$sampleSizes, x19$sampleSizes, tolerance = 1e-07)
+ expect_equal(x19CodeBased$conditionalPowerAchieved, x19$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x19), "character")
+ df <- as.data.frame(x19)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x19)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x20 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "rBest", rValue = 2,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x20' with expected results
+ expect_equal(x20$iterations[1, ], c(10, 10, 10, 10), label = paste0(x20$iterations[1, ]))
+ expect_equal(x20$iterations[2, ], c(7, 7, 9, 10), label = paste0(x20$iterations[2, ]))
+ expect_equal(x20$iterations[3, ], c(2, 5, 3, 1), label = paste0(x20$iterations[3, ]))
+ expect_equal(x20$rejectAtLeastOne, c(0, 0, 0.2, 0), tolerance = 1e-07, label = paste0(x20$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x20$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x20$rejectedArmsPerStage))))
+ expect_equal(x20$futilityStop, c(0.8, 0.5, 0.6, 0.9), tolerance = 1e-07, label = paste0(x20$futilityStop))
+ expect_equal(x20$futilityPerStage[1, ], c(0.3, 0.3, 0.1, 0), tolerance = 1e-07, label = paste0(x20$futilityPerStage[1, ]))
+ expect_equal(x20$futilityPerStage[2, ], c(0.5, 0.2, 0.5, 0.9), tolerance = 1e-07, label = paste0(x20$futilityPerStage[2, ]))
+ expect_equal(x20$earlyStop[1, ], c(0.3, 0.3, 0.1, 0), tolerance = 1e-07, label = paste0(x20$earlyStop[1, ]))
+ expect_equal(x20$earlyStop[2, ], c(0.5, 0.2, 0.6, 0.9), tolerance = 1e-07, label = paste0(x20$earlyStop[2, ]))
+ expect_equal(x20$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[1, ]))
+ expect_equal(x20$successPerStage[2, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0(x20$successPerStage[2, ]))
+ expect_equal(x20$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x20$selectedArms)), c(1, 0.2, 0.2, 1, 0.5, 0.5, 1, 0.4, 0.3, 1, 0.1, 0.1, 1, 0.3, 0.1, 1, 0.2, 0, 1, 0.1, 0, 1, 0.4, 0, 1, 0.2, 0, 1, 0.3, 0.3, 1, 0.5, 0.1, 1, 0.8, 0, 1, 0.5, 0.1, 1, 0.4, 0.2, 1, 0.6, 0.2, 1, 0.7, 0.1, 1, 0.7, 0.2, 1, 0.7, 0.5, 1, 0.9, 0.3, 1, 1, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x20$selectedArms))))
+ expect_equal(x20$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x20$numberOfActiveArms[1, ]))
+ expect_equal(x20$numberOfActiveArms[2, ], c(1.7142857, 2, 1.7777778, 2), tolerance = 1e-07, label = paste0(x20$numberOfActiveArms[2, ]))
+ expect_equal(x20$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x20$numberOfActiveArms[3, ]))
+ expect_equal(x20$expectedNumberOfSubjects, c(267.3, 301.1, 325.2, 315.5), tolerance = 1e-07, label = paste0(x20$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x20$sampleSizes)), c(10, 24.142857, 84.5, 10, 51.714286, 72.2, 10, 39, 83.333333, 10, 8.8, 88, 10, 36.142857, 50, 10, 16.285714, 0, 10, 4.1111111, 0, 10, 28.2, 0, 10, 28.571429, 0, 10, 30.142857, 42.2, 10, 42.555556, 33.333333, 10, 60.9, 0, 10, 60.285714, 34.5, 10, 37.857143, 30, 10, 55.222222, 50, 10, 61.5, 88, 10, 88.857143, 84.5, 10, 68, 72.2, 10, 81.555556, 83.333333, 10, 79.7, 88), tolerance = 1e-07, label = paste0(unlist(as.list(x20$sampleSizes))))
+ expect_equal(x20$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x20$conditionalPowerAchieved[1, ]))
+ expect_equal(x20$conditionalPowerAchieved[2, ], c(0.14688077, 0.19244817, 0.083030211, 0.1268121), tolerance = 1e-07, label = paste0(x20$conditionalPowerAchieved[2, ]))
+ expect_equal(x20$conditionalPowerAchieved[3, ], c(0.021357961, 0.35341345, 0.67128636, 1), tolerance = 1e-07, label = paste0(x20$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x20), NA)))
+ expect_output(print(x20)$show())
+ invisible(capture.output(expect_error(summary(x20), NA)))
+ expect_output(summary(x20)$show())
+ x20CodeBased <- eval(parse(text = getObjectRCode(x20, stringWrapParagraphWidth = NULL)))
+ expect_equal(x20CodeBased$iterations, x20$iterations, tolerance = 1e-07)
+ expect_equal(x20CodeBased$rejectAtLeastOne, x20$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x20CodeBased$rejectedArmsPerStage, x20$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$futilityStop, x20$futilityStop, tolerance = 1e-07)
+ expect_equal(x20CodeBased$futilityPerStage, x20$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$earlyStop, x20$earlyStop, tolerance = 1e-07)
+ expect_equal(x20CodeBased$successPerStage, x20$successPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$selectedArms, x20$selectedArms, tolerance = 1e-07)
+ expect_equal(x20CodeBased$numberOfActiveArms, x20$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x20CodeBased$expectedNumberOfSubjects, x20$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x20CodeBased$sampleSizes, x20$sampleSizes, tolerance = 1e-07)
+ expect_equal(x20CodeBased$conditionalPowerAchieved, x20$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x20), "character")
+ df <- as.data.frame(x20)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x20)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x21 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1),
+ adaptations = c(TRUE, FALSE), intersectionTest = "Hierarchical",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x21' with expected results
+ expect_equal(x21$iterations[1, ], c(10, 10, 10, 10), label = paste0(x21$iterations[1, ]))
+ expect_equal(x21$iterations[2, ], c(9, 9, 9, 10), label = paste0(x21$iterations[2, ]))
+ expect_equal(x21$iterations[3, ], c(2, 4, 4, 2), label = paste0(x21$iterations[3, ]))
+ expect_equal(x21$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x21$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x21$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x21$rejectedArmsPerStage))))
+ expect_equal(x21$futilityStop, c(0.8, 0.6, 0.6, 0.8), tolerance = 1e-07, label = paste0(x21$futilityStop))
+ expect_equal(x21$futilityPerStage[1, ], c(0.1, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x21$futilityPerStage[1, ]))
+ expect_equal(x21$futilityPerStage[2, ], c(0.7, 0.5, 0.5, 0.8), tolerance = 1e-07, label = paste0(x21$futilityPerStage[2, ]))
+ expect_equal(x21$earlyStop[1, ], c(0.1, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x21$earlyStop[1, ]))
+ expect_equal(x21$earlyStop[2, ], c(0.7, 0.5, 0.5, 0.8), tolerance = 1e-07, label = paste0(x21$earlyStop[2, ]))
+ expect_equal(x21$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[1, ]))
+ expect_equal(x21$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[2, ]))
+ expect_equal(x21$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x21$selectedArms)), c(1, 0.2, 0.2, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.2, 0, 1, 0.2, 0.1, 1, 0.3, 0.1, 1, 0.4, 0.1, 1, 0.5, 0.1, 1, 0.5, 0.2, 1, 0.2, 0.2, 1, 0.7, 0.1, 1, 0.4, 0, 1, 0.2, 0, 1, 0.7, 0.3, 1, 0.9, 0.2, 1, 0.9, 0.2, 1, 0.9, 0.4, 1, 0.9, 0.4, 1, 1, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x21$selectedArms))))
+ expect_equal(x21$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x21$numberOfActiveArms[1, ]))
+ expect_equal(x21$numberOfActiveArms[2, ], c(1.4444444, 1.4444444, 1.7777778, 2.2), tolerance = 1e-07, label = paste0(x21$numberOfActiveArms[2, ]))
+ expect_equal(x21$numberOfActiveArms[3, ], c(1.5, 1.75, 2.5, 3), tolerance = 1e-07, label = paste0(x21$numberOfActiveArms[3, ]))
+ expect_equal(x21$expectedNumberOfSubjects, c(240.6, 332.2, 346.2, 256.5), tolerance = 1e-07, label = paste0(x21$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x21$sampleSizes)), c(10, 17.666667, 79, 10, 39.222222, 88.25, 10, 35.777778, 80.25, 10, 7.9, 39, 10, 13.555556, 0, 10, 22.222222, 25, 10, 24.666667, 5.25, 10, 17.7, 25, 10, 42.333333, 50, 10, 47.555556, 50, 10, 22.222222, 50, 10, 44.9, 25, 10, 27.111111, 0, 10, 14.111111, 0, 10, 51.888889, 55.25, 10, 50.7, 39, 10, 64.888889, 79, 10, 78.666667, 88.25, 10, 74.111111, 80.25, 10, 51.9, 39), tolerance = 1e-07, label = paste0(unlist(as.list(x21$sampleSizes))))
+ expect_equal(x21$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x21$conditionalPowerAchieved[1, ]))
+ expect_equal(x21$conditionalPowerAchieved[2, ], c(0.071382822, 0.0014758747, 0.067299064, 0.14413714), tolerance = 1e-07, label = paste0(x21$conditionalPowerAchieved[2, ]))
+ expect_equal(x21$conditionalPowerAchieved[3, ], c(0.29927137, 0.0060466075, 0.55383829, 0.59417789), tolerance = 1e-07, label = paste0(x21$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x21), NA)))
+ expect_output(print(x21)$show())
+ invisible(capture.output(expect_error(summary(x21), NA)))
+ expect_output(summary(x21)$show())
+ x21CodeBased <- eval(parse(text = getObjectRCode(x21, stringWrapParagraphWidth = NULL)))
+ expect_equal(x21CodeBased$iterations, x21$iterations, tolerance = 1e-07)
+ expect_equal(x21CodeBased$rejectAtLeastOne, x21$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x21CodeBased$rejectedArmsPerStage, x21$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$futilityStop, x21$futilityStop, tolerance = 1e-07)
+ expect_equal(x21CodeBased$futilityPerStage, x21$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$earlyStop, x21$earlyStop, tolerance = 1e-07)
+ expect_equal(x21CodeBased$successPerStage, x21$successPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$selectedArms, x21$selectedArms, tolerance = 1e-07)
+ expect_equal(x21CodeBased$numberOfActiveArms, x21$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x21CodeBased$expectedNumberOfSubjects, x21$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x21CodeBased$sampleSizes, x21$sampleSizes, tolerance = 1e-07)
+ expect_equal(x21CodeBased$conditionalPowerAchieved, x21$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x21), "character")
+ df <- as.data.frame(x21)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x21)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x22 <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, threshold = 0.1, plannedSubjects = c(10, 30, 50), piControl = 0.3,
+ piMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Hierarchical",
+ conditionalPower = 0.8, minNumberOfSubjectsPerStage = c(10, 4, 4),
+ maxNumberOfSubjectsPerStage = c(10, 100, 100), directionUpper = FALSE,
+ maxNumberOfIterations = 1
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x22' with expected results
+ expect_equal(x22$iterations[1, ], c(1, 1, 1), label = paste0(x22$iterations[1, ]))
+ expect_equal(x22$iterations[2, ], c(0, 1, 0), label = paste0(x22$iterations[2, ]))
+ expect_equal(x22$iterations[3, ], c(0, 0, 0), label = paste0(x22$iterations[3, ]))
+ expect_equal(x22$rejectAtLeastOne, c(0, 0, 0), label = paste0(x22$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x22$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x22$rejectedArmsPerStage))))
+ expect_equal(x22$futilityStop, c(1, 1, 1), label = paste0(x22$futilityStop))
+ expect_equal(x22$futilityPerStage[1, ], c(1, 0, 1), label = paste0(x22$futilityPerStage[1, ]))
+ expect_equal(x22$futilityPerStage[2, ], c(0, 1, 0), label = paste0(x22$futilityPerStage[2, ]))
+ expect_equal(x22$earlyStop[1, ], c(1, 0, 1), label = paste0(x22$earlyStop[1, ]))
+ expect_equal(x22$earlyStop[2, ], c(0, 1, 0), label = paste0(x22$earlyStop[2, ]))
+ expect_equal(x22$successPerStage[1, ], c(0, 0, 0), label = paste0(x22$successPerStage[1, ]))
+ expect_equal(x22$successPerStage[2, ], c(0, 0, 0), label = paste0(x22$successPerStage[2, ]))
+ expect_equal(x22$successPerStage[3, ], c(0, 0, 0), label = paste0(x22$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x22$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0), label = paste0(unlist(as.list(x22$selectedArms))))
+ expect_equal(x22$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0(x22$numberOfActiveArms[1, ]))
+ expect_equal(x22$numberOfActiveArms[2, ], c(NaN, 1, NaN), label = paste0(x22$numberOfActiveArms[2, ]))
+ expect_equal(x22$numberOfActiveArms[3, ], c(NaN, NaN, NaN), label = paste0(x22$numberOfActiveArms[3, ]))
+ expect_equal(x22$expectedNumberOfSubjects, c(NaN, NaN, NaN), label = paste0(x22$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x22$sampleSizes)), c(10, 0, 0, 10, 0, 0, 10, NaN, NaN, 10, 0, 0, 10, 0, 0, 10, NaN, NaN, 10, 0, 0, 10, 91, 0, 10, NaN, NaN, 10, 0, 0, 10, 0, 0, 10, NaN, NaN, 10, 0, 0, 10, 91, 0, 10, NaN, NaN), label = paste0(unlist(as.list(x22$sampleSizes))))
+ expect_equal(x22$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x22$conditionalPowerAchieved[1, ]))
+ expect_equal(x22$conditionalPowerAchieved[2, ], c(NaN, 3.7427402e-05, NaN), tolerance = 1e-07, label = paste0(x22$conditionalPowerAchieved[2, ]))
+ expect_equal(x22$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN), label = paste0(x22$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x22), NA)))
+ expect_output(print(x22)$show())
+ invisible(capture.output(expect_error(summary(x22), NA)))
+ expect_output(summary(x22)$show())
+ x22CodeBased <- eval(parse(text = getObjectRCode(x22, stringWrapParagraphWidth = NULL)))
+ expect_equal(x22CodeBased$iterations, x22$iterations, tolerance = 1e-07)
+ expect_equal(x22CodeBased$rejectAtLeastOne, x22$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x22CodeBased$rejectedArmsPerStage, x22$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$futilityStop, x22$futilityStop, tolerance = 1e-07)
+ expect_equal(x22CodeBased$futilityPerStage, x22$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$earlyStop, x22$earlyStop, tolerance = 1e-07)
+ expect_equal(x22CodeBased$successPerStage, x22$successPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$selectedArms, x22$selectedArms, tolerance = 1e-07)
+ expect_equal(x22CodeBased$numberOfActiveArms, x22$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x22CodeBased$expectedNumberOfSubjects, x22$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x22CodeBased$sampleSizes, x22$sampleSizes, tolerance = 1e-07)
+ expect_equal(x22CodeBased$conditionalPowerAchieved, x22$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x22), "character")
+ df <- as.data.frame(x22)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x22)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmRates': using calcSubjectsFunction", {
-
- .skipTestIfDisabled()
- .skipTestIfNotX64()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
- # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- calcSubjectsFunctionSimulationMultiArmRates <- function(..., stage, minNumberOfSubjectsPerStage) {
- return(ifelse(stage == 3, 33, minNumberOfSubjectsPerStage[stage]))
- }
-
- x <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4,
- plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10, calcSubjectsFunction = calcSubjectsFunctionSimulationMultiArmRates
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x' with expected results
- expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(10, 10, 10, 9), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0, 0, 1, 0.1, 0.1, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.6, 0.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(124, 124, 124, 117.4), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(10, 0.4, 3.3, 10, 1.6, 13.2, 10, 0, 0, 10, 0.4, 3.6666667, 10, 0, 0, 10, 0.4, 3.3, 10, 1.6, 13.2, 10, 0.8, 7.3333333, 10, 1.2, 9.9, 10, 0.8, 6.6, 10, 0.8, 6.6, 10, 0.4, 3.6666667, 10, 2.4, 19.8, 10, 1.2, 9.9, 10, 1.6, 13.2, 10, 2.4, 18.333333, 10, 4, 33, 10, 4, 33, 10, 4, 33, 10, 4, 33), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.012189382, 0.016190277, 0.020380353, 0.11925746), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.32488024, 0.34652134, 0.40081174, 0.68872913), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+ .skipTestIfNotX64()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ calcSubjectsFunctionSimulationMultiArmRates <- function(..., stage, minNumberOfSubjectsPerStage) {
+ return(ifelse(stage == 3, 33, minNumberOfSubjectsPerStage[stage]))
+ }
+
+ x <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), piControl = 0.3, piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ minNumberOfSubjectsPerStage = c(10, 4, 4), maxNumberOfSubjectsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10, calcSubjectsFunction = calcSubjectsFunctionSimulationMultiArmRates
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(10, 10, 10, 9), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0, 0, 0.2, 0.4), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0.1, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0, 0.2, 0.3), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0, 0, 1, 0.1, 0.1, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.4, 0.4, 1, 0.6, 0.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(124, 124, 124, 117.4), tolerance = 1e-07, label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(10, 0.4, 3.3, 10, 1.6, 13.2, 10, 0, 0, 10, 0.4, 3.6666667, 10, 0, 0, 10, 0.4, 3.3, 10, 1.6, 13.2, 10, 0.8, 7.3333333, 10, 1.2, 9.9, 10, 0.8, 6.6, 10, 0.8, 6.6, 10, 0.4, 3.6666667, 10, 2.4, 19.8, 10, 1.2, 9.9, 10, 1.6, 13.2, 10, 2.4, 18.333333, 10, 4, 33, 10, 4, 33, 10, 4, 33, 10, 4, 33), tolerance = 1e-07, label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.012189382, 0.016190277, 0.020380353, 0.11925746), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.32488024, 0.34652134, 0.40081174, 0.68872913), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmRates': using selectArmsFunction", {
-
- .skipTestIfDisabled()
- .skipTestIfNotX64()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
- # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- selectArmsFunctionSimulationMultiArmRates <- function(effectSizes) {
- return(c(TRUE, FALSE, FALSE, FALSE))
- }
-
- x <- getSimulationMultiArmRates(
- seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4,
- plannedSubjects = c(10, 30, 50), piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- maxNumberOfIterations = 10, selectArmsFunction = selectArmsFunctionSimulationMultiArmRates, typeOfSelection = "userDefined"
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x' with expected results
- expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(10, 10, 10, 9), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0, 0, 0.1, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(130, 130, 130, 126), label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20), label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.044616119, 0.11264062, 0.1248477, 0.43958255), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.087582974, 0.1172724, 0.15105487, 0.4331775), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+ .skipTestIfNotX64()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ selectArmsFunctionSimulationMultiArmRates <- function(effectSizes) {
+ return(c(TRUE, FALSE, FALSE, FALSE))
+ }
+
+ x <- getSimulationMultiArmRates(
+ seed = 1234, getDesignFisher(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4,
+ plannedSubjects = c(10, 30, 50), piMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ maxNumberOfIterations = 10, selectArmsFunction = selectArmsFunctionSimulationMultiArmRates, typeOfSelection = "userDefined"
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(10, 10, 10, 9), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0, 0, 0.1, 0.4), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.4, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0, 0.1, 0), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(130, 130, 130, 126), label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 0, 0, 10, 20, 20, 10, 20, 20, 10, 20, 20, 10, 20, 20), label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.044616119, 0.11264062, 0.1248477, 0.43958255), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.087582974, 0.1172724, 0.15105487, 0.4331775), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmRates': typeOfShape = sigmoidEmax", {
-
- .skipTestIfDisabled()
- .skipTestIfNotX64()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
- # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- designIN <- getDesignInverseNormal(typeOfDesign = "P", kMax = 3, futilityBounds = c(0, 0))
- x <- getSimulationMultiArmRates(designIN,
- activeArms = 3, typeOfShape = "sigmoidEmax",
- piMaxVector = seq(0.1, 0.9, 0.2), gED50 = 2, plannedSubjects = cumsum(rep(20, 3)), piControl = 0.1,
- intersectionTest = "Sidak", typeOfSelection = "rBest", rValue = 2, threshold = -Inf,
- successCriterion = "all", maxNumberOfIterations = 100, seed = 3456
- )
-
- ## Comparison of the results of SimulationResultsMultiArmRates object 'x' with expected results
- expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(20, 60, 88, 84, 81), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(4, 45, 70, 38, 20), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0, 0.07, 0.55, 0.89, 0.99), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.03, 0.02, 0.01, 0.11, 0.11, 0.05, 0.19, 0.06, 0.03, 0, 0, 0, 0, 0.01, 0.03, 0.07, 0.1, 0.13, 0.3, 0.22, 0.14, 0.45, 0.3, 0.12, 0, 0, 0, 0.01, 0.03, 0.01, 0.11, 0.23, 0.18, 0.41, 0.32, 0.09, 0.62, 0.31, 0.04), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0.96, 0.54, 0.13, 0.05, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0.8, 0.4, 0.11, 0.05, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0.16, 0.14, 0.02, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0.8, 0.4, 0.12, 0.16, 0.19), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.16, 0.15, 0.18, 0.46, 0.61), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0.01, 0.11, 0.19), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0.01, 0.16, 0.46, 0.61), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0.01, 0.15, 0.18, 0.14), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.11, 0.01, 1, 0.24, 0.17, 1, 0.26, 0.2, 1, 0.24, 0.14, 1, 0.14, 0.08, 1, 0.13, 0.03, 1, 0.44, 0.34, 1, 0.7, 0.55, 1, 0.69, 0.31, 1, 0.69, 0.13, 1, 0.16, 0.04, 1, 0.52, 0.39, 1, 0.8, 0.65, 1, 0.75, 0.31, 1, 0.79, 0.19, 1, 0.2, 0.04, 1, 0.6, 0.45, 1, 0.88, 0.7, 1, 0.84, 0.38, 1, 0.81, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(3, 3, 3, 3, 3), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(2, 2, 2, 2, 2), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(2, 2, 2, 2, 2), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfSubjects, c(94.4, 143, 174.8, 153.2, 140.6), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$sampleSizes)), c(20, 11, 5, 20, 8, 7.5555556, 20, 5.9090909, 5.7142857, 20, 5.7142857, 7.3684211, 20, 3.4567901, 8, 20, 13, 15, 20, 14.666667, 15.111111, 20, 15.909091, 15.714286, 20, 16.428571, 16.315789, 20, 17.037037, 13, 20, 16, 20, 20, 17.333333, 17.333333, 20, 18.181818, 18.571429, 20, 17.857143, 16.315789, 20, 19.506173, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$sampleSizes)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.011866207, 0.085418744, 0.23090361, 0.47460917, 0.65183497), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.02497337, 0.151524, 0.4525101, 0.68922536, 0.80573911), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
- expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+ .skipTestIfNotX64()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ designIN <- getDesignInverseNormal(typeOfDesign = "P", kMax = 3, futilityBounds = c(0, 0))
+ x <- getSimulationMultiArmRates(designIN,
+ activeArms = 3, typeOfShape = "sigmoidEmax",
+ piMaxVector = seq(0.1, 0.9, 0.2), gED50 = 2, plannedSubjects = cumsum(rep(20, 3)), piControl = 0.1,
+ intersectionTest = "Sidak", typeOfSelection = "rBest", rValue = 2, threshold = -Inf,
+ successCriterion = "all", maxNumberOfIterations = 100, seed = 3456
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmRates object 'x' with expected results
+ expect_equal(x$iterations[1, ], c(100, 100, 100, 100, 100), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(20, 60, 88, 84, 81), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(4, 45, 70, 38, 20), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0, 0.07, 0.55, 0.89, 0.99), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0.03, 0.02, 0.01, 0.11, 0.11, 0.05, 0.19, 0.06, 0.03, 0, 0, 0, 0, 0.01, 0.03, 0.07, 0.1, 0.13, 0.3, 0.22, 0.14, 0.45, 0.3, 0.12, 0, 0, 0, 0.01, 0.03, 0.01, 0.11, 0.23, 0.18, 0.41, 0.32, 0.09, 0.62, 0.31, 0.04), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0.96, 0.54, 0.13, 0.05, 0), tolerance = 1e-07, label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0.8, 0.4, 0.11, 0.05, 0), tolerance = 1e-07, label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0.16, 0.14, 0.02, 0, 0), tolerance = 1e-07, label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0.8, 0.4, 0.12, 0.16, 0.19), tolerance = 1e-07, label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.16, 0.15, 0.18, 0.46, 0.61), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0.01, 0.11, 0.19), tolerance = 1e-07, label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0.01, 0.16, 0.46, 0.61), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0.01, 0.15, 0.18, 0.14), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.11, 0.01, 1, 0.24, 0.17, 1, 0.26, 0.2, 1, 0.24, 0.14, 1, 0.14, 0.08, 1, 0.13, 0.03, 1, 0.44, 0.34, 1, 0.7, 0.55, 1, 0.69, 0.31, 1, 0.69, 0.13, 1, 0.16, 0.04, 1, 0.52, 0.39, 1, 0.8, 0.65, 1, 0.75, 0.31, 1, 0.79, 0.19, 1, 0.2, 0.04, 1, 0.6, 0.45, 1, 0.88, 0.7, 1, 0.84, 0.38, 1, 0.81, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(3, 3, 3, 3, 3), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(2, 2, 2, 2, 2), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(2, 2, 2, 2, 2), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfSubjects, c(94.4, 143, 174.8, 153.2, 140.6), tolerance = 1e-07, label = paste0(x$expectedNumberOfSubjects))
+ expect_equal(unlist(as.list(x$sampleSizes)), c(20, 11, 5, 20, 8, 7.5555556, 20, 5.9090909, 5.7142857, 20, 5.7142857, 7.3684211, 20, 3.4567901, 8, 20, 13, 15, 20, 14.666667, 15.111111, 20, 15.909091, 15.714286, 20, 16.428571, 16.315789, 20, 17.037037, 13, 20, 16, 20, 20, 17.333333, 17.333333, 20, 18.181818, 18.571429, 20, 17.857143, 16.315789, 20, 19.506173, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20), tolerance = 1e-07, label = paste0(unlist(as.list(x$sampleSizes))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.011866207, 0.085418744, 0.23090361, 0.47460917, 0.65183497), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.02497337, 0.151524, 0.4525101, 0.68922536, 0.80573911), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfSubjects, x$expectedNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(xCodeBased$sampleSizes, x$sampleSizes, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmRates': comparison of base and multi-arm", {
-
- .skipTestIfDisabled()
- .skipTestIfNotX64()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
- # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- allocationRatioPlanned <- 2
- design <- getDesignInverseNormal(
- typeOfDesign = "WT", deltaWT = 0.15,
- futilityBounds = c(-0.5, 0.5), informationRates = c(0.2, 0.8, 1)
- )
-
- x <- getSimulationMultiArmRates(design,
- activeArms = 1, plannedSubjects = c(20, 40, 60),
- directionUpper = FALSE, piControl = 0.6, piMaxVector = seq(0.3, 0.6, 0.1),
- conditionalPower = 0.6, minNumberOfSubjectsPerStage = c(NA, 20, 20), maxNumberOfSubjectsPerStage = c(NA, 80, 80),
- piControlH1 = 0.4,
- piTreatmentsH1 = 0.3,
- maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 1234
- )
-
- y <- getSimulationRates(design,
- plannedSubjects = round((1 + 1 / allocationRatioPlanned) * c(20, 40, 60)),
- normalApproximation = TRUE, pi2 = 0.6, pi1 = seq(0.3, 0.6, 0.1), directionUpper = FALSE,
- conditionalPower = 0.6,
- pi2H1 = 0.4,
- pi1H1 = 0.3,
- minNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 20, 20)),
- maxNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 80, 80)),
- maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 1234
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(-0.03, -0.02, 0.09, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(0.09, -0.01, 0.06, 0.02), tolerance = 1e-07, label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(-0.12, -0.01, 0.03, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(0.04, 0.04, -0.12, -0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(0.01, 0.02, -0.05, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(1.1, 0.3, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(-44.7, 9.7, 1.3, -3.2), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(-14.6, -6.6, 26.9, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(-0.96, -0.39, -0.75, -0.06), tolerance = 1e-07, label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(0.1, -0.16, -0.38, -0.43), tolerance = 1e-07, label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
-
+ .skipTestIfDisabled()
+ .skipTestIfNotX64()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ allocationRatioPlanned <- 2
+ design <- getDesignInverseNormal(
+ typeOfDesign = "WT", deltaWT = 0.15,
+ futilityBounds = c(-0.5, 0.5), informationRates = c(0.2, 0.8, 1)
+ )
+
+ x <- getSimulationMultiArmRates(design,
+ activeArms = 1, plannedSubjects = c(20, 40, 60),
+ directionUpper = FALSE, piControl = 0.6, piMaxVector = seq(0.3, 0.6, 0.1),
+ conditionalPower = 0.6, minNumberOfSubjectsPerStage = c(NA, 20, 20), maxNumberOfSubjectsPerStage = c(NA, 80, 80),
+ piControlH1 = 0.4,
+ piTreatmentsH1 = 0.3,
+ maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 1234
+ )
+
+ y <- getSimulationRates(design,
+ plannedSubjects = round((1 + 1 / allocationRatioPlanned) * c(20, 40, 60)),
+ normalApproximation = TRUE, pi2 = 0.6, pi1 = seq(0.3, 0.6, 0.1), directionUpper = FALSE,
+ conditionalPower = 0.6,
+ pi2H1 = 0.4,
+ pi1H1 = 0.3,
+ minNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 20, 20)),
+ maxNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 80, 80)),
+ maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = 1234
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(-0.03, -0.02, 0.09, 0.03), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(0, 0, 0, 0), label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(0.09, -0.01, 0.06, 0.02), tolerance = 1e-07, label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(-0.12, -0.01, 0.03, 0.01), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(0.04, 0.04, -0.12, -0.03), tolerance = 1e-07, label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(0.01, 0.02, -0.05, 0.03), tolerance = 1e-07, label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(1.1, 0.3, 0, 0), tolerance = 1e-07, label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(-44.7, 9.7, 1.3, -3.2), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(-14.6, -6.6, 26.9, 0.4), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(-0.96, -0.39, -0.75, -0.06), tolerance = 1e-07, label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(0.1, -0.16, -0.38, -0.43), tolerance = 1e-07, label = paste0(comp6[2, ]))
})
test_that("'getSimulationMultiArmRates': comparison of base and multi-arm, Fisher design", {
-
- .skipTestIfDisabled()
- .skipTestIfNotX64()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
- # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- allocationRatioPlanned <- 1
- design <- getDesignFisher(alpha0Vec = c(0.3, 0.4), informationRates = c(0.5, 0.7, 1))
-
- x <- getSimulationMultiArmRates(design,
- activeArms = 1, plannedSubjects = c(20, 40, 60),
- directionUpper = FALSE, piControl = 0.6, piMaxVector = seq(0.3, 0.6, 0.1),
- conditionalPower = 0.6, minNumberOfSubjectsPerStage = c(NA, 20, 20), maxNumberOfSubjectsPerStage = c(NA, 80, 80),
- maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = -1008239793
- )
-
- y <- getSimulationRates(design,
- plannedSubjects = round((1 + 1 / allocationRatioPlanned) * c(20, 40, 60)),
- normalApproximation = TRUE, pi2 = 0.6, pi1 = seq(0.3, 0.6, 0.1), directionUpper = FALSE,
- conditionalPower = 0.6, minNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 20, 20)),
- maxNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 80, 80)),
- maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = -2039707705
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(0.05, 0.1, 0.07, 0.02), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(0.05, 0.01, 0.02, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(-0.03, 0.04, -0.01, -0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(0.03, 0.05, 0.06, 0), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(-0.05, -0.09, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(0, 0, -0.05, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(7.4, 3.6, -6.3, 6.6), tolerance = 1e-07, label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(0.5, 12.9, -5, 26), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(6.1, 19.9, -2, -3.9), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(-0.38, -0.17, -0.41, 0.14), tolerance = 1e-07, label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(-0.29, -0.61, -0.52, -0.78), tolerance = 1e-07, label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
+ .skipTestIfDisabled()
+ .skipTestIfNotX64()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmRates}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmRatesGenerate}
+ # @refFS[Formula]{fs:simulationMultiArmRatesTestStatistics}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ allocationRatioPlanned <- 1
+ design <- getDesignFisher(alpha0Vec = c(0.3, 0.4), informationRates = c(0.5, 0.7, 1))
+
+ x <- getSimulationMultiArmRates(design,
+ activeArms = 1, plannedSubjects = c(20, 40, 60),
+ directionUpper = FALSE, piControl = 0.6, piMaxVector = seq(0.3, 0.6, 0.1),
+ conditionalPower = 0.6, minNumberOfSubjectsPerStage = c(NA, 20, 20), maxNumberOfSubjectsPerStage = c(NA, 80, 80),
+ maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = -1008239793
+ )
+
+ y <- getSimulationRates(design,
+ plannedSubjects = round((1 + 1 / allocationRatioPlanned) * c(20, 40, 60)),
+ normalApproximation = TRUE, pi2 = 0.6, pi1 = seq(0.3, 0.6, 0.1), directionUpper = FALSE,
+ conditionalPower = 0.6, minNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 20, 20)),
+ maxNumberOfSubjectsPerStage = round((1 + 1 / allocationRatioPlanned) * c(NA, 80, 80)),
+ maxNumberOfIterations = 100, allocationRatioPlanned = allocationRatioPlanned, seed = -2039707705
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(0.05, 0.1, 0.07, 0.02), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(0.05, 0.01, 0.02, 0.03), tolerance = 1e-07, label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(-0.03, 0.04, -0.01, -0.01), tolerance = 1e-07, label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(0.03, 0.05, 0.06, 0), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(-0.05, -0.09, 0, 0), tolerance = 1e-07, label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(0, 0, -0.05, 0.01), tolerance = 1e-07, label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$sampleSizes - (x$sampleSizes[, , 1] + x$sampleSizes[, , 2]), 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(7.4, 3.6, -6.3, 6.6), tolerance = 1e-07, label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(0.5, 12.9, -5, 26), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfSubjects - x$expectedNumberOfSubjects, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(6.1, 19.9, -2, -3.9), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(-0.38, -0.17, -0.41, 0.14), tolerance = 1e-07, label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(-0.29, -0.61, -0.52, -0.78), tolerance = 1e-07, label = paste0(comp6[2, ]))
})
-
diff --git a/tests/testthat/test-f_simulation_multiarm_survival.R b/tests/testthat/test-f_simulation_multiarm_survival.R
index 81065d40..41239743 100644
--- a/tests/testthat/test-f_simulation_multiarm_survival.R
+++ b/tests/testthat/test-f_simulation_multiarm_survival.R
@@ -1,1841 +1,1784 @@
-## |
+## |
## | *Unit tests*
-## |
+## |
## | This file is part of the R package rpact:
## | Confirmatory Adaptive Clinical Trial Design and Analysis
-## |
+## |
## | Author: Gernot Wassmer, PhD, and Friedrich Pahlke, PhD
## | Licensed under "GNU Lesser General Public License" version 3
## | License text can be found here: https://www.r-project.org/Licenses/LGPL-3
-## |
+## |
## | RPACT company website: https://www.rpact.com
## | RPACT package website: https://www.rpact.org
-## |
+## |
## | Contact us for information about our services: info@rpact.com
-## |
+## |
## | File name: test-f_simulation_multiarm_survival.R
-## | Creation date: 08 November 2023, 09:11:58
-## | File version: $Revision: 7560 $
-## | Last changed: $Date: 2024-01-15 14:20:32 +0100 (Mo, 15 Jan 2024) $
+## | Creation date: 09 February 2024, 10:57:46
+## | File version: $Revision: 7620 $
+## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | Last changed by: $Author: pahlke $
-## |
+## |
test_plan_section("Testing Simulation Multi-Arm Survival Function")
test_that("'getSimulationMultiArmSurvival': several configurations", {
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetBonferroni}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- # @refFS[Formula]{fs:adjustedPValueSubsetHierarchical}
- # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
- # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
- x1 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x1' with expected results
- expect_equal(unlist(as.list(x1$eventsPerStage)), c(4, 56.544006, 118.06218, 3.7272727, 45.869846, 102.75827, 3.5, 30.37664, 63.385959, 3.3076923, 32.448585, 72.264513, 4, 49.635155, 106.15332, 3.8181818, 36.042521, 83.474993, 3.6666667, 30.759757, 64.009577, 3.5384615, 32.768737, 72.921706, 4, 65.124183, 133.16052, 3.9090909, 38.113637, 101.03155, 3.8333333, 29.450577, 70.659781, 3.7692308, 37.063433, 93.1602, 4, 43.825836, 90.344006, 4, 31.654176, 76.670094, 4, 38.617451, 74.294998, 4, 39.885794, 87.433784), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x1$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x1$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x1$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x1$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x1$iterations[3, ], c(10, 10, 9, 9), label = paste0("c(", paste0(x1$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x1$rejectAtLeastOne, c(0, 0.1, 0.4, 0.5), tolerance = 1e-07, label = paste0("c(", paste0(x1$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x1$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityStop, collapse = ", "), ")"))
- expect_equal(x1$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x1$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x1$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x1$earlyStop[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x1$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x1$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x1$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x1$successPerStage[3, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x1$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$selectedArms)), collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x1$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x1$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x1$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x1$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x1$expectedNumberOfEvents, c(182.68801, 153.5825, 114.70922, 140.61265), tolerance = 1e-07, label = paste0("c(", paste0(x1$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x1$singleNumberOfEventsPerStage)), c(2, 12.71817, 15, 1.9090909, 15.365854, 15.365854, 1.8333333, 5.2380952, 5.8201058, 1.7692308, 5.5627907, 5.9431525, 2, 5.8093191, 10, 2, 5.447619, 5.9099062, 2, 5.4545455, 6.0606061, 2, 5.6521739, 6.2801932, 2, 21.298347, 21.51817, 2.0909091, 7.4278263, 21.395349, 2.1666667, 3.9786992, 14.01999, 2.2307692, 9.7161004, 22.223992, 2, 0, 0, 2.1818182, 0.87745601, 3.4933517, 2.3333333, 12.978906, 8.4883336, 2.4615385, 12.307692, 13.675214, 2, 39.825836, 46.51817, 1.8181818, 26.77672, 41.522566, 1.6666667, 21.638545, 27.189214, 1.5384615, 23.578102, 33.872776), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x1$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[2, ], c(5.8245202e-05, 0.033918251, 0.017570415, 0.062651459), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPowerAchieved[3, ], c(0.081443645, 0.17714318, 0.49831, 0.30622362), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x1), NA)))
- expect_output(print(x1)$show())
- invisible(capture.output(expect_error(summary(x1), NA)))
- expect_output(summary(x1)$show())
- x1CodeBased <- eval(parse(text = getObjectRCode(x1, stringWrapParagraphWidth = NULL)))
- expect_equal(x1CodeBased$eventsPerStage, x1$eventsPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$iterations, x1$iterations, tolerance = 1e-07)
- expect_equal(x1CodeBased$rejectAtLeastOne, x1$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x1CodeBased$rejectedArmsPerStage, x1$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$futilityStop, x1$futilityStop, tolerance = 1e-07)
- expect_equal(x1CodeBased$futilityPerStage, x1$futilityPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$earlyStop, x1$earlyStop, tolerance = 1e-07)
- expect_equal(x1CodeBased$successPerStage, x1$successPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$selectedArms, x1$selectedArms, tolerance = 1e-07)
- expect_equal(x1CodeBased$numberOfActiveArms, x1$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x1CodeBased$expectedNumberOfEvents, x1$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x1CodeBased$singleNumberOfEventsPerStage, x1$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPowerAchieved, x1$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x1), "character")
- df <- as.data.frame(x1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- .skipTestIfDisabled()
-
- x2 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "userDefined", activeArms = 4,
- plannedEvents = c(10, 30, 50), adaptations = rep(TRUE, 2),
- effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x2' with expected results
- expect_equal(unlist(as.list(x2$eventsPerStage)), c(5.5, 83.888278, 161.11661, 5, 67.731433, 137.0436, 6.5, 94.119048, 179.03968, 5.8333333, 80.884792, 166.06998, 6, 91.054945, 173.83883, 5.4166667, 70.455792, 139.76796, 7, 91.102564, 177.8547, 6.25, 81.100963, 165.22795), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x2$iterations[1, ], c(10, 10), label = paste0("c(", paste0(x2$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x2$iterations[2, ], c(10, 10), label = paste0("c(", paste0(x2$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x2$iterations[3, ], c(3, 9), label = paste0("c(", paste0(x2$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x2$rejectAtLeastOne, c(0, 0), label = paste0("c(", paste0(x2$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x2$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x2$futilityStop, c(0.7, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x2$futilityStop, collapse = ", "), ")"))
- expect_equal(x2$futilityPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x2$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x2$futilityPerStage[2, ], c(0.7, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x2$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x2$earlyStop[1, ], c(0, 0), label = paste0("c(", paste0(x2$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x2$earlyStop[2, ], c(0.7, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x2$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x2$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[2, ], c(0, 0), label = paste0("c(", paste0(x2$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x2$successPerStage[3, ], c(0, 0), label = paste0("c(", paste0(x2$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.4, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.1, 1, 0.1, 0, 1, 0.2, 0.1, 1, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$selectedArms)), collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[1, ], c(4, 4), label = paste0("c(", paste0(x2$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[2, ], c(1, 1), label = paste0("c(", paste0(x2$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x2$numberOfActiveArms[3, ], c(1, 1), label = paste0("c(", paste0(x2$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x2$expectedNumberOfEvents, c(140, 189.47868), tolerance = 1e-07, label = paste0("c(", paste0(x2$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x2$singleNumberOfEventsPerStage)), c(0.5, 0, 0, 0.83333333, 0, 0, 1.5, 9.2307692, 7.6923077, 1.6666667, 12.320026, 15.873016, 1, 6.6666667, 5.5555556, 1.25, 2.3076923, 0, 2, 5.7142857, 9.5238095, 2.0833333, 12.119531, 14.814815, 5, 78.388278, 77.228327, 4.1666667, 62.731433, 69.312169), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x2$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[2, ], c(0, 1.5253195e-09), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPowerAchieved[3, ], c(0, 1.1842379e-15), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x2), NA)))
- expect_output(print(x2)$show())
- invisible(capture.output(expect_error(summary(x2), NA)))
- expect_output(summary(x2)$show())
- x2CodeBased <- eval(parse(text = getObjectRCode(x2, stringWrapParagraphWidth = NULL)))
- expect_equal(x2CodeBased$eventsPerStage, x2$eventsPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$iterations, x2$iterations, tolerance = 1e-07)
- expect_equal(x2CodeBased$rejectAtLeastOne, x2$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x2CodeBased$rejectedArmsPerStage, x2$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$futilityStop, x2$futilityStop, tolerance = 1e-07)
- expect_equal(x2CodeBased$futilityPerStage, x2$futilityPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$earlyStop, x2$earlyStop, tolerance = 1e-07)
- expect_equal(x2CodeBased$successPerStage, x2$successPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$selectedArms, x2$selectedArms, tolerance = 1e-07)
- expect_equal(x2CodeBased$numberOfActiveArms, x2$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x2CodeBased$expectedNumberOfEvents, x2$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x2CodeBased$singleNumberOfEventsPerStage, x2$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPowerAchieved, x2$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x2), "character")
- df <- as.data.frame(x2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x3 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x3' with expected results
- expect_equal(unlist(as.list(x3$eventsPerStage)), c(4, 56.544006, 118.06218, 3.8499139, 46.858849, 105.91374, 3.7209785, 37.392533, 79.701207, 3.6090171, 41.322916, 96.584767, 4, 49.635155, 106.15332, 3.8816273, 36.741574, 86.112527, 3.7799362, 32.140988, 69.139159, 3.6916324, 34.296961, 77.330183, 4, 65.124183, 133.16052, 3.9002999, 39.328667, 103.83053, 3.8146499, 31.005549, 75.358715, 3.7402755, 36.850923, 90.063067, 4, 43.825836, 90.344006, 3.9133408, 32.25912, 80.994092, 3.8388939, 33.67594, 74.187296, 3.7742477, 34.474746, 77.613714), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x3$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x3$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x3$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x3$iterations[3, ], c(10, 10, 10, 9), label = paste0("c(", paste0(x3$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x3$rejectAtLeastOne, c(0, 0.1, 0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x3$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x3$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityStop, collapse = ", "), ")"))
- expect_equal(x3$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x3$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x3$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x3$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x3$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x3$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x3$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x3$successPerStage[3, ], c(0, 0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x3$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.4, 0.3, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0, 0, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$selectedArms)), collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x3$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x3$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x3$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x3$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x3$expectedNumberOfEvents, c(182.68801, 158.69386, 129.88152, 143.2193), tolerance = 1e-07, label = paste0("c(", paste0(x3$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x3$singleNumberOfEventsPerStage)), c(2, 12.71817, 15, 2.0015199, 15.596608, 15.596608, 2.0028257, 10.765048, 10.765048, 2.0039595, 12.760745, 18.508821, 2, 5.8093191, 10, 2.0332334, 5.447619, 5.9126663, 2.0617834, 5.4545455, 5.4545455, 2.0865748, 5.6521739, 6.2801932, 2, 21.298347, 21.51817, 2.0519059, 8.0160405, 21.043571, 2.0964971, 4.2843932, 12.80954, 2.135218, 8.1574931, 16.459114, 2, 0, 0, 2.0649468, 0.93345197, 5.2766854, 2.120741, 6.9305404, 8.9677303, 2.1691901, 5.7473444, 6.3859382, 2, 39.825836, 46.51817, 1.848394, 27.412327, 43.458287, 1.7181528, 22.906506, 31.543625, 1.6050576, 24.953154, 36.753029), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x3$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[2, ], c(5.8245202e-05, 0.027881828, 0.017394693, 0.05621525), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPowerAchieved[3, ], c(0.081443645, 0.17047212, 0.40326875, 0.20898924), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x3), NA)))
- expect_output(print(x3)$show())
- invisible(capture.output(expect_error(summary(x3), NA)))
- expect_output(summary(x3)$show())
- x3CodeBased <- eval(parse(text = getObjectRCode(x3, stringWrapParagraphWidth = NULL)))
- expect_equal(x3CodeBased$eventsPerStage, x3$eventsPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$iterations, x3$iterations, tolerance = 1e-07)
- expect_equal(x3CodeBased$rejectAtLeastOne, x3$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x3CodeBased$rejectedArmsPerStage, x3$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$futilityStop, x3$futilityStop, tolerance = 1e-07)
- expect_equal(x3CodeBased$futilityPerStage, x3$futilityPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$earlyStop, x3$earlyStop, tolerance = 1e-07)
- expect_equal(x3CodeBased$successPerStage, x3$successPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$selectedArms, x3$selectedArms, tolerance = 1e-07)
- expect_equal(x3CodeBased$numberOfActiveArms, x3$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x3CodeBased$expectedNumberOfEvents, x3$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x3CodeBased$singleNumberOfEventsPerStage, x3$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPowerAchieved, x3$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x3), "character")
- df <- as.data.frame(x3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x4 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "all",
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x4' with expected results
- expect_equal(unlist(as.list(x4$eventsPerStage)), c(4, 43.80534, 83.80534, 3.7272727, 41, 78.272727, 3.5, 36.991095, 71.991095, 3.3076923, 31.601422, 64.678345, 4, 43.80534, 83.80534, 3.8181818, 42, 80.181818, 3.6666667, 38.752575, 75.419242, 3.5384615, 33.806172, 69.190787, 4, 43.80534, 83.80534, 3.9090909, 43, 82.090909, 3.8333333, 40.514056, 78.847389, 3.7692308, 36.010922, 73.70323, 4, 43.80534, 83.80534, 4, 44, 84, 4, 42.275537, 82.275537, 4, 38.215673, 78.215673), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x4$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x4$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x4$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x4$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x4$rejectAtLeastOne, c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x4$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x4$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityStop, collapse = ", "), ")"))
- expect_equal(x4$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x4$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x4$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x4$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x4$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x4$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(unlist(as.list(x4$selectedArms)), collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x4$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x4$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x4$expectedNumberOfEvents, c(209.51335, 210, 205.68884, 195.53918), tolerance = 1e-07, label = paste0("c(", paste0(x4$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x4$singleNumberOfEventsPerStage)), c(2, 19.90267, 20, 1.9090909, 19.090909, 19.090909, 1.8333333, 17.542954, 18.333333, 1.7692308, 15.133855, 17.692308, 2, 19.90267, 20, 2, 20, 20, 2, 19.137768, 20, 2, 17.107836, 20, 2, 19.90267, 20, 2.0909091, 20.909091, 20.909091, 2.1666667, 20.732582, 21.666667, 2.2307692, 19.081818, 22.307692, 2, 19.90267, 20, 2.1818182, 21.818182, 21.818182, 2.3333333, 22.327396, 23.333333, 2.4615385, 21.055799, 24.615385, 2, 19.90267, 20, 1.8181818, 18.181818, 18.181818, 1.6666667, 15.94814, 16.666667, 1.5384615, 13.159874, 15.384615), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x4$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[2, ], c(0.09225544, 0.10755451, 0.080008195, 0.16137979), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPowerAchieved[3, ], c(0.011907723, 0.030096405, 0.063317228, 0.080810126), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x4), NA)))
- expect_output(print(x4)$show())
- invisible(capture.output(expect_error(summary(x4), NA)))
- expect_output(summary(x4)$show())
- x4CodeBased <- eval(parse(text = getObjectRCode(x4, stringWrapParagraphWidth = NULL)))
- expect_equal(x4CodeBased$eventsPerStage, x4$eventsPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$iterations, x4$iterations, tolerance = 1e-07)
- expect_equal(x4CodeBased$rejectAtLeastOne, x4$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x4CodeBased$rejectedArmsPerStage, x4$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$futilityStop, x4$futilityStop, tolerance = 1e-07)
- expect_equal(x4CodeBased$futilityPerStage, x4$futilityPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$earlyStop, x4$earlyStop, tolerance = 1e-07)
- expect_equal(x4CodeBased$successPerStage, x4$successPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$selectedArms, x4$selectedArms, tolerance = 1e-07)
- expect_equal(x4CodeBased$numberOfActiveArms, x4$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x4CodeBased$expectedNumberOfEvents, x4$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x4CodeBased$singleNumberOfEventsPerStage, x4$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalPowerAchieved, x4$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x4), "character")
- df <- as.data.frame(x4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x5 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "rBest", rValue = 2,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x5' with expected results
- expect_equal(unlist(as.list(x5$eventsPerStage)), c(4, 52.52163, 101.87923, 3.7272727, 38.874416, 80.596598, 3.5, 26.84484, 58.886153, 3.3076923, 30.949369, 59.030095, 4, 46.265898, 91.178205, 3.8181818, 38.846483, 77.651274, 3.6666667, 31.816991, 74.831476, 3.5384615, 34.40256, 64.30431, 4, 45.854963, 88.5459, 3.9090909, 42.746334, 86.637949, 3.8333333, 33.812131, 81.900895, 3.7692308, 37.761125, 70.330365, 4, 39.599231, 77.844872, 4, 51.153533, 106.61534, 4, 33.295158, 78.303665, 4, 52.301815, 100.0206), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x5$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x5$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x5$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x5$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x5$rejectAtLeastOne, c(0.1, 0, 0.2, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x5$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x5$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityStop, collapse = ", "), ")"))
- expect_equal(x5$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x5$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x5$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x5$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x5$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x5$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x5$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$selectedArms)), c(1, 0.7, 0.7, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.7, 0.7, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.8, 0.8, 1, 0.5, 0.5, 1, 0.8, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$selectedArms)), collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x5$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x5$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x5$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x5$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x5$expectedNumberOfEvents, c(181.7241, 185.49972, 161.03264, 167.26743), tolerance = 1e-07, label = paste0("c(", paste0(x5$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x5$singleNumberOfEventsPerStage)), c(2, 20.481343, 20.156522, 1.9090909, 10.277572, 13.076122, 1.8333333, 6.3781513, 6.3781513, 1.7692308, 7.1692484, 7.9523038, 2, 14.225611, 15.711226, 2, 10.15873, 10.15873, 2, 11.183635, 17.351324, 2, 10.39167, 9.7733283, 2, 13.814676, 13.489856, 2.0909091, 13.967672, 15.245555, 2.1666667, 13.012108, 22.425602, 2.2307692, 13.519466, 12.440818, 2, 7.5589445, 9.044559, 2.1818182, 22.283962, 26.815748, 2.3333333, 12.328469, 19.345345, 2.4615385, 27.829386, 27.590364, 2, 28.040287, 29.201081, 1.8181818, 24.869571, 28.64606, 1.6666667, 16.966689, 25.663162, 1.5384615, 20.472429, 20.128422), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x5$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x5$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[2, ], c(0.0011884888, 0.025687618, 0.050936222, 0.056920177), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPowerAchieved[3, ], c(0.16000064, 0.17717891, 0.25226702, 0.41435883), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x5), NA)))
- expect_output(print(x5)$show())
- invisible(capture.output(expect_error(summary(x5), NA)))
- expect_output(summary(x5)$show())
- x5CodeBased <- eval(parse(text = getObjectRCode(x5, stringWrapParagraphWidth = NULL)))
- expect_equal(x5CodeBased$eventsPerStage, x5$eventsPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$iterations, x5$iterations, tolerance = 1e-07)
- expect_equal(x5CodeBased$rejectAtLeastOne, x5$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x5CodeBased$rejectedArmsPerStage, x5$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$futilityStop, x5$futilityStop, tolerance = 1e-07)
- expect_equal(x5CodeBased$futilityPerStage, x5$futilityPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$earlyStop, x5$earlyStop, tolerance = 1e-07)
- expect_equal(x5CodeBased$successPerStage, x5$successPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$selectedArms, x5$selectedArms, tolerance = 1e-07)
- expect_equal(x5CodeBased$numberOfActiveArms, x5$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x5CodeBased$expectedNumberOfEvents, x5$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x5CodeBased$singleNumberOfEventsPerStage, x5$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x5CodeBased$conditionalPowerAchieved, x5$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x5), "character")
- df <- as.data.frame(x5)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x5)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x6 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x6' with expected results
- expect_equal(unlist(as.list(x6$eventsPerStage)), c(4, 61.733546, 127.87237, 3.7272727, 31.938683, 70.204069, 3.5, 41.1271, 91.550286, 3.3076923, 34.649784, 81.031044, 4, 56.48818, 112.05759, 3.8181818, 40.038722, 105.34522, 3.6666667, 42.689301, 87.532881, 3.5384615, 28.026291, 80.666398, 4, 48.154846, 98.724256, 3.9090909, 30.896746, 79.036909, 3.8333333, 37.59905, 82.662218, 3.7692308, 38.754446, 86.274767, 4, 48.730993, 104.3004, 4, 35.685987, 84.168898, 4, 44.550112, 108.98044, 4, 36.742663, 80.705475), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x6$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x6$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x6$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x6$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x6$iterations[3, ], c(10, 9, 9, 10), label = paste0("c(", paste0(x6$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x6$rejectAtLeastOne, c(0, 0.3, 0.5, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x6$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.3, 0, 0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x6$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityStop, collapse = ", "), ")"))
- expect_equal(x6$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x6$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x6$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x6$earlyStop[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x6$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x6$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0("c(", paste0(x6$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x6$successPerStage[3, ], c(0, 0.2, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x6$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$selectedArms)), c(1, 0.5, 0.5, 1, 0.3, 0, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.5, 0.5, 1, 0.2, 0.1, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.2, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$selectedArms)), collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x6$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[2, ], c(1.1, 1.3, 1.1, 1.2), tolerance = 1e-07, label = paste0("c(", paste0(x6$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x6$numberOfActiveArms[3, ], c(1, 1.1111111, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x6$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x6$expectedNumberOfEvents, c(182.78185, 142.9628, 156.19514, 150.78355), tolerance = 1e-07, label = paste0("c(", paste0(x6$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x6$singleNumberOfEventsPerStage)), c(2, 18.5787, 20.56941, 1.9090909, 5.8775077, 0, 1.8333333, 9.5135564, 11.640212, 1.7692308, 9.2660953, 10.697674, 2, 13.333333, 10, 2, 13.886638, 27.041107, 2, 10.909091, 6.0606061, 2, 2.4118335, 16.956522, 2, 5, 5, 2.0909091, 4.6537525, 9.8747764, 2.1666667, 5.6521739, 6.2801932, 2.2307692, 12.909219, 11.836735, 2, 5.5761462, 10, 2.1818182, 9.3520845, 10.217524, 2.3333333, 12.436568, 25.647358, 2.4615385, 10.666667, 8.2792264, 2, 39.154846, 45.56941, 1.8181818, 22.333902, 38.265387, 1.6666667, 28.113543, 38.782975, 1.5384615, 22.075996, 35.683586), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x6$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x6$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[2, ], c(0.018816179, 0.071905821, 0.002298516, 0.067085771), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPowerAchieved[3, ], c(0.080015186, 0.29125387, 0.18887123, 0.4033636), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x6), NA)))
- expect_output(print(x6)$show())
- invisible(capture.output(expect_error(summary(x6), NA)))
- expect_output(summary(x6)$show())
- x6CodeBased <- eval(parse(text = getObjectRCode(x6, stringWrapParagraphWidth = NULL)))
- expect_equal(x6CodeBased$eventsPerStage, x6$eventsPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$iterations, x6$iterations, tolerance = 1e-07)
- expect_equal(x6CodeBased$rejectAtLeastOne, x6$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x6CodeBased$rejectedArmsPerStage, x6$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$futilityStop, x6$futilityStop, tolerance = 1e-07)
- expect_equal(x6CodeBased$futilityPerStage, x6$futilityPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$earlyStop, x6$earlyStop, tolerance = 1e-07)
- expect_equal(x6CodeBased$successPerStage, x6$successPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$selectedArms, x6$selectedArms, tolerance = 1e-07)
- expect_equal(x6CodeBased$numberOfActiveArms, x6$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x6CodeBased$expectedNumberOfEvents, x6$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x6CodeBased$singleNumberOfEventsPerStage, x6$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x6CodeBased$conditionalPowerAchieved, x6$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x6), "character")
- df <- as.data.frame(x6)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x6)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x7 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x7' with expected results
- expect_equal(unlist(as.list(x7$eventsPerStage)), c(4, 56.544006, 109.08801, 3.7272727, 45.869846, 88.01242, 3.5, 30.37664, 55.609943, 3.3076923, 32.448585, 64.38291, 4, 49.635155, 95.27031, 3.8181818, 36.042521, 68.26686, 3.6666667, 30.759757, 56.23356, 3.5384615, 32.768737, 65.040103, 4, 65.124183, 126.24837, 3.9090909, 38.113637, 72.318183, 3.8333333, 29.450577, 53.284552, 3.7692308, 37.063433, 73.850273, 4, 43.825836, 83.651672, 4, 31.654176, 59.308352, 4, 38.617451, 65.970174, 4, 39.885794, 79.552181), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x7$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x7$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x7$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x7$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x7$iterations[3, ], c(10, 10, 9, 9), label = paste0("c(", paste0(x7$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x7$rejectAtLeastOne, c(0, 0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(x7$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x7$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityStop, collapse = ", "), ")"))
- expect_equal(x7$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x7$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x7$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x7$earlyStop[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x7$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x7$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x7$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x7$successPerStage[3, ], c(0, 0.1, 0.3, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x7$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$selectedArms)), collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x7$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x7$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x7$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x7$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x7$expectedNumberOfEvents, c(169.30334, 121.79095, 98.577582, 123.23372), tolerance = 1e-07, label = paste0("c(", paste0(x7$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x7$singleNumberOfEventsPerStage)), c(2, 12.71817, 12.71817, 1.9090909, 15.365854, 15.365854, 1.8333333, 5.2380952, 5.8201058, 1.7692308, 5.5627907, 5.9431525, 2, 5.8093191, 5.8093191, 2, 5.447619, 5.447619, 2, 5.4545455, 6.0606061, 2, 5.6521739, 6.2801932, 2, 21.298347, 21.298347, 2.0909091, 7.4278263, 7.4278263, 2.1666667, 3.9786992, 4.4207768, 2.2307692, 9.7161004, 10.795667, 2, 0, 0, 2.1818182, 0.87745601, 0.87745601, 2.3333333, 12.978906, 7.9395257, 2.4615385, 12.307692, 13.675214, 2, 39.825836, 39.825836, 1.8181818, 26.77672, 26.77672, 1.6666667, 21.638545, 19.413198, 1.5384615, 23.578102, 25.991173), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x7$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x7$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[2, ], c(5.8245202e-05, 0.033918251, 0.017570415, 0.062651459), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPowerAchieved[3, ], c(0.075858531, 0.086024261, 0.37522404, 0.19729909), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x7), NA)))
- expect_output(print(x7)$show())
- invisible(capture.output(expect_error(summary(x7), NA)))
- expect_output(summary(x7)$show())
- x7CodeBased <- eval(parse(text = getObjectRCode(x7, stringWrapParagraphWidth = NULL)))
- expect_equal(x7CodeBased$eventsPerStage, x7$eventsPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$iterations, x7$iterations, tolerance = 1e-07)
- expect_equal(x7CodeBased$rejectAtLeastOne, x7$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x7CodeBased$rejectedArmsPerStage, x7$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$futilityStop, x7$futilityStop, tolerance = 1e-07)
- expect_equal(x7CodeBased$futilityPerStage, x7$futilityPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$earlyStop, x7$earlyStop, tolerance = 1e-07)
- expect_equal(x7CodeBased$successPerStage, x7$successPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$selectedArms, x7$selectedArms, tolerance = 1e-07)
- expect_equal(x7CodeBased$numberOfActiveArms, x7$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x7CodeBased$expectedNumberOfEvents, x7$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x7CodeBased$singleNumberOfEventsPerStage, x7$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x7CodeBased$conditionalPowerAchieved, x7$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x7), "character")
- df <- as.data.frame(x7)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x7)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x8 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "all",
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x8' with expected results
- expect_equal(unlist(as.list(x8$eventsPerStage)), c(4, 43.80534, 83.61068, 3.7272727, 41, 78.272727, 3.5, 36.991095, 70.482189, 3.3076923, 31.601422, 59.895151, 4, 43.80534, 83.61068, 3.8181818, 42, 80.181818, 3.6666667, 38.752575, 73.838484, 3.5384615, 33.806172, 64.073883, 4, 43.80534, 83.61068, 3.9090909, 43, 82.090909, 3.8333333, 40.514056, 77.194778, 3.7692308, 36.010922, 68.252614, 4, 43.80534, 83.61068, 4, 44, 84, 4, 42.275537, 80.551073, 4, 38.215673, 72.431346), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x8$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x8$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x8$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x8$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x8$rejectAtLeastOne, c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x8$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x8$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityStop, collapse = ", "), ")"))
- expect_equal(x8$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x8$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x8$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x8$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x8$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x8$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0("c(", paste0(unlist(as.list(x8$selectedArms)), collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x8$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x8$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x8$expectedNumberOfEvents, c(209.0267, 210, 201.37768, 181.07836), tolerance = 1e-07, label = paste0("c(", paste0(x8$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x8$singleNumberOfEventsPerStage)), c(2, 19.90267, 19.90267, 1.9090909, 19.090909, 19.090909, 1.8333333, 17.542954, 17.542954, 1.7692308, 15.133855, 15.133855, 2, 19.90267, 19.90267, 2, 20, 20, 2, 19.137768, 19.137768, 2, 17.107836, 17.107836, 2, 19.90267, 19.90267, 2.0909091, 20.909091, 20.909091, 2.1666667, 20.732582, 20.732582, 2.2307692, 19.081818, 19.081818, 2, 19.90267, 19.90267, 2.1818182, 21.818182, 21.818182, 2.3333333, 22.327396, 22.327396, 2.4615385, 21.055799, 21.055799, 2, 19.90267, 19.90267, 1.8181818, 18.181818, 18.181818, 1.6666667, 15.94814, 15.94814, 1.5384615, 13.159874, 13.159874), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x8$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x8$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[2, ], c(0.09225544, 0.10755451, 0.080008195, 0.16137979), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPowerAchieved[3, ], c(0.011968708, 0.030096405, 0.063317862, 0.066369104), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x8), NA)))
- expect_output(print(x8)$show())
- invisible(capture.output(expect_error(summary(x8), NA)))
- expect_output(summary(x8)$show())
- x8CodeBased <- eval(parse(text = getObjectRCode(x8, stringWrapParagraphWidth = NULL)))
- expect_equal(x8CodeBased$eventsPerStage, x8$eventsPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$iterations, x8$iterations, tolerance = 1e-07)
- expect_equal(x8CodeBased$rejectAtLeastOne, x8$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x8CodeBased$rejectedArmsPerStage, x8$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$futilityStop, x8$futilityStop, tolerance = 1e-07)
- expect_equal(x8CodeBased$futilityPerStage, x8$futilityPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$earlyStop, x8$earlyStop, tolerance = 1e-07)
- expect_equal(x8CodeBased$successPerStage, x8$successPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$selectedArms, x8$selectedArms, tolerance = 1e-07)
- expect_equal(x8CodeBased$numberOfActiveArms, x8$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x8CodeBased$expectedNumberOfEvents, x8$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x8CodeBased$singleNumberOfEventsPerStage, x8$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x8CodeBased$conditionalPowerAchieved, x8$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x8), "character")
- df <- as.data.frame(x8)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x9 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "rBest", rValue = 2,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x9' with expected results
- expect_equal(unlist(as.list(x9$eventsPerStage)), c(4, 52.52163, 101.04326, 3.7272727, 38.874416, 74.021559, 3.5, 26.84484, 50.189681, 3.3076923, 30.949369, 58.591046, 4, 46.265898, 88.531796, 3.8181818, 38.846483, 73.874785, 3.6666667, 31.816991, 59.967314, 3.5384615, 34.40256, 65.266658, 4, 45.854963, 87.709926, 3.9090909, 42.746334, 81.583577, 3.8333333, 33.812131, 63.790928, 3.7692308, 37.761125, 71.75302, 4, 39.599231, 75.198463, 4, 51.153533, 98.307067, 4, 33.295158, 62.590316, 4, 52.301815, 100.60363), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x9$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x9$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x9$iterations[3, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x9$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x9$rejectAtLeastOne, c(0.1, 0, 0.2, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(x9$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x9$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityStop, collapse = ", "), ")"))
- expect_equal(x9$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x9$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x9$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x9$earlyStop[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x9$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x9$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x9$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$selectedArms)), c(1, 0.7, 0.7, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.7, 0.7, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.8, 0.8, 1, 0.5, 0.5, 1, 0.8, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$selectedArms)), collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x9$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x9$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x9$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x9$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x9$expectedNumberOfEvents, c(178.24172, 173.11501, 129.7381, 168.7644), tolerance = 1e-07, label = paste0("c(", paste0(x9$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x9$singleNumberOfEventsPerStage)), c(2, 20.481343, 20.481343, 1.9090909, 10.277572, 10.277572, 1.8333333, 6.3781513, 6.3781513, 1.7692308, 7.1692484, 7.1692484, 2, 14.225611, 14.225611, 2, 10.15873, 10.15873, 2, 11.183635, 11.183635, 2, 10.39167, 10.39167, 2, 13.814676, 13.814676, 2.0909091, 13.967672, 13.967672, 2.1666667, 13.012108, 13.012108, 2.2307692, 13.519466, 13.519466, 2, 7.5589445, 7.5589445, 2.1818182, 22.283962, 22.283962, 2.3333333, 12.328469, 12.328469, 2.4615385, 27.829386, 27.829386, 2, 28.040287, 28.040287, 1.8181818, 24.869571, 24.869571, 1.6666667, 16.966689, 16.966689, 1.5384615, 20.472429, 20.472429), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x9$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x9$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[2, ], c(0.0011884888, 0.025687618, 0.050936222, 0.056920177), tolerance = 1e-07, label = paste0("c(", paste0(x9$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x9$conditionalPowerAchieved[3, ], c(0.13630501, 0.14441052, 0.13257023, 0.41932885), tolerance = 1e-07, label = paste0("c(", paste0(x9$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x9), NA)))
- expect_output(print(x9)$show())
- invisible(capture.output(expect_error(summary(x9), NA)))
- expect_output(summary(x9)$show())
- x9CodeBased <- eval(parse(text = getObjectRCode(x9, stringWrapParagraphWidth = NULL)))
- expect_equal(x9CodeBased$eventsPerStage, x9$eventsPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$iterations, x9$iterations, tolerance = 1e-07)
- expect_equal(x9CodeBased$rejectAtLeastOne, x9$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x9CodeBased$rejectedArmsPerStage, x9$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$futilityStop, x9$futilityStop, tolerance = 1e-07)
- expect_equal(x9CodeBased$futilityPerStage, x9$futilityPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$earlyStop, x9$earlyStop, tolerance = 1e-07)
- expect_equal(x9CodeBased$successPerStage, x9$successPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$selectedArms, x9$selectedArms, tolerance = 1e-07)
- expect_equal(x9CodeBased$numberOfActiveArms, x9$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x9CodeBased$expectedNumberOfEvents, x9$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x9CodeBased$singleNumberOfEventsPerStage, x9$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x9CodeBased$conditionalPowerAchieved, x9$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x9), "character")
- df <- as.data.frame(x9)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x9)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x10 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Hierarchical",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x10' with expected results
- expect_equal(unlist(as.list(x10$eventsPerStage)), c(4, 56.657929, 125.67531, 3.7272727, 49.785816, 137.47812, 3.5, 31.249399, 83.970115, 3.3076923, 24.380086, 39.12662, 4, 50.333545, 107.06446, 3.8181818, 41.640149, 84.416884, 3.6666667, 39.507667, 64.61277, 3.5384615, 24.167144, 31.025997, 4, 45.952714, 80.461405, 3.9090909, 47.662083, 90.438818, 3.8333333, 33.911202, 59.016305, 3.7692308, 36.126326, 42.985179, 4, 39.486047, 79.550294, 4, 50.19027, 105.2747, 4, 37.6469, 62.752003, 4, 41.892876, 48.751729), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x10$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x10$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x10$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x10$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x10$iterations[3, ], c(6, 3, 2, 1), label = paste0("c(", paste0(x10$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x10$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x10$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x10$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x10$futilityStop, c(0.4, 0.7, 0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x10$futilityStop, collapse = ", "), ")"))
- expect_equal(x10$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x10$futilityPerStage[2, ], c(0.4, 0.7, 0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x10$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x10$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x10$earlyStop[2, ], c(0.4, 0.7, 0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(x10$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x10$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x10$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$selectedArms)), c(1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.5, 0.4, 1, 0.1, 0, 1, 0.4, 0, 1, 0.1, 0, 1, 0.2, 0, 1, 0.4, 0, 1, 0.3, 0, 1, 0.3, 0, 1, 0.2, 0.1, 1, 0.4, 0.1, 1, 0.4, 0, 1, 0.5, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$selectedArms)), collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x10$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[2, ], c(1.5, 1.2, 1.3, 1), tolerance = 1e-07, label = paste0("c(", paste0(x10$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x10$numberOfActiveArms[3, ], c(1.8333333, 1.3333333, 1, 1), tolerance = 1e-07, label = paste0("c(", paste0(x10$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x10$expectedNumberOfEvents, c(148.64919, 116.07216, 81.180483, 62.574824), tolerance = 1e-07, label = paste0("c(", paste0(x10$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x10$singleNumberOfEventsPerStage)), c(2, 20.705215, 34.508692, 1.9090909, 13.474672, 44.915572, 1.8333333, 5.5231227, 27.615613, 1.7692308, 0.78876811, 7.8876811, 2, 14.380832, 22.222222, 2, 5.2380952, 0, 2, 13.614724, 0, 2, 0.34505655, 0, 2, 10, 0, 2.0909091, 11.16912, 0, 2.1666667, 7.8515929, 0, 2.2307692, 12.073469, 0, 2, 3.5333333, 5.5555556, 2.1818182, 13.606399, 12.307692, 2.3333333, 11.420624, 0, 2.4615385, 17.609251, 0, 2, 31.952714, 34.508692, 1.8181818, 32.583872, 42.776735, 1.6666667, 22.226276, 25.105103, 1.5384615, 20.283626, 6.8588531), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x10$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x10$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[2, ], c(0.0031444794, 0.00037604601, 0.038145414, 0.045847923), tolerance = 1e-07, label = paste0("c(", paste0(x10$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x10$conditionalPowerAchieved[3, ], c(7.9302274e-08, 1.361166e-06, 0.16667791, 0.040805908), tolerance = 1e-07, label = paste0("c(", paste0(x10$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x10), NA)))
- expect_output(print(x10)$show())
- invisible(capture.output(expect_error(summary(x10), NA)))
- expect_output(summary(x10)$show())
- x10CodeBased <- eval(parse(text = getObjectRCode(x10, stringWrapParagraphWidth = NULL)))
- expect_equal(x10CodeBased$eventsPerStage, x10$eventsPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$iterations, x10$iterations, tolerance = 1e-07)
- expect_equal(x10CodeBased$rejectAtLeastOne, x10$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x10CodeBased$rejectedArmsPerStage, x10$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$futilityStop, x10$futilityStop, tolerance = 1e-07)
- expect_equal(x10CodeBased$futilityPerStage, x10$futilityPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$earlyStop, x10$earlyStop, tolerance = 1e-07)
- expect_equal(x10CodeBased$successPerStage, x10$successPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$selectedArms, x10$selectedArms, tolerance = 1e-07)
- expect_equal(x10CodeBased$numberOfActiveArms, x10$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x10CodeBased$expectedNumberOfEvents, x10$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x10CodeBased$singleNumberOfEventsPerStage, x10$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x10CodeBased$conditionalPowerAchieved, x10$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x10), "character")
- df <- as.data.frame(x10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x11 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(0.1, 0.3, 0.1),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Hierarchical",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x11' with expected results
- expect_equal(unlist(as.list(x11$eventsPerStage)), c(1.5454545, 1.5454545, 1.5454545, 2, 2, 2, 2.3846154, 2.3846154, 2.3846154, 2.3636364, 2.3636364, 2.3636364, 2.6666667, 2.6666667, 2.6666667, 2.9230769, 2.9230769, 2.9230769, 3.1818182, 3.1818182, 3.1818182, 3.3333333, 3.3333333, 3.3333333, 3.4615385, 3.4615385, 3.4615385, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x11$iterations[1, ], c(10, 10, 10), label = paste0("c(", paste0(x11$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x11$iterations[2, ], c(10, 10, 10), label = paste0("c(", paste0(x11$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x11$iterations[3, ], c(0, 0, 0), label = paste0("c(", paste0(x11$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x11$rejectAtLeastOne, c(0, 0, 0), label = paste0("c(", paste0(x11$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x11$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x11$futilityStop, c(0, 0, 0), label = paste0("c(", paste0(x11$futilityStop, collapse = ", "), ")"))
- expect_equal(x11$futilityPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x11$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x11$futilityPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x11$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x11$earlyStop[1, ], c(0, 0, 0), label = paste0("c(", paste0(x11$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x11$earlyStop[2, ], c(1, 1, 1), label = paste0("c(", paste0(x11$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x11$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[2, ], c(1, 1, 1), label = paste0("c(", paste0(x11$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x11$successPerStage[3, ], c(0, 0, 0), label = paste0("c(", paste0(x11$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x11$selectedArms)), collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0("c(", paste0(x11$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[2, ], c(0, 0, 0), label = paste0("c(", paste0(x11$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x11$numberOfActiveArms[3, ], c(NaN, NaN, NaN), label = paste0("c(", paste0(x11$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x11$expectedNumberOfEvents, c(NaN, NaN, NaN), label = paste0("c(", paste0(x11$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x11$singleNumberOfEventsPerStage)), c(1.1818182, 0, NaN, 1.3333333, 0, NaN, 1.4615385, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2.8181818, 0, NaN, 2.6666667, 0, NaN, 2.5384615, 0, NaN, 3.6363636, 0, NaN, 3.3333333, 0, NaN, 3.0769231, 0, NaN, 0.36363636, 0, NaN, 0.66666667, 0, NaN, 0.92307692, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x11$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x11$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[2, ], c(4.3545167e-12, 0.00033047407, 0.000196521), tolerance = 1e-07, label = paste0("c(", paste0(x11$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x11$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN), label = paste0("c(", paste0(x11$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x11), NA)))
- expect_output(print(x11)$show())
- invisible(capture.output(expect_error(summary(x11), NA)))
- expect_output(summary(x11)$show())
- x11CodeBased <- eval(parse(text = getObjectRCode(x11, stringWrapParagraphWidth = NULL)))
- expect_equal(x11CodeBased$eventsPerStage, x11$eventsPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$iterations, x11$iterations, tolerance = 1e-07)
- expect_equal(x11CodeBased$rejectAtLeastOne, x11$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x11CodeBased$rejectedArmsPerStage, x11$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$futilityStop, x11$futilityStop, tolerance = 1e-07)
- expect_equal(x11CodeBased$futilityPerStage, x11$futilityPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$earlyStop, x11$earlyStop, tolerance = 1e-07)
- expect_equal(x11CodeBased$successPerStage, x11$successPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$selectedArms, x11$selectedArms, tolerance = 1e-07)
- expect_equal(x11CodeBased$numberOfActiveArms, x11$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x11CodeBased$expectedNumberOfEvents, x11$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x11CodeBased$singleNumberOfEventsPerStage, x11$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x11CodeBased$conditionalPowerAchieved, x11$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x11), "character")
- df <- as.data.frame(x11)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x11)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x12 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4, directionUpper = FALSE, threshold = 0,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Hierarchical",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x12' with expected results
- expect_equal(unlist(as.list(x12$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x12$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x12$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x12$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x12$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x12$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x12$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x12$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x12$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x12$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x12$futilityStop, collapse = ", "), ")"))
- expect_equal(x12$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x12$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x12$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x12$earlyStop[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x12$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x12$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x12$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x12$selectedArms)), collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x12$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x12$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x12$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x12$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x12$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x12$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x12$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x12$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x12$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[2, ], c(0.00011390967, 0.0085722449, 0.0024797852, 0.0058179996), tolerance = 1e-07, label = paste0("c(", paste0(x12$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x12$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x12$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x12), NA)))
- expect_output(print(x12)$show())
- invisible(capture.output(expect_error(summary(x12), NA)))
- expect_output(summary(x12)$show())
- x12CodeBased <- eval(parse(text = getObjectRCode(x12, stringWrapParagraphWidth = NULL)))
- expect_equal(x12CodeBased$eventsPerStage, x12$eventsPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$iterations, x12$iterations, tolerance = 1e-07)
- expect_equal(x12CodeBased$rejectAtLeastOne, x12$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x12CodeBased$rejectedArmsPerStage, x12$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$futilityStop, x12$futilityStop, tolerance = 1e-07)
- expect_equal(x12CodeBased$futilityPerStage, x12$futilityPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$earlyStop, x12$earlyStop, tolerance = 1e-07)
- expect_equal(x12CodeBased$successPerStage, x12$successPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$selectedArms, x12$selectedArms, tolerance = 1e-07)
- expect_equal(x12CodeBased$numberOfActiveArms, x12$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x12CodeBased$expectedNumberOfEvents, x12$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x12CodeBased$singleNumberOfEventsPerStage, x12$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x12CodeBased$conditionalPowerAchieved, x12$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x12), "character")
- df <- as.data.frame(x12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x13 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "userDefined",
- activeArms = 4, directionUpper = FALSE, threshold = 0,
- plannedEvents = c(10, 30, 50), adaptations = rep(TRUE, 2),
- effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Sidak",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x13' with expected results
- expect_equal(unlist(as.list(x13$eventsPerStage)), c(5.5, 5.5, 5.5, 5, 5, 5, 6.5, 6.5, 6.5, 5.8333333, 5.8333333, 5.8333333, 6, 6, 6, 5.4166667, 5.4166667, 5.4166667, 7, 7, 7, 6.25, 6.25, 6.25), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x13$iterations[1, ], c(10, 10), label = paste0("c(", paste0(x13$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x13$iterations[2, ], c(10, 10), label = paste0("c(", paste0(x13$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x13$iterations[3, ], c(0, 0), label = paste0("c(", paste0(x13$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x13$rejectAtLeastOne, c(0, 0), label = paste0("c(", paste0(x13$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x13$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x13$futilityStop, c(0, 0), label = paste0("c(", paste0(x13$futilityStop, collapse = ", "), ")"))
- expect_equal(x13$futilityPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x13$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x13$futilityPerStage[2, ], c(0, 0), label = paste0("c(", paste0(x13$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x13$earlyStop[1, ], c(0, 0), label = paste0("c(", paste0(x13$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x13$earlyStop[2, ], c(1, 1), label = paste0("c(", paste0(x13$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[1, ], c(0, 0), label = paste0("c(", paste0(x13$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[2, ], c(1, 1), label = paste0("c(", paste0(x13$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x13$successPerStage[3, ], c(0, 0), label = paste0("c(", paste0(x13$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x13$selectedArms)), collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[1, ], c(4, 4), label = paste0("c(", paste0(x13$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[2, ], c(0, 0), label = paste0("c(", paste0(x13$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x13$numberOfActiveArms[3, ], c(NaN, NaN), label = paste0("c(", paste0(x13$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x13$expectedNumberOfEvents, c(NaN, NaN), label = paste0("c(", paste0(x13$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x13$singleNumberOfEventsPerStage)), c(0.5, 0, NaN, 0.83333333, 0, NaN, 1.5, 0, NaN, 1.6666667, 0, NaN, 1, 0, NaN, 1.25, 0, NaN, 2, 0, NaN, 2.0833333, 0, NaN, 5, 0, NaN, 4.1666667, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x13$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(x13$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[2, ], c(0.054930056, 0.084905999), tolerance = 1e-07, label = paste0("c(", paste0(x13$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x13$conditionalPowerAchieved[3, ], c(NaN, NaN), label = paste0("c(", paste0(x13$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x13), NA)))
- expect_output(print(x13)$show())
- invisible(capture.output(expect_error(summary(x13), NA)))
- expect_output(summary(x13)$show())
- x13CodeBased <- eval(parse(text = getObjectRCode(x13, stringWrapParagraphWidth = NULL)))
- expect_equal(x13CodeBased$eventsPerStage, x13$eventsPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$iterations, x13$iterations, tolerance = 1e-07)
- expect_equal(x13CodeBased$rejectAtLeastOne, x13$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x13CodeBased$rejectedArmsPerStage, x13$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$futilityStop, x13$futilityStop, tolerance = 1e-07)
- expect_equal(x13CodeBased$futilityPerStage, x13$futilityPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$earlyStop, x13$earlyStop, tolerance = 1e-07)
- expect_equal(x13CodeBased$successPerStage, x13$successPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$selectedArms, x13$selectedArms, tolerance = 1e-07)
- expect_equal(x13CodeBased$numberOfActiveArms, x13$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x13CodeBased$expectedNumberOfEvents, x13$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x13CodeBased$singleNumberOfEventsPerStage, x13$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x13CodeBased$conditionalPowerAchieved, x13$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x13), "character")
- df <- as.data.frame(x13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x14 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4, directionUpper = FALSE, threshold = 0,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Sidak",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x14' with expected results
- expect_equal(unlist(as.list(x14$eventsPerStage)), c(4, 4, 4, 4.1452587, 4.1452587, 4.1452587, 4.2627857, 4.2627857, 4.2627857, 4.3598306, 4.3598306, 4.3598306, 4, 4, 4, 4.1145653, 4.1145653, 4.1145653, 4.2072587, 4.2072587, 4.2072587, 4.2837979, 4.2837979, 4.2837979, 4, 4, 4, 4.0964933, 4.0964933, 4.0964933, 4.1745649, 4.1745649, 4.1745649, 4.2390305, 4.2390305, 4.2390305, 4, 4, 4, 4.0838719, 4.0838719, 4.0838719, 4.1517317, 4.1517317, 4.1517317, 4.2077651, 4.2077651, 4.2077651), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x14$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x14$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x14$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x14$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x14$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x14$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x14$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x14$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x14$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityStop, collapse = ", "), ")"))
- expect_equal(x14$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x14$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x14$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x14$earlyStop[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x14$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x14$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x14$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x14$selectedArms)), collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x14$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x14$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x14$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x14$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x14$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x14$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x14$singleNumberOfEventsPerStage)), c(2, 0, NaN, 1.9985289, 0, NaN, 1.9973387, 0, NaN, 1.996356, 0, NaN, 2, 0, NaN, 1.9678356, 0, NaN, 1.9418117, 0, NaN, 1.9203232, 0, NaN, 2, 0, NaN, 1.9497636, 0, NaN, 1.9091179, 0, NaN, 1.8755558, 0, NaN, 2, 0, NaN, 1.9371422, 0, NaN, 1.8862847, 0, NaN, 1.8442904, 0, NaN, 2, 0, NaN, 2.1467297, 0, NaN, 2.265447, 0, NaN, 2.3634747, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x14$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x14$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[2, ], c(0.00011390967, 0.008401317, 0.0019368562, 0.0045926774), tolerance = 1e-07, label = paste0("c(", paste0(x14$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x14$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x14$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x14), NA)))
- expect_output(print(x14)$show())
- invisible(capture.output(expect_error(summary(x14), NA)))
- expect_output(summary(x14)$show())
- x14CodeBased <- eval(parse(text = getObjectRCode(x14, stringWrapParagraphWidth = NULL)))
- expect_equal(x14CodeBased$eventsPerStage, x14$eventsPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$iterations, x14$iterations, tolerance = 1e-07)
- expect_equal(x14CodeBased$rejectAtLeastOne, x14$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x14CodeBased$rejectedArmsPerStage, x14$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$futilityStop, x14$futilityStop, tolerance = 1e-07)
- expect_equal(x14CodeBased$futilityPerStage, x14$futilityPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$earlyStop, x14$earlyStop, tolerance = 1e-07)
- expect_equal(x14CodeBased$successPerStage, x14$successPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$selectedArms, x14$selectedArms, tolerance = 1e-07)
- expect_equal(x14CodeBased$numberOfActiveArms, x14$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x14CodeBased$expectedNumberOfEvents, x14$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x14CodeBased$singleNumberOfEventsPerStage, x14$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x14CodeBased$conditionalPowerAchieved, x14$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x14), "character")
- df <- as.data.frame(x14)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x14)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x15 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "all",
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Sidak",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x15' with expected results
- expect_equal(unlist(as.list(x15$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x15$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x15$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x15$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x15$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x15$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x15$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x15$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x15$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x15$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityStop, collapse = ", "), ")"))
- expect_equal(x15$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x15$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x15$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x15$earlyStop[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x15$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x15$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x15$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x15$selectedArms)), collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x15$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x15$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x15$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x15$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x15$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x15$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x15$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x15$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x15$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[2, ], c(0.00011390967, 0.0085722449, 0.0024797852, 0.0058179996), tolerance = 1e-07, label = paste0("c(", paste0(x15$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x15$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x15$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x15), NA)))
- expect_output(print(x15)$show())
- invisible(capture.output(expect_error(summary(x15), NA)))
- expect_output(summary(x15)$show())
- x15CodeBased <- eval(parse(text = getObjectRCode(x15, stringWrapParagraphWidth = NULL)))
- expect_equal(x15CodeBased$eventsPerStage, x15$eventsPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$iterations, x15$iterations, tolerance = 1e-07)
- expect_equal(x15CodeBased$rejectAtLeastOne, x15$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x15CodeBased$rejectedArmsPerStage, x15$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$futilityStop, x15$futilityStop, tolerance = 1e-07)
- expect_equal(x15CodeBased$futilityPerStage, x15$futilityPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$earlyStop, x15$earlyStop, tolerance = 1e-07)
- expect_equal(x15CodeBased$successPerStage, x15$successPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$selectedArms, x15$selectedArms, tolerance = 1e-07)
- expect_equal(x15CodeBased$numberOfActiveArms, x15$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x15CodeBased$expectedNumberOfEvents, x15$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x15CodeBased$singleNumberOfEventsPerStage, x15$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x15CodeBased$conditionalPowerAchieved, x15$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x15), "character")
- df <- as.data.frame(x15)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x15)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x16 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "rBest", rValue = 2,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Simes",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x16' with expected results
- expect_equal(unlist(as.list(x16$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x16$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x16$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x16$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x16$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x16$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x16$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x16$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x16$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x16$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityStop, collapse = ", "), ")"))
- expect_equal(x16$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x16$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x16$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x16$earlyStop[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x16$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x16$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x16$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x16$selectedArms)), collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x16$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x16$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x16$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x16$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x16$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x16$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x16$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x16$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x16$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[2, ], c(0.00011390967, 0.0085722449, 0.0024797852, 0.0058179996), tolerance = 1e-07, label = paste0("c(", paste0(x16$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x16$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x16$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x16), NA)))
- expect_output(print(x16)$show())
- invisible(capture.output(expect_error(summary(x16), NA)))
- expect_output(summary(x16)$show())
- x16CodeBased <- eval(parse(text = getObjectRCode(x16, stringWrapParagraphWidth = NULL)))
- expect_equal(x16CodeBased$eventsPerStage, x16$eventsPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$iterations, x16$iterations, tolerance = 1e-07)
- expect_equal(x16CodeBased$rejectAtLeastOne, x16$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x16CodeBased$rejectedArmsPerStage, x16$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$futilityStop, x16$futilityStop, tolerance = 1e-07)
- expect_equal(x16CodeBased$futilityPerStage, x16$futilityPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$earlyStop, x16$earlyStop, tolerance = 1e-07)
- expect_equal(x16CodeBased$successPerStage, x16$successPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$selectedArms, x16$selectedArms, tolerance = 1e-07)
- expect_equal(x16CodeBased$numberOfActiveArms, x16$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x16CodeBased$expectedNumberOfEvents, x16$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x16CodeBased$singleNumberOfEventsPerStage, x16$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x16CodeBased$conditionalPowerAchieved, x16$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x16), "character")
- df <- as.data.frame(x16)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x16)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x17 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Simes",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x17' with expected results
- expect_equal(unlist(as.list(x17$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x17$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x17$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x17$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x17$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x17$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x17$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x17$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x17$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x17$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityStop, collapse = ", "), ")"))
- expect_equal(x17$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x17$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x17$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x17$earlyStop[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x17$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x17$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x17$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x17$selectedArms)), collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x17$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x17$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x17$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x17$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x17$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x17$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x17$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x17$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x17$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[2, ], c(0.00011390967, 0.0085722449, 0.0024797852, 0.0058179996), tolerance = 1e-07, label = paste0("c(", paste0(x17$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x17$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x17$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x17), NA)))
- expect_output(print(x17)$show())
- invisible(capture.output(expect_error(summary(x17), NA)))
- expect_output(summary(x17)$show())
- x17CodeBased <- eval(parse(text = getObjectRCode(x17, stringWrapParagraphWidth = NULL)))
- expect_equal(x17CodeBased$eventsPerStage, x17$eventsPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$iterations, x17$iterations, tolerance = 1e-07)
- expect_equal(x17CodeBased$rejectAtLeastOne, x17$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x17CodeBased$rejectedArmsPerStage, x17$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$futilityStop, x17$futilityStop, tolerance = 1e-07)
- expect_equal(x17CodeBased$futilityPerStage, x17$futilityPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$earlyStop, x17$earlyStop, tolerance = 1e-07)
- expect_equal(x17CodeBased$successPerStage, x17$successPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$selectedArms, x17$selectedArms, tolerance = 1e-07)
- expect_equal(x17CodeBased$numberOfActiveArms, x17$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x17CodeBased$expectedNumberOfEvents, x17$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x17CodeBased$singleNumberOfEventsPerStage, x17$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x17CodeBased$conditionalPowerAchieved, x17$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x17), "character")
- df <- as.data.frame(x17)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x17)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x18 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Simes",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x18' with expected results
- expect_equal(unlist(as.list(x18$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x18$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x18$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x18$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x18$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x18$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x18$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x18$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x18$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x18$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityStop, collapse = ", "), ")"))
- expect_equal(x18$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x18$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x18$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x18$earlyStop[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x18$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x18$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x18$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x18$selectedArms)), collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x18$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x18$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x18$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x18$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x18$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x18$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x18$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x18$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x18$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[2, ], c(0.00011390967, 0.0085722449, 0.0024797852, 0.0058179996), tolerance = 1e-07, label = paste0("c(", paste0(x18$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x18$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x18$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x18), NA)))
- expect_output(print(x18)$show())
- invisible(capture.output(expect_error(summary(x18), NA)))
- expect_output(summary(x18)$show())
- x18CodeBased <- eval(parse(text = getObjectRCode(x18, stringWrapParagraphWidth = NULL)))
- expect_equal(x18CodeBased$eventsPerStage, x18$eventsPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$iterations, x18$iterations, tolerance = 1e-07)
- expect_equal(x18CodeBased$rejectAtLeastOne, x18$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x18CodeBased$rejectedArmsPerStage, x18$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$futilityStop, x18$futilityStop, tolerance = 1e-07)
- expect_equal(x18CodeBased$futilityPerStage, x18$futilityPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$earlyStop, x18$earlyStop, tolerance = 1e-07)
- expect_equal(x18CodeBased$successPerStage, x18$successPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$selectedArms, x18$selectedArms, tolerance = 1e-07)
- expect_equal(x18CodeBased$numberOfActiveArms, x18$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x18CodeBased$expectedNumberOfEvents, x18$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x18CodeBased$singleNumberOfEventsPerStage, x18$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x18CodeBased$conditionalPowerAchieved, x18$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x18), "character")
- df <- as.data.frame(x18)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x18)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x19 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "all",
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- intersectionTest = "Bonferroni",
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x19' with expected results
- expect_equal(unlist(as.list(x19$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x19$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x19$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x19$iterations[2, ], c(1, 6, 4, 7), label = paste0("c(", paste0(x19$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x19$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x19$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x19$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x19$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x19$futilityStop, c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x19$futilityStop, collapse = ", "), ")"))
- expect_equal(x19$futilityPerStage[1, ], c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x19$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x19$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x19$earlyStop[1, ], c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x19$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x19$earlyStop[2, ], c(0.1, 0.6, 0.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x19$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[2, ], c(0.1, 0.6, 0.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x19$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x19$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x19$selectedArms)), collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x19$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x19$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x19$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x19$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x19$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x19$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x19$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x19$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x19$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[2, ], c(0.0011390967, 0.014287075, 0.0061994629, 0.0083114281), tolerance = 1e-07, label = paste0("c(", paste0(x19$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x19$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x19$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x19), NA)))
- expect_output(print(x19)$show())
- invisible(capture.output(expect_error(summary(x19), NA)))
- expect_output(summary(x19)$show())
- x19CodeBased <- eval(parse(text = getObjectRCode(x19, stringWrapParagraphWidth = NULL)))
- expect_equal(x19CodeBased$eventsPerStage, x19$eventsPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$iterations, x19$iterations, tolerance = 1e-07)
- expect_equal(x19CodeBased$rejectAtLeastOne, x19$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x19CodeBased$rejectedArmsPerStage, x19$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$futilityStop, x19$futilityStop, tolerance = 1e-07)
- expect_equal(x19CodeBased$futilityPerStage, x19$futilityPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$earlyStop, x19$earlyStop, tolerance = 1e-07)
- expect_equal(x19CodeBased$successPerStage, x19$successPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$selectedArms, x19$selectedArms, tolerance = 1e-07)
- expect_equal(x19CodeBased$numberOfActiveArms, x19$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x19CodeBased$expectedNumberOfEvents, x19$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x19CodeBased$singleNumberOfEventsPerStage, x19$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x19CodeBased$conditionalPowerAchieved, x19$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x19), "character")
- df <- as.data.frame(x19)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x19)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x20 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "rBest", rValue = 2,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x20' with expected results
- expect_equal(unlist(as.list(x20$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x20$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x20$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x20$iterations[2, ], c(1, 6, 4, 7), label = paste0("c(", paste0(x20$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x20$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x20$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x20$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x20$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x20$futilityStop, c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x20$futilityStop, collapse = ", "), ")"))
- expect_equal(x20$futilityPerStage[1, ], c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x20$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x20$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x20$earlyStop[1, ], c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x20$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x20$earlyStop[2, ], c(0.1, 0.6, 0.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x20$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[2, ], c(0.1, 0.6, 0.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x20$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x20$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x20$selectedArms)), collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x20$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x20$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x20$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x20$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x20$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x20$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x20$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x20$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x20$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[2, ], c(0.0011390967, 0.014287075, 0.0061994629, 0.0083114281), tolerance = 1e-07, label = paste0("c(", paste0(x20$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x20$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x20$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x20), NA)))
- expect_output(print(x20)$show())
- invisible(capture.output(expect_error(summary(x20), NA)))
- expect_output(summary(x20)$show())
- x20CodeBased <- eval(parse(text = getObjectRCode(x20, stringWrapParagraphWidth = NULL)))
- expect_equal(x20CodeBased$eventsPerStage, x20$eventsPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$iterations, x20$iterations, tolerance = 1e-07)
- expect_equal(x20CodeBased$rejectAtLeastOne, x20$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x20CodeBased$rejectedArmsPerStage, x20$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$futilityStop, x20$futilityStop, tolerance = 1e-07)
- expect_equal(x20CodeBased$futilityPerStage, x20$futilityPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$earlyStop, x20$earlyStop, tolerance = 1e-07)
- expect_equal(x20CodeBased$successPerStage, x20$successPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$selectedArms, x20$selectedArms, tolerance = 1e-07)
- expect_equal(x20CodeBased$numberOfActiveArms, x20$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x20CodeBased$expectedNumberOfEvents, x20$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x20CodeBased$singleNumberOfEventsPerStage, x20$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x20CodeBased$conditionalPowerAchieved, x20$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x20), "character")
- df <- as.data.frame(x20)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x20)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x21 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
- plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
- intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x21' with expected results
- expect_equal(unlist(as.list(x21$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x21$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x21$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x21$iterations[2, ], c(1, 6, 4, 7), label = paste0("c(", paste0(x21$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x21$iterations[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x21$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0("c(", paste0(x21$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0("c(", paste0(unlist(as.list(x21$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x21$futilityStop, c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x21$futilityStop, collapse = ", "), ")"))
- expect_equal(x21$futilityPerStage[1, ], c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x21$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x21$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x21$earlyStop[1, ], c(0.9, 0.4, 0.6, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x21$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x21$earlyStop[2, ], c(0.1, 0.6, 0.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x21$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[2, ], c(0.1, 0.6, 0.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x21$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x21$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0("c(", paste0(unlist(as.list(x21$selectedArms)), collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x21$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x21$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x21$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x21$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x21$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x21$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x21$singleNumberOfEventsPerStage)), c(2, 0, NaN, 2.0909091, 0, NaN, 2.1666667, 0, NaN, 2.2307692, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 2, 0, NaN, 1.9090909, 0, NaN, 1.8333333, 0, NaN, 1.7692308, 0, NaN, 2, 0, NaN, 1.8181818, 0, NaN, 1.6666667, 0, NaN, 1.5384615, 0, NaN, 2, 0, NaN, 2.1818182, 0, NaN, 2.3333333, 0, NaN, 2.4615385, 0, NaN), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x21$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x21$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[2, ], c(0.0011390967, 0.014287075, 0.0061994629, 0.0083114281), tolerance = 1e-07, label = paste0("c(", paste0(x21$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x21$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN, NaN), label = paste0("c(", paste0(x21$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x21), NA)))
- expect_output(print(x21)$show())
- invisible(capture.output(expect_error(summary(x21), NA)))
- expect_output(summary(x21)$show())
- x21CodeBased <- eval(parse(text = getObjectRCode(x21, stringWrapParagraphWidth = NULL)))
- expect_equal(x21CodeBased$eventsPerStage, x21$eventsPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$iterations, x21$iterations, tolerance = 1e-07)
- expect_equal(x21CodeBased$rejectAtLeastOne, x21$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x21CodeBased$rejectedArmsPerStage, x21$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$futilityStop, x21$futilityStop, tolerance = 1e-07)
- expect_equal(x21CodeBased$futilityPerStage, x21$futilityPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$earlyStop, x21$earlyStop, tolerance = 1e-07)
- expect_equal(x21CodeBased$successPerStage, x21$successPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$selectedArms, x21$selectedArms, tolerance = 1e-07)
- expect_equal(x21CodeBased$numberOfActiveArms, x21$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x21CodeBased$expectedNumberOfEvents, x21$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x21CodeBased$singleNumberOfEventsPerStage, x21$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x21CodeBased$conditionalPowerAchieved, x21$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x21), "character")
- df <- as.data.frame(x21)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x21)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x22 <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- activeArms = 4, directionUpper = FALSE, threshold = 0.1,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Bonferroni",
- conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x22' with expected results
- expect_equal(unlist(as.list(x22$eventsPerStage)), c(6.4545455, 6.8585859, 6.8585859, 6, 7.7910813, 7.7910813, 5.6153846, 6.7788202, 6.7788202, 5.6363636, 6.040404, 6.040404, 5.3333333, 7.3387003, 7.3387003, 5.0769231, 6.4373284, 6.4373284, 4.8181818, 5.2222222, 5.2222222, 4.6666667, 6.6503709, 6.6503709, 4.5384615, 5.7018972, 5.7018972, 4, 4.4444444, 4.4444444, 4, 5.9815574, 5.9815574, 4, 5.4215572, 5.4215572), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x22$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x22$iterations[1, ], c(10, 10, 10), label = paste0("c(", paste0(x22$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x22$iterations[2, ], c(9, 7, 8), label = paste0("c(", paste0(x22$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x22$iterations[3, ], c(0, 1, 1), label = paste0("c(", paste0(x22$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x22$rejectAtLeastOne, c(0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x22$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0, 0.2, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x22$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x22$futilityStop, c(0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x22$futilityStop, collapse = ", "), ")"))
- expect_equal(x22$futilityPerStage[1, ], c(0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x22$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x22$futilityPerStage[2, ], c(0, 0, 0), label = paste0("c(", paste0(x22$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x22$earlyStop[1, ], c(0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x22$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x22$earlyStop[2, ], c(0.9, 0.6, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x22$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[1, ], c(0, 0, 0), label = paste0("c(", paste0(x22$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[2, ], c(0.9, 0.6, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(x22$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x22$successPerStage[3, ], c(0, 0.1, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x22$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0.1, 0, 1, 0.1, 0, 1, 0, 0, 1, 0.1, 0, 1, 0, 0, 1, 0.1, 0, 1, 0.2, 0, 1, 0.2, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x22$selectedArms)), collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0("c(", paste0(x22$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[2, ], c(0.11111111, 0.57142857, 0.375), tolerance = 1e-07, label = paste0("c(", paste0(x22$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x22$numberOfActiveArms[3, ], c(NaN, 0, 0), label = paste0("c(", paste0(x22$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x22$expectedNumberOfEvents, c(NaN, 11.671926, 11.294822), tolerance = 1e-07, label = paste0("c(", paste0(x22$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x22$singleNumberOfEventsPerStage)), c(2.8181818, 0, NaN, 2.6666667, 0, 0, 2.5384615, 0, 0, 2, 0, NaN, 2, 0.21428571, 0, 2, 0.1969697, 0, 1.1818182, 0, NaN, 1.3333333, 0.19262298, 0, 1.4615385, 0, 0, 0.36363636, 0.04040404, NaN, 0.66666667, 0.19047619, 0, 0.92307692, 0.2581216, 0, 3.6363636, 0.4040404, NaN, 3.3333333, 1.7910813, 0, 3.0769231, 1.1634356, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x22$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x22$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[2, ], c(0.12059149, 0.53514871, 0.32608065), tolerance = 1e-07, label = paste0("c(", paste0(x22$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x22$conditionalPowerAchieved[3, ], c(NaN, 0.24333814, 0.15904956), tolerance = 1e-07, label = paste0("c(", paste0(x22$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x22), NA)))
- expect_output(print(x22)$show())
- invisible(capture.output(expect_error(summary(x22), NA)))
- expect_output(summary(x22)$show())
- x22CodeBased <- eval(parse(text = getObjectRCode(x22, stringWrapParagraphWidth = NULL)))
- expect_equal(x22CodeBased$eventsPerStage, x22$eventsPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$iterations, x22$iterations, tolerance = 1e-07)
- expect_equal(x22CodeBased$rejectAtLeastOne, x22$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(x22CodeBased$rejectedArmsPerStage, x22$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$futilityStop, x22$futilityStop, tolerance = 1e-07)
- expect_equal(x22CodeBased$futilityPerStage, x22$futilityPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$earlyStop, x22$earlyStop, tolerance = 1e-07)
- expect_equal(x22CodeBased$successPerStage, x22$successPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$selectedArms, x22$selectedArms, tolerance = 1e-07)
- expect_equal(x22CodeBased$numberOfActiveArms, x22$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(x22CodeBased$expectedNumberOfEvents, x22$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(x22CodeBased$singleNumberOfEventsPerStage, x22$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(x22CodeBased$conditionalPowerAchieved, x22$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x22), "character")
- df <- as.data.frame(x22)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x22)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetBonferroni}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ # @refFS[Formula]{fs:adjustedPValueSubsetHierarchical}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSidak}
+ # @refFS[Formula]{fs:adjustedPValueSubsetSimes}
+ x1 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x1' with expected results
+ expect_equal(unlist(as.list(x1$eventsPerStage)), c(4, 56.544006, 118.06218, 3.7272727, 45.869846, 102.75827, 3.5, 30.37664, 63.385959, 3.3076923, 32.448585, 72.264513, 4, 49.635155, 106.15332, 3.8181818, 36.042521, 83.474993, 3.6666667, 30.759757, 64.009577, 3.5384615, 32.768737, 72.921706, 4, 65.124183, 133.16052, 3.9090909, 38.113637, 101.03155, 3.8333333, 29.450577, 70.659781, 3.7692308, 37.063433, 93.1602, 4, 43.825836, 90.344006, 4, 31.654176, 76.670094, 4, 38.617451, 74.294998, 4, 39.885794, 87.433784), tolerance = 1e-07, label = paste0(unlist(as.list(x1$eventsPerStage))))
+ expect_equal(x1$iterations[1, ], c(10, 10, 10, 10), label = paste0(x1$iterations[1, ]))
+ expect_equal(x1$iterations[2, ], c(10, 10, 10, 10), label = paste0(x1$iterations[2, ]))
+ expect_equal(x1$iterations[3, ], c(10, 10, 9, 9), label = paste0(x1$iterations[3, ]))
+ expect_equal(x1$rejectAtLeastOne, c(0, 0.1, 0.4, 0.5), tolerance = 1e-07, label = paste0(x1$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x1$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x1$rejectedArmsPerStage))))
+ expect_equal(x1$futilityStop, c(0, 0, 0, 0), label = paste0(x1$futilityStop))
+ expect_equal(x1$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x1$futilityPerStage[1, ]))
+ expect_equal(x1$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x1$futilityPerStage[2, ]))
+ expect_equal(x1$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x1$earlyStop[1, ]))
+ expect_equal(x1$earlyStop[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x1$earlyStop[2, ]))
+ expect_equal(x1$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x1$successPerStage[1, ]))
+ expect_equal(x1$successPerStage[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x1$successPerStage[2, ]))
+ expect_equal(x1$successPerStage[3, ], c(0, 0.1, 0.3, 0.4), tolerance = 1e-07, label = paste0(x1$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x1$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.2, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x1$selectedArms))))
+ expect_equal(x1$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x1$numberOfActiveArms[1, ]))
+ expect_equal(x1$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x1$numberOfActiveArms[2, ]))
+ expect_equal(x1$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x1$numberOfActiveArms[3, ]))
+ expect_equal(x1$expectedNumberOfEvents, c(182.68801, 153.5825, 114.70922, 140.61265), tolerance = 1e-07, label = paste0(x1$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x1$singleNumberOfEventsPerStage)), c(2, 12.71817, 15, 1.9090909, 15.365854, 15.365854, 1.8333333, 5.2380952, 5.8201058, 1.7692308, 5.5627907, 5.9431525, 2, 5.8093191, 10, 2, 5.447619, 5.9099062, 2, 5.4545455, 6.0606061, 2, 5.6521739, 6.2801932, 2, 21.298347, 21.51817, 2.0909091, 7.4278263, 21.395349, 2.1666667, 3.9786992, 14.01999, 2.2307692, 9.7161004, 22.223992, 2, 0, 0, 2.1818182, 0.87745601, 3.4933517, 2.3333333, 12.978906, 8.4883336, 2.4615385, 12.307692, 13.675214, 2, 39.825836, 46.51817, 1.8181818, 26.77672, 41.522566, 1.6666667, 21.638545, 27.189214, 1.5384615, 23.578102, 33.872776), tolerance = 1e-07, label = paste0(unlist(as.list(x1$singleNumberOfEventsPerStage))))
+ expect_equal(x1$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPowerAchieved[1, ]))
+ expect_equal(x1$conditionalPowerAchieved[2, ], c(5.8245202e-05, 0.033918251, 0.017570415, 0.062651459), tolerance = 1e-07, label = paste0(x1$conditionalPowerAchieved[2, ]))
+ expect_equal(x1$conditionalPowerAchieved[3, ], c(0.081443645, 0.17714318, 0.49831, 0.30622362), tolerance = 1e-07, label = paste0(x1$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x1), NA)))
+ expect_output(print(x1)$show())
+ invisible(capture.output(expect_error(summary(x1), NA)))
+ expect_output(summary(x1)$show())
+ x1CodeBased <- eval(parse(text = getObjectRCode(x1, stringWrapParagraphWidth = NULL)))
+ expect_equal(x1CodeBased$eventsPerStage, x1$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$iterations, x1$iterations, tolerance = 1e-07)
+ expect_equal(x1CodeBased$rejectAtLeastOne, x1$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x1CodeBased$rejectedArmsPerStage, x1$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$futilityStop, x1$futilityStop, tolerance = 1e-07)
+ expect_equal(x1CodeBased$futilityPerStage, x1$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$earlyStop, x1$earlyStop, tolerance = 1e-07)
+ expect_equal(x1CodeBased$successPerStage, x1$successPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$selectedArms, x1$selectedArms, tolerance = 1e-07)
+ expect_equal(x1CodeBased$numberOfActiveArms, x1$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x1CodeBased$expectedNumberOfEvents, x1$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x1CodeBased$singleNumberOfEventsPerStage, x1$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPowerAchieved, x1$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x1), "character")
+ df <- as.data.frame(x1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ .skipTestIfDisabled()
+
+ x2 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "userDefined", activeArms = 4,
+ plannedEvents = c(10, 30, 50), adaptations = rep(TRUE, 2),
+ effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x2' with expected results
+ expect_equal(unlist(as.list(x2$eventsPerStage)), c(5.5, 83.888278, 161.11661, 5, 67.731433, 137.0436, 6.5, 94.119048, 179.03968, 5.8333333, 80.884792, 166.06998, 6, 91.054945, 173.83883, 5.4166667, 70.455792, 139.76796, 7, 91.102564, 177.8547, 6.25, 81.100963, 165.22795), tolerance = 1e-07, label = paste0(unlist(as.list(x2$eventsPerStage))))
+ expect_equal(x2$iterations[1, ], c(10, 10), label = paste0(x2$iterations[1, ]))
+ expect_equal(x2$iterations[2, ], c(10, 10), label = paste0(x2$iterations[2, ]))
+ expect_equal(x2$iterations[3, ], c(3, 9), label = paste0(x2$iterations[3, ]))
+ expect_equal(x2$rejectAtLeastOne, c(0, 0), label = paste0(x2$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x2$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x2$rejectedArmsPerStage))))
+ expect_equal(x2$futilityStop, c(0.7, 0.1), tolerance = 1e-07, label = paste0(x2$futilityStop))
+ expect_equal(x2$futilityPerStage[1, ], c(0, 0), label = paste0(x2$futilityPerStage[1, ]))
+ expect_equal(x2$futilityPerStage[2, ], c(0.7, 0.1), tolerance = 1e-07, label = paste0(x2$futilityPerStage[2, ]))
+ expect_equal(x2$earlyStop[1, ], c(0, 0), label = paste0(x2$earlyStop[1, ]))
+ expect_equal(x2$earlyStop[2, ], c(0.7, 0.1), tolerance = 1e-07, label = paste0(x2$earlyStop[2, ]))
+ expect_equal(x2$successPerStage[1, ], c(0, 0), label = paste0(x2$successPerStage[1, ]))
+ expect_equal(x2$successPerStage[2, ], c(0, 0), label = paste0(x2$successPerStage[2, ]))
+ expect_equal(x2$successPerStage[3, ], c(0, 0), label = paste0(x2$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x2$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0.4, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.1, 1, 0.1, 0, 1, 0.2, 0.1, 1, 0.4, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x2$selectedArms))))
+ expect_equal(x2$numberOfActiveArms[1, ], c(4, 4), label = paste0(x2$numberOfActiveArms[1, ]))
+ expect_equal(x2$numberOfActiveArms[2, ], c(1, 1), label = paste0(x2$numberOfActiveArms[2, ]))
+ expect_equal(x2$numberOfActiveArms[3, ], c(1, 1), label = paste0(x2$numberOfActiveArms[3, ]))
+ expect_equal(x2$expectedNumberOfEvents, c(140, 189.47868), tolerance = 1e-07, label = paste0(x2$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x2$singleNumberOfEventsPerStage)), c(0.5, 0, 0, 0.83333333, 0, 0, 1.5, 9.2307692, 7.6923077, 1.6666667, 12.320026, 15.873016, 1, 6.6666667, 5.5555556, 1.25, 2.3076923, 0, 2, 5.7142857, 9.5238095, 2.0833333, 12.119531, 14.814815, 5, 78.388278, 77.228327, 4.1666667, 62.731433, 69.312169), tolerance = 1e-07, label = paste0(unlist(as.list(x2$singleNumberOfEventsPerStage))))
+ expect_equal(x2$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_), label = paste0(x2$conditionalPowerAchieved[1, ]))
+ expect_equal(x2$conditionalPowerAchieved[2, ], c(0, 1.5253195e-09), tolerance = 1e-07, label = paste0(x2$conditionalPowerAchieved[2, ]))
+ expect_equal(x2$conditionalPowerAchieved[3, ], c(0, 1.1842379e-15), tolerance = 1e-07, label = paste0(x2$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x2), NA)))
+ expect_output(print(x2)$show())
+ invisible(capture.output(expect_error(summary(x2), NA)))
+ expect_output(summary(x2)$show())
+ x2CodeBased <- eval(parse(text = getObjectRCode(x2, stringWrapParagraphWidth = NULL)))
+ expect_equal(x2CodeBased$eventsPerStage, x2$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$iterations, x2$iterations, tolerance = 1e-07)
+ expect_equal(x2CodeBased$rejectAtLeastOne, x2$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x2CodeBased$rejectedArmsPerStage, x2$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$futilityStop, x2$futilityStop, tolerance = 1e-07)
+ expect_equal(x2CodeBased$futilityPerStage, x2$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$earlyStop, x2$earlyStop, tolerance = 1e-07)
+ expect_equal(x2CodeBased$successPerStage, x2$successPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$selectedArms, x2$selectedArms, tolerance = 1e-07)
+ expect_equal(x2CodeBased$numberOfActiveArms, x2$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x2CodeBased$expectedNumberOfEvents, x2$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x2CodeBased$singleNumberOfEventsPerStage, x2$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPowerAchieved, x2$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x2), "character")
+ df <- as.data.frame(x2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x3 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x3' with expected results
+ expect_equal(unlist(as.list(x3$eventsPerStage)), c(4, 56.544006, 118.06218, 3.8499139, 46.858849, 105.91374, 3.7209785, 37.392533, 79.701207, 3.6090171, 41.322916, 96.584767, 4, 49.635155, 106.15332, 3.8816273, 36.741574, 86.112527, 3.7799362, 32.140988, 69.139159, 3.6916324, 34.296961, 77.330183, 4, 65.124183, 133.16052, 3.9002999, 39.328667, 103.83053, 3.8146499, 31.005549, 75.358715, 3.7402755, 36.850923, 90.063067, 4, 43.825836, 90.344006, 3.9133408, 32.25912, 80.994092, 3.8388939, 33.67594, 74.187296, 3.7742477, 34.474746, 77.613714), tolerance = 1e-07, label = paste0(unlist(as.list(x3$eventsPerStage))))
+ expect_equal(x3$iterations[1, ], c(10, 10, 10, 10), label = paste0(x3$iterations[1, ]))
+ expect_equal(x3$iterations[2, ], c(10, 10, 10, 10), label = paste0(x3$iterations[2, ]))
+ expect_equal(x3$iterations[3, ], c(10, 10, 10, 9), label = paste0(x3$iterations[3, ]))
+ expect_equal(x3$rejectAtLeastOne, c(0, 0.1, 0.3, 0.3), tolerance = 1e-07, label = paste0(x3$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x3$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x3$rejectedArmsPerStage))))
+ expect_equal(x3$futilityStop, c(0, 0, 0, 0), label = paste0(x3$futilityStop))
+ expect_equal(x3$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x3$futilityPerStage[1, ]))
+ expect_equal(x3$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x3$futilityPerStage[2, ]))
+ expect_equal(x3$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x3$earlyStop[1, ]))
+ expect_equal(x3$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x3$earlyStop[2, ]))
+ expect_equal(x3$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x3$successPerStage[1, ]))
+ expect_equal(x3$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x3$successPerStage[2, ]))
+ expect_equal(x3$successPerStage[3, ], c(0, 0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0(x3$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x3$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.4, 0.3, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0, 0, 1, 0.1, 0.1, 1, 0.3, 0.3, 1, 0.1, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x3$selectedArms))))
+ expect_equal(x3$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x3$numberOfActiveArms[1, ]))
+ expect_equal(x3$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x3$numberOfActiveArms[2, ]))
+ expect_equal(x3$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x3$numberOfActiveArms[3, ]))
+ expect_equal(x3$expectedNumberOfEvents, c(182.68801, 158.69386, 129.88152, 143.2193), tolerance = 1e-07, label = paste0(x3$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x3$singleNumberOfEventsPerStage)), c(2, 12.71817, 15, 2.0015199, 15.596608, 15.596608, 2.0028257, 10.765048, 10.765048, 2.0039595, 12.760745, 18.508821, 2, 5.8093191, 10, 2.0332334, 5.447619, 5.9126663, 2.0617834, 5.4545455, 5.4545455, 2.0865748, 5.6521739, 6.2801932, 2, 21.298347, 21.51817, 2.0519059, 8.0160405, 21.043571, 2.0964971, 4.2843932, 12.80954, 2.135218, 8.1574931, 16.459114, 2, 0, 0, 2.0649468, 0.93345197, 5.2766854, 2.120741, 6.9305404, 8.9677303, 2.1691901, 5.7473444, 6.3859382, 2, 39.825836, 46.51817, 1.848394, 27.412327, 43.458287, 1.7181528, 22.906506, 31.543625, 1.6050576, 24.953154, 36.753029), tolerance = 1e-07, label = paste0(unlist(as.list(x3$singleNumberOfEventsPerStage))))
+ expect_equal(x3$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPowerAchieved[1, ]))
+ expect_equal(x3$conditionalPowerAchieved[2, ], c(5.8245202e-05, 0.027881828, 0.017394693, 0.05621525), tolerance = 1e-07, label = paste0(x3$conditionalPowerAchieved[2, ]))
+ expect_equal(x3$conditionalPowerAchieved[3, ], c(0.081443645, 0.17047212, 0.40326875, 0.20898924), tolerance = 1e-07, label = paste0(x3$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x3), NA)))
+ expect_output(print(x3)$show())
+ invisible(capture.output(expect_error(summary(x3), NA)))
+ expect_output(summary(x3)$show())
+ x3CodeBased <- eval(parse(text = getObjectRCode(x3, stringWrapParagraphWidth = NULL)))
+ expect_equal(x3CodeBased$eventsPerStage, x3$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$iterations, x3$iterations, tolerance = 1e-07)
+ expect_equal(x3CodeBased$rejectAtLeastOne, x3$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x3CodeBased$rejectedArmsPerStage, x3$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$futilityStop, x3$futilityStop, tolerance = 1e-07)
+ expect_equal(x3CodeBased$futilityPerStage, x3$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$earlyStop, x3$earlyStop, tolerance = 1e-07)
+ expect_equal(x3CodeBased$successPerStage, x3$successPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$selectedArms, x3$selectedArms, tolerance = 1e-07)
+ expect_equal(x3CodeBased$numberOfActiveArms, x3$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x3CodeBased$expectedNumberOfEvents, x3$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x3CodeBased$singleNumberOfEventsPerStage, x3$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPowerAchieved, x3$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x3), "character")
+ df <- as.data.frame(x3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x4 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "all",
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x4' with expected results
+ expect_equal(unlist(as.list(x4$eventsPerStage)), c(4, 43.80534, 83.80534, 3.7272727, 41, 78.272727, 3.5, 36.991095, 71.991095, 3.3076923, 31.601422, 64.678345, 4, 43.80534, 83.80534, 3.8181818, 42, 80.181818, 3.6666667, 38.752575, 75.419242, 3.5384615, 33.806172, 69.190787, 4, 43.80534, 83.80534, 3.9090909, 43, 82.090909, 3.8333333, 40.514056, 78.847389, 3.7692308, 36.010922, 73.70323, 4, 43.80534, 83.80534, 4, 44, 84, 4, 42.275537, 82.275537, 4, 38.215673, 78.215673), tolerance = 1e-07, label = paste0(unlist(as.list(x4$eventsPerStage))))
+ expect_equal(x4$iterations[1, ], c(10, 10, 10, 10), label = paste0(x4$iterations[1, ]))
+ expect_equal(x4$iterations[2, ], c(10, 10, 10, 10), label = paste0(x4$iterations[2, ]))
+ expect_equal(x4$iterations[3, ], c(10, 10, 10, 10), label = paste0(x4$iterations[3, ]))
+ expect_equal(x4$rejectAtLeastOne, c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x4$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x4$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x4$rejectedArmsPerStage))))
+ expect_equal(x4$futilityStop, c(0, 0, 0, 0), label = paste0(x4$futilityStop))
+ expect_equal(x4$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x4$futilityPerStage[1, ]))
+ expect_equal(x4$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x4$futilityPerStage[2, ]))
+ expect_equal(x4$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x4$earlyStop[1, ]))
+ expect_equal(x4$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x4$earlyStop[2, ]))
+ expect_equal(x4$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[1, ]))
+ expect_equal(x4$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[2, ]))
+ expect_equal(x4$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x4$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x4$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0(unlist(as.list(x4$selectedArms))))
+ expect_equal(x4$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[1, ]))
+ expect_equal(x4$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[2, ]))
+ expect_equal(x4$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0(x4$numberOfActiveArms[3, ]))
+ expect_equal(x4$expectedNumberOfEvents, c(209.51335, 210, 205.68884, 195.53918), tolerance = 1e-07, label = paste0(x4$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x4$singleNumberOfEventsPerStage)), c(2, 19.90267, 20, 1.9090909, 19.090909, 19.090909, 1.8333333, 17.542954, 18.333333, 1.7692308, 15.133855, 17.692308, 2, 19.90267, 20, 2, 20, 20, 2, 19.137768, 20, 2, 17.107836, 20, 2, 19.90267, 20, 2.0909091, 20.909091, 20.909091, 2.1666667, 20.732582, 21.666667, 2.2307692, 19.081818, 22.307692, 2, 19.90267, 20, 2.1818182, 21.818182, 21.818182, 2.3333333, 22.327396, 23.333333, 2.4615385, 21.055799, 24.615385, 2, 19.90267, 20, 1.8181818, 18.181818, 18.181818, 1.6666667, 15.94814, 16.666667, 1.5384615, 13.159874, 15.384615), tolerance = 1e-07, label = paste0(unlist(as.list(x4$singleNumberOfEventsPerStage))))
+ expect_equal(x4$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x4$conditionalPowerAchieved[1, ]))
+ expect_equal(x4$conditionalPowerAchieved[2, ], c(0.09225544, 0.10755451, 0.080008195, 0.16137979), tolerance = 1e-07, label = paste0(x4$conditionalPowerAchieved[2, ]))
+ expect_equal(x4$conditionalPowerAchieved[3, ], c(0.011907723, 0.030096405, 0.063317228, 0.080810126), tolerance = 1e-07, label = paste0(x4$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x4), NA)))
+ expect_output(print(x4)$show())
+ invisible(capture.output(expect_error(summary(x4), NA)))
+ expect_output(summary(x4)$show())
+ x4CodeBased <- eval(parse(text = getObjectRCode(x4, stringWrapParagraphWidth = NULL)))
+ expect_equal(x4CodeBased$eventsPerStage, x4$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$iterations, x4$iterations, tolerance = 1e-07)
+ expect_equal(x4CodeBased$rejectAtLeastOne, x4$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x4CodeBased$rejectedArmsPerStage, x4$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$futilityStop, x4$futilityStop, tolerance = 1e-07)
+ expect_equal(x4CodeBased$futilityPerStage, x4$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$earlyStop, x4$earlyStop, tolerance = 1e-07)
+ expect_equal(x4CodeBased$successPerStage, x4$successPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$selectedArms, x4$selectedArms, tolerance = 1e-07)
+ expect_equal(x4CodeBased$numberOfActiveArms, x4$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x4CodeBased$expectedNumberOfEvents, x4$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x4CodeBased$singleNumberOfEventsPerStage, x4$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalPowerAchieved, x4$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x4), "character")
+ df <- as.data.frame(x4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x5 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "rBest", rValue = 2,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x5' with expected results
+ expect_equal(unlist(as.list(x5$eventsPerStage)), c(4, 52.52163, 101.87923, 3.7272727, 38.874416, 80.596598, 3.5, 26.84484, 58.886153, 3.3076923, 30.949369, 59.030095, 4, 46.265898, 91.178205, 3.8181818, 38.846483, 77.651274, 3.6666667, 31.816991, 74.831476, 3.5384615, 34.40256, 64.30431, 4, 45.854963, 88.5459, 3.9090909, 42.746334, 86.637949, 3.8333333, 33.812131, 81.900895, 3.7692308, 37.761125, 70.330365, 4, 39.599231, 77.844872, 4, 51.153533, 106.61534, 4, 33.295158, 78.303665, 4, 52.301815, 100.0206), tolerance = 1e-07, label = paste0(unlist(as.list(x5$eventsPerStage))))
+ expect_equal(x5$iterations[1, ], c(10, 10, 10, 10), label = paste0(x5$iterations[1, ]))
+ expect_equal(x5$iterations[2, ], c(10, 10, 10, 10), label = paste0(x5$iterations[2, ]))
+ expect_equal(x5$iterations[3, ], c(10, 10, 10, 10), label = paste0(x5$iterations[3, ]))
+ expect_equal(x5$rejectAtLeastOne, c(0.1, 0, 0.2, 0.6), tolerance = 1e-07, label = paste0(x5$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x5$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x5$rejectedArmsPerStage))))
+ expect_equal(x5$futilityStop, c(0, 0, 0, 0), label = paste0(x5$futilityStop))
+ expect_equal(x5$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x5$futilityPerStage[1, ]))
+ expect_equal(x5$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x5$futilityPerStage[2, ]))
+ expect_equal(x5$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x5$earlyStop[1, ]))
+ expect_equal(x5$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x5$earlyStop[2, ]))
+ expect_equal(x5$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x5$successPerStage[1, ]))
+ expect_equal(x5$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x5$successPerStage[2, ]))
+ expect_equal(x5$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x5$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x5$selectedArms)), c(1, 0.7, 0.7, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.7, 0.7, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.8, 0.8, 1, 0.5, 0.5, 1, 0.8, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x5$selectedArms))))
+ expect_equal(x5$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x5$numberOfActiveArms[1, ]))
+ expect_equal(x5$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x5$numberOfActiveArms[2, ]))
+ expect_equal(x5$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x5$numberOfActiveArms[3, ]))
+ expect_equal(x5$expectedNumberOfEvents, c(181.7241, 185.49972, 161.03264, 167.26743), tolerance = 1e-07, label = paste0(x5$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x5$singleNumberOfEventsPerStage)), c(2, 20.481343, 20.156522, 1.9090909, 10.277572, 13.076122, 1.8333333, 6.3781513, 6.3781513, 1.7692308, 7.1692484, 7.9523038, 2, 14.225611, 15.711226, 2, 10.15873, 10.15873, 2, 11.183635, 17.351324, 2, 10.39167, 9.7733283, 2, 13.814676, 13.489856, 2.0909091, 13.967672, 15.245555, 2.1666667, 13.012108, 22.425602, 2.2307692, 13.519466, 12.440818, 2, 7.5589445, 9.044559, 2.1818182, 22.283962, 26.815748, 2.3333333, 12.328469, 19.345345, 2.4615385, 27.829386, 27.590364, 2, 28.040287, 29.201081, 1.8181818, 24.869571, 28.64606, 1.6666667, 16.966689, 25.663162, 1.5384615, 20.472429, 20.128422), tolerance = 1e-07, label = paste0(unlist(as.list(x5$singleNumberOfEventsPerStage))))
+ expect_equal(x5$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x5$conditionalPowerAchieved[1, ]))
+ expect_equal(x5$conditionalPowerAchieved[2, ], c(0.0011884888, 0.025687618, 0.050936222, 0.056920177), tolerance = 1e-07, label = paste0(x5$conditionalPowerAchieved[2, ]))
+ expect_equal(x5$conditionalPowerAchieved[3, ], c(0.16000064, 0.17717891, 0.25226702, 0.41435883), tolerance = 1e-07, label = paste0(x5$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x5), NA)))
+ expect_output(print(x5)$show())
+ invisible(capture.output(expect_error(summary(x5), NA)))
+ expect_output(summary(x5)$show())
+ x5CodeBased <- eval(parse(text = getObjectRCode(x5, stringWrapParagraphWidth = NULL)))
+ expect_equal(x5CodeBased$eventsPerStage, x5$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$iterations, x5$iterations, tolerance = 1e-07)
+ expect_equal(x5CodeBased$rejectAtLeastOne, x5$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x5CodeBased$rejectedArmsPerStage, x5$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$futilityStop, x5$futilityStop, tolerance = 1e-07)
+ expect_equal(x5CodeBased$futilityPerStage, x5$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$earlyStop, x5$earlyStop, tolerance = 1e-07)
+ expect_equal(x5CodeBased$successPerStage, x5$successPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$selectedArms, x5$selectedArms, tolerance = 1e-07)
+ expect_equal(x5CodeBased$numberOfActiveArms, x5$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x5CodeBased$expectedNumberOfEvents, x5$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x5CodeBased$singleNumberOfEventsPerStage, x5$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x5CodeBased$conditionalPowerAchieved, x5$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x5), "character")
+ df <- as.data.frame(x5)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x5)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x6 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x6' with expected results
+ expect_equal(unlist(as.list(x6$eventsPerStage)), c(4, 61.733546, 127.87237, 3.7272727, 31.938683, 70.204069, 3.5, 41.1271, 91.550286, 3.3076923, 34.649784, 81.031044, 4, 56.48818, 112.05759, 3.8181818, 40.038722, 105.34522, 3.6666667, 42.689301, 87.532881, 3.5384615, 28.026291, 80.666398, 4, 48.154846, 98.724256, 3.9090909, 30.896746, 79.036909, 3.8333333, 37.59905, 82.662218, 3.7692308, 38.754446, 86.274767, 4, 48.730993, 104.3004, 4, 35.685987, 84.168898, 4, 44.550112, 108.98044, 4, 36.742663, 80.705475), tolerance = 1e-07, label = paste0(unlist(as.list(x6$eventsPerStage))))
+ expect_equal(x6$iterations[1, ], c(10, 10, 10, 10), label = paste0(x6$iterations[1, ]))
+ expect_equal(x6$iterations[2, ], c(10, 10, 10, 10), label = paste0(x6$iterations[2, ]))
+ expect_equal(x6$iterations[3, ], c(10, 9, 9, 10), label = paste0(x6$iterations[3, ]))
+ expect_equal(x6$rejectAtLeastOne, c(0, 0.3, 0.5, 0.4), tolerance = 1e-07, label = paste0(x6$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x6$rejectedArmsPerStage)), c(0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.3, 0, 0, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x6$rejectedArmsPerStage))))
+ expect_equal(x6$futilityStop, c(0, 0, 0, 0), label = paste0(x6$futilityStop))
+ expect_equal(x6$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x6$futilityPerStage[1, ]))
+ expect_equal(x6$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x6$futilityPerStage[2, ]))
+ expect_equal(x6$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x6$earlyStop[1, ]))
+ expect_equal(x6$earlyStop[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x6$earlyStop[2, ]))
+ expect_equal(x6$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x6$successPerStage[1, ]))
+ expect_equal(x6$successPerStage[2, ], c(0, 0.1, 0.1, 0), tolerance = 1e-07, label = paste0(x6$successPerStage[2, ]))
+ expect_equal(x6$successPerStage[3, ], c(0, 0.2, 0.4, 0.4), tolerance = 1e-07, label = paste0(x6$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x6$selectedArms)), c(1, 0.5, 0.5, 1, 0.3, 0, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.3, 0.2, 1, 0.5, 0.5, 1, 0.2, 0.1, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.3, 0.2, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3), tolerance = 1e-07, label = paste0(unlist(as.list(x6$selectedArms))))
+ expect_equal(x6$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x6$numberOfActiveArms[1, ]))
+ expect_equal(x6$numberOfActiveArms[2, ], c(1.1, 1.3, 1.1, 1.2), tolerance = 1e-07, label = paste0(x6$numberOfActiveArms[2, ]))
+ expect_equal(x6$numberOfActiveArms[3, ], c(1, 1.1111111, 1, 1), tolerance = 1e-07, label = paste0(x6$numberOfActiveArms[3, ]))
+ expect_equal(x6$expectedNumberOfEvents, c(182.78185, 142.9628, 156.19514, 150.78355), tolerance = 1e-07, label = paste0(x6$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x6$singleNumberOfEventsPerStage)), c(2, 18.5787, 20.56941, 1.9090909, 5.8775077, 0, 1.8333333, 9.5135564, 11.640212, 1.7692308, 9.2660953, 10.697674, 2, 13.333333, 10, 2, 13.886638, 27.041107, 2, 10.909091, 6.0606061, 2, 2.4118335, 16.956522, 2, 5, 5, 2.0909091, 4.6537525, 9.8747764, 2.1666667, 5.6521739, 6.2801932, 2.2307692, 12.909219, 11.836735, 2, 5.5761462, 10, 2.1818182, 9.3520845, 10.217524, 2.3333333, 12.436568, 25.647358, 2.4615385, 10.666667, 8.2792264, 2, 39.154846, 45.56941, 1.8181818, 22.333902, 38.265387, 1.6666667, 28.113543, 38.782975, 1.5384615, 22.075996, 35.683586), tolerance = 1e-07, label = paste0(unlist(as.list(x6$singleNumberOfEventsPerStage))))
+ expect_equal(x6$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x6$conditionalPowerAchieved[1, ]))
+ expect_equal(x6$conditionalPowerAchieved[2, ], c(0.018816179, 0.071905821, 0.002298516, 0.067085771), tolerance = 1e-07, label = paste0(x6$conditionalPowerAchieved[2, ]))
+ expect_equal(x6$conditionalPowerAchieved[3, ], c(0.080015186, 0.29125387, 0.18887123, 0.4033636), tolerance = 1e-07, label = paste0(x6$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x6), NA)))
+ expect_output(print(x6)$show())
+ invisible(capture.output(expect_error(summary(x6), NA)))
+ expect_output(summary(x6)$show())
+ x6CodeBased <- eval(parse(text = getObjectRCode(x6, stringWrapParagraphWidth = NULL)))
+ expect_equal(x6CodeBased$eventsPerStage, x6$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$iterations, x6$iterations, tolerance = 1e-07)
+ expect_equal(x6CodeBased$rejectAtLeastOne, x6$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x6CodeBased$rejectedArmsPerStage, x6$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$futilityStop, x6$futilityStop, tolerance = 1e-07)
+ expect_equal(x6CodeBased$futilityPerStage, x6$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$earlyStop, x6$earlyStop, tolerance = 1e-07)
+ expect_equal(x6CodeBased$successPerStage, x6$successPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$selectedArms, x6$selectedArms, tolerance = 1e-07)
+ expect_equal(x6CodeBased$numberOfActiveArms, x6$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x6CodeBased$expectedNumberOfEvents, x6$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x6CodeBased$singleNumberOfEventsPerStage, x6$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x6CodeBased$conditionalPowerAchieved, x6$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x6), "character")
+ df <- as.data.frame(x6)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x6)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x7 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x7' with expected results
+ expect_equal(unlist(as.list(x7$eventsPerStage)), c(4, 56.544006, 109.08801, 3.7272727, 45.869846, 88.01242, 3.5, 30.37664, 55.609943, 3.3076923, 32.448585, 64.38291, 4, 49.635155, 95.27031, 3.8181818, 36.042521, 68.26686, 3.6666667, 30.759757, 56.23356, 3.5384615, 32.768737, 65.040103, 4, 65.124183, 126.24837, 3.9090909, 38.113637, 72.318183, 3.8333333, 29.450577, 53.284552, 3.7692308, 37.063433, 73.850273, 4, 43.825836, 83.651672, 4, 31.654176, 59.308352, 4, 38.617451, 65.970174, 4, 39.885794, 79.552181), tolerance = 1e-07, label = paste0(unlist(as.list(x7$eventsPerStage))))
+ expect_equal(x7$iterations[1, ], c(10, 10, 10, 10), label = paste0(x7$iterations[1, ]))
+ expect_equal(x7$iterations[2, ], c(10, 10, 10, 10), label = paste0(x7$iterations[2, ]))
+ expect_equal(x7$iterations[3, ], c(10, 10, 9, 9), label = paste0(x7$iterations[3, ]))
+ expect_equal(x7$rejectAtLeastOne, c(0, 0.1, 0.4, 0.4), tolerance = 1e-07, label = paste0(x7$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x7$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x7$rejectedArmsPerStage))))
+ expect_equal(x7$futilityStop, c(0, 0, 0, 0), label = paste0(x7$futilityStop))
+ expect_equal(x7$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x7$futilityPerStage[1, ]))
+ expect_equal(x7$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x7$futilityPerStage[2, ]))
+ expect_equal(x7$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x7$earlyStop[1, ]))
+ expect_equal(x7$earlyStop[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x7$earlyStop[2, ]))
+ expect_equal(x7$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x7$successPerStage[1, ]))
+ expect_equal(x7$successPerStage[2, ], c(0, 0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x7$successPerStage[2, ]))
+ expect_equal(x7$successPerStage[3, ], c(0, 0.1, 0.3, 0.3), tolerance = 1e-07, label = paste0(x7$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x7$selectedArms)), c(1, 0.3, 0.3, 1, 0.3, 0.3, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.5, 0.5, 1, 0.4, 0.4, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0, 0, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.2, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x7$selectedArms))))
+ expect_equal(x7$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x7$numberOfActiveArms[1, ]))
+ expect_equal(x7$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x7$numberOfActiveArms[2, ]))
+ expect_equal(x7$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x7$numberOfActiveArms[3, ]))
+ expect_equal(x7$expectedNumberOfEvents, c(169.30334, 121.79095, 98.577582, 123.23372), tolerance = 1e-07, label = paste0(x7$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x7$singleNumberOfEventsPerStage)), c(2, 12.71817, 12.71817, 1.9090909, 15.365854, 15.365854, 1.8333333, 5.2380952, 5.8201058, 1.7692308, 5.5627907, 5.9431525, 2, 5.8093191, 5.8093191, 2, 5.447619, 5.447619, 2, 5.4545455, 6.0606061, 2, 5.6521739, 6.2801932, 2, 21.298347, 21.298347, 2.0909091, 7.4278263, 7.4278263, 2.1666667, 3.9786992, 4.4207768, 2.2307692, 9.7161004, 10.795667, 2, 0, 0, 2.1818182, 0.87745601, 0.87745601, 2.3333333, 12.978906, 7.9395257, 2.4615385, 12.307692, 13.675214, 2, 39.825836, 39.825836, 1.8181818, 26.77672, 26.77672, 1.6666667, 21.638545, 19.413198, 1.5384615, 23.578102, 25.991173), tolerance = 1e-07, label = paste0(unlist(as.list(x7$singleNumberOfEventsPerStage))))
+ expect_equal(x7$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x7$conditionalPowerAchieved[1, ]))
+ expect_equal(x7$conditionalPowerAchieved[2, ], c(5.8245202e-05, 0.033918251, 0.017570415, 0.062651459), tolerance = 1e-07, label = paste0(x7$conditionalPowerAchieved[2, ]))
+ expect_equal(x7$conditionalPowerAchieved[3, ], c(0.075858531, 0.086024261, 0.37522404, 0.19729909), tolerance = 1e-07, label = paste0(x7$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x7), NA)))
+ expect_output(print(x7)$show())
+ invisible(capture.output(expect_error(summary(x7), NA)))
+ expect_output(summary(x7)$show())
+ x7CodeBased <- eval(parse(text = getObjectRCode(x7, stringWrapParagraphWidth = NULL)))
+ expect_equal(x7CodeBased$eventsPerStage, x7$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$iterations, x7$iterations, tolerance = 1e-07)
+ expect_equal(x7CodeBased$rejectAtLeastOne, x7$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x7CodeBased$rejectedArmsPerStage, x7$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$futilityStop, x7$futilityStop, tolerance = 1e-07)
+ expect_equal(x7CodeBased$futilityPerStage, x7$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$earlyStop, x7$earlyStop, tolerance = 1e-07)
+ expect_equal(x7CodeBased$successPerStage, x7$successPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$selectedArms, x7$selectedArms, tolerance = 1e-07)
+ expect_equal(x7CodeBased$numberOfActiveArms, x7$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x7CodeBased$expectedNumberOfEvents, x7$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x7CodeBased$singleNumberOfEventsPerStage, x7$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x7CodeBased$conditionalPowerAchieved, x7$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x7), "character")
+ df <- as.data.frame(x7)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x7)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x8 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "all",
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x8' with expected results
+ expect_equal(unlist(as.list(x8$eventsPerStage)), c(4, 43.80534, 83.61068, 3.7272727, 41, 78.272727, 3.5, 36.991095, 70.482189, 3.3076923, 31.601422, 59.895151, 4, 43.80534, 83.61068, 3.8181818, 42, 80.181818, 3.6666667, 38.752575, 73.838484, 3.5384615, 33.806172, 64.073883, 4, 43.80534, 83.61068, 3.9090909, 43, 82.090909, 3.8333333, 40.514056, 77.194778, 3.7692308, 36.010922, 68.252614, 4, 43.80534, 83.61068, 4, 44, 84, 4, 42.275537, 80.551073, 4, 38.215673, 72.431346), tolerance = 1e-07, label = paste0(unlist(as.list(x8$eventsPerStage))))
+ expect_equal(x8$iterations[1, ], c(10, 10, 10, 10), label = paste0(x8$iterations[1, ]))
+ expect_equal(x8$iterations[2, ], c(10, 10, 10, 10), label = paste0(x8$iterations[2, ]))
+ expect_equal(x8$iterations[3, ], c(10, 10, 10, 10), label = paste0(x8$iterations[3, ]))
+ expect_equal(x8$rejectAtLeastOne, c(0, 0.1, 0.2, 0.2), tolerance = 1e-07, label = paste0(x8$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x8$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x8$rejectedArmsPerStage))))
+ expect_equal(x8$futilityStop, c(0, 0, 0, 0), label = paste0(x8$futilityStop))
+ expect_equal(x8$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x8$futilityPerStage[1, ]))
+ expect_equal(x8$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x8$futilityPerStage[2, ]))
+ expect_equal(x8$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x8$earlyStop[1, ]))
+ expect_equal(x8$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x8$earlyStop[2, ]))
+ expect_equal(x8$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[1, ]))
+ expect_equal(x8$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[2, ]))
+ expect_equal(x8$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x8$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x8$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = paste0(unlist(as.list(x8$selectedArms))))
+ expect_equal(x8$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[1, ]))
+ expect_equal(x8$numberOfActiveArms[2, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[2, ]))
+ expect_equal(x8$numberOfActiveArms[3, ], c(4, 4, 4, 4), label = paste0(x8$numberOfActiveArms[3, ]))
+ expect_equal(x8$expectedNumberOfEvents, c(209.0267, 210, 201.37768, 181.07836), tolerance = 1e-07, label = paste0(x8$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x8$singleNumberOfEventsPerStage)), c(2, 19.90267, 19.90267, 1.9090909, 19.090909, 19.090909, 1.8333333, 17.542954, 17.542954, 1.7692308, 15.133855, 15.133855, 2, 19.90267, 19.90267, 2, 20, 20, 2, 19.137768, 19.137768, 2, 17.107836, 17.107836, 2, 19.90267, 19.90267, 2.0909091, 20.909091, 20.909091, 2.1666667, 20.732582, 20.732582, 2.2307692, 19.081818, 19.081818, 2, 19.90267, 19.90267, 2.1818182, 21.818182, 21.818182, 2.3333333, 22.327396, 22.327396, 2.4615385, 21.055799, 21.055799, 2, 19.90267, 19.90267, 1.8181818, 18.181818, 18.181818, 1.6666667, 15.94814, 15.94814, 1.5384615, 13.159874, 13.159874), tolerance = 1e-07, label = paste0(unlist(as.list(x8$singleNumberOfEventsPerStage))))
+ expect_equal(x8$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x8$conditionalPowerAchieved[1, ]))
+ expect_equal(x8$conditionalPowerAchieved[2, ], c(0.09225544, 0.10755451, 0.080008195, 0.16137979), tolerance = 1e-07, label = paste0(x8$conditionalPowerAchieved[2, ]))
+ expect_equal(x8$conditionalPowerAchieved[3, ], c(0.011968708, 0.030096405, 0.063317862, 0.066369104), tolerance = 1e-07, label = paste0(x8$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x8), NA)))
+ expect_output(print(x8)$show())
+ invisible(capture.output(expect_error(summary(x8), NA)))
+ expect_output(summary(x8)$show())
+ x8CodeBased <- eval(parse(text = getObjectRCode(x8, stringWrapParagraphWidth = NULL)))
+ expect_equal(x8CodeBased$eventsPerStage, x8$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$iterations, x8$iterations, tolerance = 1e-07)
+ expect_equal(x8CodeBased$rejectAtLeastOne, x8$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x8CodeBased$rejectedArmsPerStage, x8$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$futilityStop, x8$futilityStop, tolerance = 1e-07)
+ expect_equal(x8CodeBased$futilityPerStage, x8$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$earlyStop, x8$earlyStop, tolerance = 1e-07)
+ expect_equal(x8CodeBased$successPerStage, x8$successPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$selectedArms, x8$selectedArms, tolerance = 1e-07)
+ expect_equal(x8CodeBased$numberOfActiveArms, x8$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x8CodeBased$expectedNumberOfEvents, x8$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x8CodeBased$singleNumberOfEventsPerStage, x8$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x8CodeBased$conditionalPowerAchieved, x8$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x8), "character")
+ df <- as.data.frame(x8)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x9 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "rBest", rValue = 2,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x9' with expected results
+ expect_equal(unlist(as.list(x9$eventsPerStage)), c(4, 52.52163, 101.04326, 3.7272727, 38.874416, 74.021559, 3.5, 26.84484, 50.189681, 3.3076923, 30.949369, 58.591046, 4, 46.265898, 88.531796, 3.8181818, 38.846483, 73.874785, 3.6666667, 31.816991, 59.967314, 3.5384615, 34.40256, 65.266658, 4, 45.854963, 87.709926, 3.9090909, 42.746334, 81.583577, 3.8333333, 33.812131, 63.790928, 3.7692308, 37.761125, 71.75302, 4, 39.599231, 75.198463, 4, 51.153533, 98.307067, 4, 33.295158, 62.590316, 4, 52.301815, 100.60363), tolerance = 1e-07, label = paste0(unlist(as.list(x9$eventsPerStage))))
+ expect_equal(x9$iterations[1, ], c(10, 10, 10, 10), label = paste0(x9$iterations[1, ]))
+ expect_equal(x9$iterations[2, ], c(10, 10, 10, 10), label = paste0(x9$iterations[2, ]))
+ expect_equal(x9$iterations[3, ], c(10, 10, 10, 10), label = paste0(x9$iterations[3, ]))
+ expect_equal(x9$rejectAtLeastOne, c(0.1, 0, 0.2, 0.6), tolerance = 1e-07, label = paste0(x9$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x9$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.1, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0, 0, 0.4), tolerance = 1e-07, label = paste0(unlist(as.list(x9$rejectedArmsPerStage))))
+ expect_equal(x9$futilityStop, c(0, 0, 0, 0), label = paste0(x9$futilityStop))
+ expect_equal(x9$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x9$futilityPerStage[1, ]))
+ expect_equal(x9$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x9$futilityPerStage[2, ]))
+ expect_equal(x9$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x9$earlyStop[1, ]))
+ expect_equal(x9$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x9$earlyStop[2, ]))
+ expect_equal(x9$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x9$successPerStage[1, ]))
+ expect_equal(x9$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x9$successPerStage[2, ]))
+ expect_equal(x9$successPerStage[3, ], c(0, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x9$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x9$selectedArms)), c(1, 0.7, 0.7, 1, 0.4, 0.4, 1, 0.2, 0.2, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.6, 0.6, 1, 0.4, 0.4, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.7, 0.7, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.8, 0.8, 1, 0.5, 0.5, 1, 0.8, 0.8), tolerance = 1e-07, label = paste0(unlist(as.list(x9$selectedArms))))
+ expect_equal(x9$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x9$numberOfActiveArms[1, ]))
+ expect_equal(x9$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x9$numberOfActiveArms[2, ]))
+ expect_equal(x9$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x9$numberOfActiveArms[3, ]))
+ expect_equal(x9$expectedNumberOfEvents, c(178.24172, 173.11501, 129.7381, 168.7644), tolerance = 1e-07, label = paste0(x9$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x9$singleNumberOfEventsPerStage)), c(2, 20.481343, 20.481343, 1.9090909, 10.277572, 10.277572, 1.8333333, 6.3781513, 6.3781513, 1.7692308, 7.1692484, 7.1692484, 2, 14.225611, 14.225611, 2, 10.15873, 10.15873, 2, 11.183635, 11.183635, 2, 10.39167, 10.39167, 2, 13.814676, 13.814676, 2.0909091, 13.967672, 13.967672, 2.1666667, 13.012108, 13.012108, 2.2307692, 13.519466, 13.519466, 2, 7.5589445, 7.5589445, 2.1818182, 22.283962, 22.283962, 2.3333333, 12.328469, 12.328469, 2.4615385, 27.829386, 27.829386, 2, 28.040287, 28.040287, 1.8181818, 24.869571, 24.869571, 1.6666667, 16.966689, 16.966689, 1.5384615, 20.472429, 20.472429), tolerance = 1e-07, label = paste0(unlist(as.list(x9$singleNumberOfEventsPerStage))))
+ expect_equal(x9$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x9$conditionalPowerAchieved[1, ]))
+ expect_equal(x9$conditionalPowerAchieved[2, ], c(0.0011884888, 0.025687618, 0.050936222, 0.056920177), tolerance = 1e-07, label = paste0(x9$conditionalPowerAchieved[2, ]))
+ expect_equal(x9$conditionalPowerAchieved[3, ], c(0.13630501, 0.14441052, 0.13257023, 0.41932885), tolerance = 1e-07, label = paste0(x9$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x9), NA)))
+ expect_output(print(x9)$show())
+ invisible(capture.output(expect_error(summary(x9), NA)))
+ expect_output(summary(x9)$show())
+ x9CodeBased <- eval(parse(text = getObjectRCode(x9, stringWrapParagraphWidth = NULL)))
+ expect_equal(x9CodeBased$eventsPerStage, x9$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$iterations, x9$iterations, tolerance = 1e-07)
+ expect_equal(x9CodeBased$rejectAtLeastOne, x9$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x9CodeBased$rejectedArmsPerStage, x9$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$futilityStop, x9$futilityStop, tolerance = 1e-07)
+ expect_equal(x9CodeBased$futilityPerStage, x9$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$earlyStop, x9$earlyStop, tolerance = 1e-07)
+ expect_equal(x9CodeBased$successPerStage, x9$successPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$selectedArms, x9$selectedArms, tolerance = 1e-07)
+ expect_equal(x9CodeBased$numberOfActiveArms, x9$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x9CodeBased$expectedNumberOfEvents, x9$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x9CodeBased$singleNumberOfEventsPerStage, x9$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x9CodeBased$conditionalPowerAchieved, x9$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x9), "character")
+ df <- as.data.frame(x9)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x9)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x10 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Hierarchical",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x10' with expected results
+ expect_equal(unlist(as.list(x10$eventsPerStage)), c(4, 56.657929, 125.67531, 3.7272727, 49.785816, 137.47812, 3.5, 31.249399, 83.970115, 3.3076923, 24.380086, 39.12662, 4, 50.333545, 107.06446, 3.8181818, 41.640149, 84.416884, 3.6666667, 39.507667, 64.61277, 3.5384615, 24.167144, 31.025997, 4, 45.952714, 80.461405, 3.9090909, 47.662083, 90.438818, 3.8333333, 33.911202, 59.016305, 3.7692308, 36.126326, 42.985179, 4, 39.486047, 79.550294, 4, 50.19027, 105.2747, 4, 37.6469, 62.752003, 4, 41.892876, 48.751729), tolerance = 1e-07, label = paste0(unlist(as.list(x10$eventsPerStage))))
+ expect_equal(x10$iterations[1, ], c(10, 10, 10, 10), label = paste0(x10$iterations[1, ]))
+ expect_equal(x10$iterations[2, ], c(10, 10, 10, 10), label = paste0(x10$iterations[2, ]))
+ expect_equal(x10$iterations[3, ], c(6, 3, 2, 1), label = paste0(x10$iterations[3, ]))
+ expect_equal(x10$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x10$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x10$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x10$rejectedArmsPerStage))))
+ expect_equal(x10$futilityStop, c(0.4, 0.7, 0.8, 0.9), tolerance = 1e-07, label = paste0(x10$futilityStop))
+ expect_equal(x10$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x10$futilityPerStage[1, ]))
+ expect_equal(x10$futilityPerStage[2, ], c(0.4, 0.7, 0.8, 0.9), tolerance = 1e-07, label = paste0(x10$futilityPerStage[2, ]))
+ expect_equal(x10$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x10$earlyStop[1, ]))
+ expect_equal(x10$earlyStop[2, ], c(0.4, 0.7, 0.8, 0.9), tolerance = 1e-07, label = paste0(x10$earlyStop[2, ]))
+ expect_equal(x10$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x10$successPerStage[1, ]))
+ expect_equal(x10$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x10$successPerStage[2, ]))
+ expect_equal(x10$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x10$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x10$selectedArms)), c(1, 0.6, 0.6, 1, 0.3, 0.3, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.5, 0.4, 1, 0.1, 0, 1, 0.4, 0, 1, 0.1, 0, 1, 0.2, 0, 1, 0.4, 0, 1, 0.3, 0, 1, 0.3, 0, 1, 0.2, 0.1, 1, 0.4, 0.1, 1, 0.4, 0, 1, 0.5, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x10$selectedArms))))
+ expect_equal(x10$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x10$numberOfActiveArms[1, ]))
+ expect_equal(x10$numberOfActiveArms[2, ], c(1.5, 1.2, 1.3, 1), tolerance = 1e-07, label = paste0(x10$numberOfActiveArms[2, ]))
+ expect_equal(x10$numberOfActiveArms[3, ], c(1.8333333, 1.3333333, 1, 1), tolerance = 1e-07, label = paste0(x10$numberOfActiveArms[3, ]))
+ expect_equal(x10$expectedNumberOfEvents, c(148.64919, 116.07216, 81.180483, 62.574824), tolerance = 1e-07, label = paste0(x10$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x10$singleNumberOfEventsPerStage)), c(2, 20.705215, 34.508692, 1.9090909, 13.474672, 44.915572, 1.8333333, 5.5231227, 27.615613, 1.7692308, 0.78876811, 7.8876811, 2, 14.380832, 22.222222, 2, 5.2380952, 0, 2, 13.614724, 0, 2, 0.34505655, 0, 2, 10, 0, 2.0909091, 11.16912, 0, 2.1666667, 7.8515929, 0, 2.2307692, 12.073469, 0, 2, 3.5333333, 5.5555556, 2.1818182, 13.606399, 12.307692, 2.3333333, 11.420624, 0, 2.4615385, 17.609251, 0, 2, 31.952714, 34.508692, 1.8181818, 32.583872, 42.776735, 1.6666667, 22.226276, 25.105103, 1.5384615, 20.283626, 6.8588531), tolerance = 1e-07, label = paste0(unlist(as.list(x10$singleNumberOfEventsPerStage))))
+ expect_equal(x10$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x10$conditionalPowerAchieved[1, ]))
+ expect_equal(x10$conditionalPowerAchieved[2, ], c(0.0031444794, 0.00037604601, 0.038145414, 0.045847923), tolerance = 1e-07, label = paste0(x10$conditionalPowerAchieved[2, ]))
+ expect_equal(x10$conditionalPowerAchieved[3, ], c(7.9302274e-08, 1.361166e-06, 0.16667791, 0.040805908), tolerance = 1e-07, label = paste0(x10$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x10), NA)))
+ expect_output(print(x10)$show())
+ invisible(capture.output(expect_error(summary(x10), NA)))
+ expect_output(summary(x10)$show())
+ x10CodeBased <- eval(parse(text = getObjectRCode(x10, stringWrapParagraphWidth = NULL)))
+ expect_equal(x10CodeBased$eventsPerStage, x10$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$iterations, x10$iterations, tolerance = 1e-07)
+ expect_equal(x10CodeBased$rejectAtLeastOne, x10$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x10CodeBased$rejectedArmsPerStage, x10$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$futilityStop, x10$futilityStop, tolerance = 1e-07)
+ expect_equal(x10CodeBased$futilityPerStage, x10$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$earlyStop, x10$earlyStop, tolerance = 1e-07)
+ expect_equal(x10CodeBased$successPerStage, x10$successPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$selectedArms, x10$selectedArms, tolerance = 1e-07)
+ expect_equal(x10CodeBased$numberOfActiveArms, x10$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x10CodeBased$expectedNumberOfEvents, x10$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x10CodeBased$singleNumberOfEventsPerStage, x10$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x10CodeBased$conditionalPowerAchieved, x10$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x10), "character")
+ df <- as.data.frame(x10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x11 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(0.1, 0.3, 0.1),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Hierarchical",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x11' with expected results
+ expect_equal(unlist(as.list(x11$eventsPerStage)), c(1.5454545, 1.5454545, 1.5454545, 2, 2, 2, 2.3846154, 2.3846154, 2.3846154, 2.3636364, 2.3636364, 2.3636364, 2.6666667, 2.6666667, 2.6666667, 2.9230769, 2.9230769, 2.9230769, 3.1818182, 3.1818182, 3.1818182, 3.3333333, 3.3333333, 3.3333333, 3.4615385, 3.4615385, 3.4615385, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x11$eventsPerStage))))
+ expect_equal(x11$iterations[1, ], c(10, 10, 10), label = paste0(x11$iterations[1, ]))
+ expect_equal(x11$iterations[2, ], c(0, 0, 0), label = paste0(x11$iterations[2, ]))
+ expect_equal(x11$iterations[3, ], c(0, 0, 0), label = paste0(x11$iterations[3, ]))
+ expect_equal(x11$rejectAtLeastOne, c(0, 0, 0), label = paste0(x11$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x11$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x11$rejectedArmsPerStage))))
+ expect_equal(x11$futilityStop, c(1, 1, 1), label = paste0(x11$futilityStop))
+ expect_equal(x11$futilityPerStage[1, ], c(1, 1, 1), label = paste0(x11$futilityPerStage[1, ]))
+ expect_equal(x11$futilityPerStage[2, ], c(0, 0, 0), label = paste0(x11$futilityPerStage[2, ]))
+ expect_equal(x11$earlyStop[1, ], c(1, 1, 1), label = paste0(x11$earlyStop[1, ]))
+ expect_equal(x11$earlyStop[2, ], c(0, 0, 0), label = paste0(x11$earlyStop[2, ]))
+ expect_equal(x11$successPerStage[1, ], c(0, 0, 0), label = paste0(x11$successPerStage[1, ]))
+ expect_equal(x11$successPerStage[2, ], c(0, 0, 0), label = paste0(x11$successPerStage[2, ]))
+ expect_equal(x11$successPerStage[3, ], c(0, 0, 0), label = paste0(x11$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x11$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x11$selectedArms))))
+ expect_equal(x11$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0(x11$numberOfActiveArms[1, ]))
+ expect_equal(x11$numberOfActiveArms[2, ], c(NaN, NaN, NaN), label = paste0(x11$numberOfActiveArms[2, ]))
+ expect_equal(x11$numberOfActiveArms[3, ], c(NaN, NaN, NaN), label = paste0(x11$numberOfActiveArms[3, ]))
+ expect_equal(x11$expectedNumberOfEvents, c(NaN, NaN, NaN), label = paste0(x11$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x11$singleNumberOfEventsPerStage)), c(1.1818182, NaN, NaN, 1.3333333, NaN, NaN, 1.4615385, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2.8181818, NaN, NaN, 2.6666667, NaN, NaN, 2.5384615, NaN, NaN, 3.6363636, NaN, NaN, 3.3333333, NaN, NaN, 3.0769231, NaN, NaN, 0.36363636, NaN, NaN, 0.66666667, NaN, NaN, 0.92307692, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x11$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x11), NA)))
+ expect_output(print(x11)$show())
+ invisible(capture.output(expect_error(summary(x11), NA)))
+ expect_output(summary(x11)$show())
+ x11CodeBased <- eval(parse(text = getObjectRCode(x11, stringWrapParagraphWidth = NULL)))
+ expect_equal(x11CodeBased$eventsPerStage, x11$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$iterations, x11$iterations, tolerance = 1e-07)
+ expect_equal(x11CodeBased$rejectAtLeastOne, x11$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x11CodeBased$rejectedArmsPerStage, x11$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$futilityStop, x11$futilityStop, tolerance = 1e-07)
+ expect_equal(x11CodeBased$futilityPerStage, x11$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$earlyStop, x11$earlyStop, tolerance = 1e-07)
+ expect_equal(x11CodeBased$successPerStage, x11$successPerStage, tolerance = 1e-07)
+ expect_equal(x11CodeBased$selectedArms, x11$selectedArms, tolerance = 1e-07)
+ expect_equal(x11CodeBased$numberOfActiveArms, x11$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x11CodeBased$expectedNumberOfEvents, x11$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x11CodeBased$singleNumberOfEventsPerStage, x11$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x11), "character")
+ df <- as.data.frame(x11)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x11)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x12 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4, directionUpper = FALSE, threshold = 0,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Hierarchical",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x12' with expected results
+ expect_equal(unlist(as.list(x12$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x12$eventsPerStage))))
+ expect_equal(x12$iterations[1, ], c(10, 10, 10, 10), label = paste0(x12$iterations[1, ]))
+ expect_equal(x12$iterations[2, ], c(0, 0, 0, 0), label = paste0(x12$iterations[2, ]))
+ expect_equal(x12$iterations[3, ], c(0, 0, 0, 0), label = paste0(x12$iterations[3, ]))
+ expect_equal(x12$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x12$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x12$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x12$rejectedArmsPerStage))))
+ expect_equal(x12$futilityStop, c(1, 1, 1, 1), label = paste0(x12$futilityStop))
+ expect_equal(x12$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x12$futilityPerStage[1, ]))
+ expect_equal(x12$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x12$futilityPerStage[2, ]))
+ expect_equal(x12$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x12$earlyStop[1, ]))
+ expect_equal(x12$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x12$earlyStop[2, ]))
+ expect_equal(x12$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x12$successPerStage[1, ]))
+ expect_equal(x12$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x12$successPerStage[2, ]))
+ expect_equal(x12$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x12$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x12$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x12$selectedArms))))
+ expect_equal(x12$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x12$numberOfActiveArms[1, ]))
+ expect_equal(x12$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x12$numberOfActiveArms[2, ]))
+ expect_equal(x12$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x12$numberOfActiveArms[3, ]))
+ expect_equal(x12$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x12$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x12$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x12$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x12), NA)))
+ expect_output(print(x12)$show())
+ invisible(capture.output(expect_error(summary(x12), NA)))
+ expect_output(summary(x12)$show())
+ x12CodeBased <- eval(parse(text = getObjectRCode(x12, stringWrapParagraphWidth = NULL)))
+ expect_equal(x12CodeBased$eventsPerStage, x12$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$iterations, x12$iterations, tolerance = 1e-07)
+ expect_equal(x12CodeBased$rejectAtLeastOne, x12$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x12CodeBased$rejectedArmsPerStage, x12$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$futilityStop, x12$futilityStop, tolerance = 1e-07)
+ expect_equal(x12CodeBased$futilityPerStage, x12$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$earlyStop, x12$earlyStop, tolerance = 1e-07)
+ expect_equal(x12CodeBased$successPerStage, x12$successPerStage, tolerance = 1e-07)
+ expect_equal(x12CodeBased$selectedArms, x12$selectedArms, tolerance = 1e-07)
+ expect_equal(x12CodeBased$numberOfActiveArms, x12$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x12CodeBased$expectedNumberOfEvents, x12$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x12CodeBased$singleNumberOfEventsPerStage, x12$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x12), "character")
+ df <- as.data.frame(x12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x13 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "userDefined",
+ activeArms = 4, directionUpper = FALSE, threshold = 0,
+ plannedEvents = c(10, 30, 50), adaptations = rep(TRUE, 2),
+ effectMatrix = matrix(c(0.1, 0.2, 0.3, 0.4, 0.2, 0.3, 0.4, 0.5), ncol = 4),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Sidak",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x13' with expected results
+ expect_equal(unlist(as.list(x13$eventsPerStage)), c(5.5, 5.5, 5.5, 5, 5, 5, 6.5, 6.5, 6.5, 5.8333333, 5.8333333, 5.8333333, 6, 6, 6, 5.4166667, 5.4166667, 5.4166667, 7, 7, 7, 6.25, 6.25, 6.25), tolerance = 1e-07, label = paste0(unlist(as.list(x13$eventsPerStage))))
+ expect_equal(x13$iterations[1, ], c(10, 10), label = paste0(x13$iterations[1, ]))
+ expect_equal(x13$iterations[2, ], c(0, 0), label = paste0(x13$iterations[2, ]))
+ expect_equal(x13$iterations[3, ], c(0, 0), label = paste0(x13$iterations[3, ]))
+ expect_equal(x13$rejectAtLeastOne, c(0, 0), label = paste0(x13$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x13$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x13$rejectedArmsPerStage))))
+ expect_equal(x13$futilityStop, c(1, 1), label = paste0(x13$futilityStop))
+ expect_equal(x13$futilityPerStage[1, ], c(1, 1), label = paste0(x13$futilityPerStage[1, ]))
+ expect_equal(x13$futilityPerStage[2, ], c(0, 0), label = paste0(x13$futilityPerStage[2, ]))
+ expect_equal(x13$earlyStop[1, ], c(1, 1), label = paste0(x13$earlyStop[1, ]))
+ expect_equal(x13$earlyStop[2, ], c(0, 0), label = paste0(x13$earlyStop[2, ]))
+ expect_equal(x13$successPerStage[1, ], c(0, 0), label = paste0(x13$successPerStage[1, ]))
+ expect_equal(x13$successPerStage[2, ], c(0, 0), label = paste0(x13$successPerStage[2, ]))
+ expect_equal(x13$successPerStage[3, ], c(0, 0), label = paste0(x13$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x13$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x13$selectedArms))))
+ expect_equal(x13$numberOfActiveArms[1, ], c(4, 4), label = paste0(x13$numberOfActiveArms[1, ]))
+ expect_equal(x13$numberOfActiveArms[2, ], c(NaN, NaN), label = paste0(x13$numberOfActiveArms[2, ]))
+ expect_equal(x13$numberOfActiveArms[3, ], c(NaN, NaN), label = paste0(x13$numberOfActiveArms[3, ]))
+ expect_equal(x13$expectedNumberOfEvents, c(NaN, NaN), label = paste0(x13$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x13$singleNumberOfEventsPerStage)), c(0.5, NaN, NaN, 0.83333333, NaN, NaN, 1.5, NaN, NaN, 1.6666667, NaN, NaN, 1, NaN, NaN, 1.25, NaN, NaN, 2, NaN, NaN, 2.0833333, NaN, NaN, 5, NaN, NaN, 4.1666667, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x13$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x13), NA)))
+ expect_output(print(x13)$show())
+ invisible(capture.output(expect_error(summary(x13), NA)))
+ expect_output(summary(x13)$show())
+ x13CodeBased <- eval(parse(text = getObjectRCode(x13, stringWrapParagraphWidth = NULL)))
+ expect_equal(x13CodeBased$eventsPerStage, x13$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$iterations, x13$iterations, tolerance = 1e-07)
+ expect_equal(x13CodeBased$rejectAtLeastOne, x13$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x13CodeBased$rejectedArmsPerStage, x13$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$futilityStop, x13$futilityStop, tolerance = 1e-07)
+ expect_equal(x13CodeBased$futilityPerStage, x13$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$earlyStop, x13$earlyStop, tolerance = 1e-07)
+ expect_equal(x13CodeBased$successPerStage, x13$successPerStage, tolerance = 1e-07)
+ expect_equal(x13CodeBased$selectedArms, x13$selectedArms, tolerance = 1e-07)
+ expect_equal(x13CodeBased$numberOfActiveArms, x13$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x13CodeBased$expectedNumberOfEvents, x13$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x13CodeBased$singleNumberOfEventsPerStage, x13$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x13), "character")
+ df <- as.data.frame(x13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x14 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "sigmoidEmax", gED50 = 2, slope = 0.5, activeArms = 4, directionUpper = FALSE, threshold = 0,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Sidak",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x14' with expected results
+ expect_equal(unlist(as.list(x14$eventsPerStage)), c(4, 4, 4, 4.1452587, 4.1452587, 4.1452587, 4.2627857, 4.2627857, 4.2627857, 4.3598306, 4.3598306, 4.3598306, 4, 4, 4, 4.1145653, 4.1145653, 4.1145653, 4.2072587, 4.2072587, 4.2072587, 4.2837979, 4.2837979, 4.2837979, 4, 4, 4, 4.0964933, 4.0964933, 4.0964933, 4.1745649, 4.1745649, 4.1745649, 4.2390305, 4.2390305, 4.2390305, 4, 4, 4, 4.0838719, 4.0838719, 4.0838719, 4.1517317, 4.1517317, 4.1517317, 4.2077651, 4.2077651, 4.2077651), tolerance = 1e-07, label = paste0(unlist(as.list(x14$eventsPerStage))))
+ expect_equal(x14$iterations[1, ], c(10, 10, 10, 10), label = paste0(x14$iterations[1, ]))
+ expect_equal(x14$iterations[2, ], c(0, 0, 0, 0), label = paste0(x14$iterations[2, ]))
+ expect_equal(x14$iterations[3, ], c(0, 0, 0, 0), label = paste0(x14$iterations[3, ]))
+ expect_equal(x14$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x14$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x14$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x14$rejectedArmsPerStage))))
+ expect_equal(x14$futilityStop, c(1, 1, 1, 1), label = paste0(x14$futilityStop))
+ expect_equal(x14$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x14$futilityPerStage[1, ]))
+ expect_equal(x14$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x14$futilityPerStage[2, ]))
+ expect_equal(x14$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x14$earlyStop[1, ]))
+ expect_equal(x14$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x14$earlyStop[2, ]))
+ expect_equal(x14$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[1, ]))
+ expect_equal(x14$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[2, ]))
+ expect_equal(x14$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x14$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x14$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x14$selectedArms))))
+ expect_equal(x14$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x14$numberOfActiveArms[1, ]))
+ expect_equal(x14$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x14$numberOfActiveArms[2, ]))
+ expect_equal(x14$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x14$numberOfActiveArms[3, ]))
+ expect_equal(x14$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x14$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x14$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 1.9985289, NaN, NaN, 1.9973387, NaN, NaN, 1.996356, NaN, NaN, 2, NaN, NaN, 1.9678356, NaN, NaN, 1.9418117, NaN, NaN, 1.9203232, NaN, NaN, 2, NaN, NaN, 1.9497636, NaN, NaN, 1.9091179, NaN, NaN, 1.8755558, NaN, NaN, 2, NaN, NaN, 1.9371422, NaN, NaN, 1.8862847, NaN, NaN, 1.8442904, NaN, NaN, 2, NaN, NaN, 2.1467297, NaN, NaN, 2.265447, NaN, NaN, 2.3634747, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x14$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x14), NA)))
+ expect_output(print(x14)$show())
+ invisible(capture.output(expect_error(summary(x14), NA)))
+ expect_output(summary(x14)$show())
+ x14CodeBased <- eval(parse(text = getObjectRCode(x14, stringWrapParagraphWidth = NULL)))
+ expect_equal(x14CodeBased$eventsPerStage, x14$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$iterations, x14$iterations, tolerance = 1e-07)
+ expect_equal(x14CodeBased$rejectAtLeastOne, x14$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x14CodeBased$rejectedArmsPerStage, x14$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$futilityStop, x14$futilityStop, tolerance = 1e-07)
+ expect_equal(x14CodeBased$futilityPerStage, x14$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$earlyStop, x14$earlyStop, tolerance = 1e-07)
+ expect_equal(x14CodeBased$successPerStage, x14$successPerStage, tolerance = 1e-07)
+ expect_equal(x14CodeBased$selectedArms, x14$selectedArms, tolerance = 1e-07)
+ expect_equal(x14CodeBased$numberOfActiveArms, x14$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x14CodeBased$expectedNumberOfEvents, x14$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x14CodeBased$singleNumberOfEventsPerStage, x14$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x14), "character")
+ df <- as.data.frame(x14)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x14)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x15 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "all",
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Sidak",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x15' with expected results
+ expect_equal(unlist(as.list(x15$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x15$eventsPerStage))))
+ expect_equal(x15$iterations[1, ], c(10, 10, 10, 10), label = paste0(x15$iterations[1, ]))
+ expect_equal(x15$iterations[2, ], c(0, 0, 0, 0), label = paste0(x15$iterations[2, ]))
+ expect_equal(x15$iterations[3, ], c(0, 0, 0, 0), label = paste0(x15$iterations[3, ]))
+ expect_equal(x15$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x15$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x15$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x15$rejectedArmsPerStage))))
+ expect_equal(x15$futilityStop, c(1, 1, 1, 1), label = paste0(x15$futilityStop))
+ expect_equal(x15$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x15$futilityPerStage[1, ]))
+ expect_equal(x15$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x15$futilityPerStage[2, ]))
+ expect_equal(x15$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x15$earlyStop[1, ]))
+ expect_equal(x15$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x15$earlyStop[2, ]))
+ expect_equal(x15$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x15$successPerStage[1, ]))
+ expect_equal(x15$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x15$successPerStage[2, ]))
+ expect_equal(x15$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x15$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x15$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x15$selectedArms))))
+ expect_equal(x15$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x15$numberOfActiveArms[1, ]))
+ expect_equal(x15$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x15$numberOfActiveArms[2, ]))
+ expect_equal(x15$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x15$numberOfActiveArms[3, ]))
+ expect_equal(x15$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x15$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x15$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x15$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x15), NA)))
+ expect_output(print(x15)$show())
+ invisible(capture.output(expect_error(summary(x15), NA)))
+ expect_output(summary(x15)$show())
+ x15CodeBased <- eval(parse(text = getObjectRCode(x15, stringWrapParagraphWidth = NULL)))
+ expect_equal(x15CodeBased$eventsPerStage, x15$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$iterations, x15$iterations, tolerance = 1e-07)
+ expect_equal(x15CodeBased$rejectAtLeastOne, x15$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x15CodeBased$rejectedArmsPerStage, x15$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$futilityStop, x15$futilityStop, tolerance = 1e-07)
+ expect_equal(x15CodeBased$futilityPerStage, x15$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$earlyStop, x15$earlyStop, tolerance = 1e-07)
+ expect_equal(x15CodeBased$successPerStage, x15$successPerStage, tolerance = 1e-07)
+ expect_equal(x15CodeBased$selectedArms, x15$selectedArms, tolerance = 1e-07)
+ expect_equal(x15CodeBased$numberOfActiveArms, x15$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x15CodeBased$expectedNumberOfEvents, x15$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x15CodeBased$singleNumberOfEventsPerStage, x15$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x15), "character")
+ df <- as.data.frame(x15)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x15)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x16 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "rBest", rValue = 2,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Simes",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x16' with expected results
+ expect_equal(unlist(as.list(x16$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x16$eventsPerStage))))
+ expect_equal(x16$iterations[1, ], c(10, 10, 10, 10), label = paste0(x16$iterations[1, ]))
+ expect_equal(x16$iterations[2, ], c(0, 0, 0, 0), label = paste0(x16$iterations[2, ]))
+ expect_equal(x16$iterations[3, ], c(0, 0, 0, 0), label = paste0(x16$iterations[3, ]))
+ expect_equal(x16$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x16$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x16$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x16$rejectedArmsPerStage))))
+ expect_equal(x16$futilityStop, c(1, 1, 1, 1), label = paste0(x16$futilityStop))
+ expect_equal(x16$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x16$futilityPerStage[1, ]))
+ expect_equal(x16$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x16$futilityPerStage[2, ]))
+ expect_equal(x16$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x16$earlyStop[1, ]))
+ expect_equal(x16$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x16$earlyStop[2, ]))
+ expect_equal(x16$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x16$successPerStage[1, ]))
+ expect_equal(x16$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x16$successPerStage[2, ]))
+ expect_equal(x16$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x16$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x16$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x16$selectedArms))))
+ expect_equal(x16$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x16$numberOfActiveArms[1, ]))
+ expect_equal(x16$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x16$numberOfActiveArms[2, ]))
+ expect_equal(x16$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x16$numberOfActiveArms[3, ]))
+ expect_equal(x16$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x16$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x16$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x16$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x16), NA)))
+ expect_output(print(x16)$show())
+ invisible(capture.output(expect_error(summary(x16), NA)))
+ expect_output(summary(x16)$show())
+ x16CodeBased <- eval(parse(text = getObjectRCode(x16, stringWrapParagraphWidth = NULL)))
+ expect_equal(x16CodeBased$eventsPerStage, x16$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$iterations, x16$iterations, tolerance = 1e-07)
+ expect_equal(x16CodeBased$rejectAtLeastOne, x16$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x16CodeBased$rejectedArmsPerStage, x16$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$futilityStop, x16$futilityStop, tolerance = 1e-07)
+ expect_equal(x16CodeBased$futilityPerStage, x16$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$earlyStop, x16$earlyStop, tolerance = 1e-07)
+ expect_equal(x16CodeBased$successPerStage, x16$successPerStage, tolerance = 1e-07)
+ expect_equal(x16CodeBased$selectedArms, x16$selectedArms, tolerance = 1e-07)
+ expect_equal(x16CodeBased$numberOfActiveArms, x16$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x16CodeBased$expectedNumberOfEvents, x16$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x16CodeBased$singleNumberOfEventsPerStage, x16$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x16), "character")
+ df <- as.data.frame(x16)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x16)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x17 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = rep(TRUE, 2),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Simes",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x17' with expected results
+ expect_equal(unlist(as.list(x17$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x17$eventsPerStage))))
+ expect_equal(x17$iterations[1, ], c(10, 10, 10, 10), label = paste0(x17$iterations[1, ]))
+ expect_equal(x17$iterations[2, ], c(0, 0, 0, 0), label = paste0(x17$iterations[2, ]))
+ expect_equal(x17$iterations[3, ], c(0, 0, 0, 0), label = paste0(x17$iterations[3, ]))
+ expect_equal(x17$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x17$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x17$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x17$rejectedArmsPerStage))))
+ expect_equal(x17$futilityStop, c(1, 1, 1, 1), label = paste0(x17$futilityStop))
+ expect_equal(x17$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x17$futilityPerStage[1, ]))
+ expect_equal(x17$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x17$futilityPerStage[2, ]))
+ expect_equal(x17$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x17$earlyStop[1, ]))
+ expect_equal(x17$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x17$earlyStop[2, ]))
+ expect_equal(x17$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x17$successPerStage[1, ]))
+ expect_equal(x17$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x17$successPerStage[2, ]))
+ expect_equal(x17$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x17$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x17$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x17$selectedArms))))
+ expect_equal(x17$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x17$numberOfActiveArms[1, ]))
+ expect_equal(x17$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x17$numberOfActiveArms[2, ]))
+ expect_equal(x17$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x17$numberOfActiveArms[3, ]))
+ expect_equal(x17$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x17$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x17$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x17$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x17), NA)))
+ expect_output(print(x17)$show())
+ invisible(capture.output(expect_error(summary(x17), NA)))
+ expect_output(summary(x17)$show())
+ x17CodeBased <- eval(parse(text = getObjectRCode(x17, stringWrapParagraphWidth = NULL)))
+ expect_equal(x17CodeBased$eventsPerStage, x17$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$iterations, x17$iterations, tolerance = 1e-07)
+ expect_equal(x17CodeBased$rejectAtLeastOne, x17$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x17CodeBased$rejectedArmsPerStage, x17$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$futilityStop, x17$futilityStop, tolerance = 1e-07)
+ expect_equal(x17CodeBased$futilityPerStage, x17$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$earlyStop, x17$earlyStop, tolerance = 1e-07)
+ expect_equal(x17CodeBased$successPerStage, x17$successPerStage, tolerance = 1e-07)
+ expect_equal(x17CodeBased$selectedArms, x17$selectedArms, tolerance = 1e-07)
+ expect_equal(x17CodeBased$numberOfActiveArms, x17$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x17CodeBased$expectedNumberOfEvents, x17$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x17CodeBased$singleNumberOfEventsPerStage, x17$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x17), "character")
+ df <- as.data.frame(x17)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x17)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x18 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Simes",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x18' with expected results
+ expect_equal(unlist(as.list(x18$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x18$eventsPerStage))))
+ expect_equal(x18$iterations[1, ], c(10, 10, 10, 10), label = paste0(x18$iterations[1, ]))
+ expect_equal(x18$iterations[2, ], c(0, 0, 0, 0), label = paste0(x18$iterations[2, ]))
+ expect_equal(x18$iterations[3, ], c(0, 0, 0, 0), label = paste0(x18$iterations[3, ]))
+ expect_equal(x18$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x18$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x18$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x18$rejectedArmsPerStage))))
+ expect_equal(x18$futilityStop, c(1, 1, 1, 1), label = paste0(x18$futilityStop))
+ expect_equal(x18$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x18$futilityPerStage[1, ]))
+ expect_equal(x18$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x18$futilityPerStage[2, ]))
+ expect_equal(x18$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x18$earlyStop[1, ]))
+ expect_equal(x18$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x18$earlyStop[2, ]))
+ expect_equal(x18$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x18$successPerStage[1, ]))
+ expect_equal(x18$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x18$successPerStage[2, ]))
+ expect_equal(x18$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x18$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x18$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x18$selectedArms))))
+ expect_equal(x18$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x18$numberOfActiveArms[1, ]))
+ expect_equal(x18$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x18$numberOfActiveArms[2, ]))
+ expect_equal(x18$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x18$numberOfActiveArms[3, ]))
+ expect_equal(x18$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x18$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x18$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x18$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x18), NA)))
+ expect_output(print(x18)$show())
+ invisible(capture.output(expect_error(summary(x18), NA)))
+ expect_output(summary(x18)$show())
+ x18CodeBased <- eval(parse(text = getObjectRCode(x18, stringWrapParagraphWidth = NULL)))
+ expect_equal(x18CodeBased$eventsPerStage, x18$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$iterations, x18$iterations, tolerance = 1e-07)
+ expect_equal(x18CodeBased$rejectAtLeastOne, x18$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x18CodeBased$rejectedArmsPerStage, x18$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$futilityStop, x18$futilityStop, tolerance = 1e-07)
+ expect_equal(x18CodeBased$futilityPerStage, x18$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$earlyStop, x18$earlyStop, tolerance = 1e-07)
+ expect_equal(x18CodeBased$successPerStage, x18$successPerStage, tolerance = 1e-07)
+ expect_equal(x18CodeBased$selectedArms, x18$selectedArms, tolerance = 1e-07)
+ expect_equal(x18CodeBased$numberOfActiveArms, x18$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x18CodeBased$expectedNumberOfEvents, x18$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x18CodeBased$singleNumberOfEventsPerStage, x18$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x18), "character")
+ df <- as.data.frame(x18)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x18)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x19 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "all",
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ intersectionTest = "Bonferroni",
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x19' with expected results
+ expect_equal(unlist(as.list(x19$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x19$eventsPerStage))))
+ expect_equal(x19$iterations[1, ], c(10, 10, 10, 10), label = paste0(x19$iterations[1, ]))
+ expect_equal(x19$iterations[2, ], c(0, 0, 0, 0), label = paste0(x19$iterations[2, ]))
+ expect_equal(x19$iterations[3, ], c(0, 0, 0, 0), label = paste0(x19$iterations[3, ]))
+ expect_equal(x19$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x19$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x19$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x19$rejectedArmsPerStage))))
+ expect_equal(x19$futilityStop, c(1, 1, 1, 1), label = paste0(x19$futilityStop))
+ expect_equal(x19$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x19$futilityPerStage[1, ]))
+ expect_equal(x19$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x19$futilityPerStage[2, ]))
+ expect_equal(x19$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x19$earlyStop[1, ]))
+ expect_equal(x19$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x19$earlyStop[2, ]))
+ expect_equal(x19$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x19$successPerStage[1, ]))
+ expect_equal(x19$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x19$successPerStage[2, ]))
+ expect_equal(x19$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x19$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x19$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x19$selectedArms))))
+ expect_equal(x19$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x19$numberOfActiveArms[1, ]))
+ expect_equal(x19$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x19$numberOfActiveArms[2, ]))
+ expect_equal(x19$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x19$numberOfActiveArms[3, ]))
+ expect_equal(x19$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x19$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x19$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x19$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x19), NA)))
+ expect_output(print(x19)$show())
+ invisible(capture.output(expect_error(summary(x19), NA)))
+ expect_output(summary(x19)$show())
+ x19CodeBased <- eval(parse(text = getObjectRCode(x19, stringWrapParagraphWidth = NULL)))
+ expect_equal(x19CodeBased$eventsPerStage, x19$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$iterations, x19$iterations, tolerance = 1e-07)
+ expect_equal(x19CodeBased$rejectAtLeastOne, x19$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x19CodeBased$rejectedArmsPerStage, x19$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$futilityStop, x19$futilityStop, tolerance = 1e-07)
+ expect_equal(x19CodeBased$futilityPerStage, x19$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$earlyStop, x19$earlyStop, tolerance = 1e-07)
+ expect_equal(x19CodeBased$successPerStage, x19$successPerStage, tolerance = 1e-07)
+ expect_equal(x19CodeBased$selectedArms, x19$selectedArms, tolerance = 1e-07)
+ expect_equal(x19CodeBased$numberOfActiveArms, x19$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x19CodeBased$expectedNumberOfEvents, x19$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x19CodeBased$singleNumberOfEventsPerStage, x19$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x19), "character")
+ df <- as.data.frame(x19)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x19)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x20 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "rBest", rValue = 2,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x20' with expected results
+ expect_equal(unlist(as.list(x20$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x20$eventsPerStage))))
+ expect_equal(x20$iterations[1, ], c(10, 10, 10, 10), label = paste0(x20$iterations[1, ]))
+ expect_equal(x20$iterations[2, ], c(0, 0, 0, 0), label = paste0(x20$iterations[2, ]))
+ expect_equal(x20$iterations[3, ], c(0, 0, 0, 0), label = paste0(x20$iterations[3, ]))
+ expect_equal(x20$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x20$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x20$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x20$rejectedArmsPerStage))))
+ expect_equal(x20$futilityStop, c(1, 1, 1, 1), label = paste0(x20$futilityStop))
+ expect_equal(x20$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x20$futilityPerStage[1, ]))
+ expect_equal(x20$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x20$futilityPerStage[2, ]))
+ expect_equal(x20$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x20$earlyStop[1, ]))
+ expect_equal(x20$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x20$earlyStop[2, ]))
+ expect_equal(x20$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[1, ]))
+ expect_equal(x20$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[2, ]))
+ expect_equal(x20$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x20$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x20$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x20$selectedArms))))
+ expect_equal(x20$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x20$numberOfActiveArms[1, ]))
+ expect_equal(x20$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x20$numberOfActiveArms[2, ]))
+ expect_equal(x20$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x20$numberOfActiveArms[3, ]))
+ expect_equal(x20$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x20$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x20$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x20$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x20), NA)))
+ expect_output(print(x20)$show())
+ invisible(capture.output(expect_error(summary(x20), NA)))
+ expect_output(summary(x20)$show())
+ x20CodeBased <- eval(parse(text = getObjectRCode(x20, stringWrapParagraphWidth = NULL)))
+ expect_equal(x20CodeBased$eventsPerStage, x20$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$iterations, x20$iterations, tolerance = 1e-07)
+ expect_equal(x20CodeBased$rejectAtLeastOne, x20$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x20CodeBased$rejectedArmsPerStage, x20$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$futilityStop, x20$futilityStop, tolerance = 1e-07)
+ expect_equal(x20CodeBased$futilityPerStage, x20$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$earlyStop, x20$earlyStop, tolerance = 1e-07)
+ expect_equal(x20CodeBased$successPerStage, x20$successPerStage, tolerance = 1e-07)
+ expect_equal(x20CodeBased$selectedArms, x20$selectedArms, tolerance = 1e-07)
+ expect_equal(x20CodeBased$numberOfActiveArms, x20$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x20CodeBased$expectedNumberOfEvents, x20$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x20CodeBased$singleNumberOfEventsPerStage, x20$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x20), "character")
+ df <- as.data.frame(x20)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x20)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x21 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0, typeOfSelection = "epsilon", epsilonValue = 0.1,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = 1 / seq(1, 1.6, 0.2), adaptations = c(TRUE, FALSE),
+ intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x21' with expected results
+ expect_equal(unlist(as.list(x21$eventsPerStage)), c(4, 4, 4, 4.2727273, 4.2727273, 4.2727273, 4.5, 4.5, 4.5, 4.6923077, 4.6923077, 4.6923077, 4, 4, 4, 4.1818182, 4.1818182, 4.1818182, 4.3333333, 4.3333333, 4.3333333, 4.4615385, 4.4615385, 4.4615385, 4, 4, 4, 4.0909091, 4.0909091, 4.0909091, 4.1666667, 4.1666667, 4.1666667, 4.2307692, 4.2307692, 4.2307692, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4), tolerance = 1e-07, label = paste0(unlist(as.list(x21$eventsPerStage))))
+ expect_equal(x21$iterations[1, ], c(10, 10, 10, 10), label = paste0(x21$iterations[1, ]))
+ expect_equal(x21$iterations[2, ], c(0, 0, 0, 0), label = paste0(x21$iterations[2, ]))
+ expect_equal(x21$iterations[3, ], c(0, 0, 0, 0), label = paste0(x21$iterations[3, ]))
+ expect_equal(x21$rejectAtLeastOne, c(0, 0, 0, 0), label = paste0(x21$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x21$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = paste0(unlist(as.list(x21$rejectedArmsPerStage))))
+ expect_equal(x21$futilityStop, c(1, 1, 1, 1), label = paste0(x21$futilityStop))
+ expect_equal(x21$futilityPerStage[1, ], c(1, 1, 1, 1), label = paste0(x21$futilityPerStage[1, ]))
+ expect_equal(x21$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x21$futilityPerStage[2, ]))
+ expect_equal(x21$earlyStop[1, ], c(1, 1, 1, 1), label = paste0(x21$earlyStop[1, ]))
+ expect_equal(x21$earlyStop[2, ], c(0, 0, 0, 0), label = paste0(x21$earlyStop[2, ]))
+ expect_equal(x21$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[1, ]))
+ expect_equal(x21$successPerStage[2, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[2, ]))
+ expect_equal(x21$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x21$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x21$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), label = paste0(unlist(as.list(x21$selectedArms))))
+ expect_equal(x21$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x21$numberOfActiveArms[1, ]))
+ expect_equal(x21$numberOfActiveArms[2, ], c(NaN, NaN, NaN, NaN), label = paste0(x21$numberOfActiveArms[2, ]))
+ expect_equal(x21$numberOfActiveArms[3, ], c(NaN, NaN, NaN, NaN), label = paste0(x21$numberOfActiveArms[3, ]))
+ expect_equal(x21$expectedNumberOfEvents, c(NaN, NaN, NaN, NaN), label = paste0(x21$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x21$singleNumberOfEventsPerStage)), c(2, NaN, NaN, 2.0909091, NaN, NaN, 2.1666667, NaN, NaN, 2.2307692, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 2, NaN, NaN, 1.9090909, NaN, NaN, 1.8333333, NaN, NaN, 1.7692308, NaN, NaN, 2, NaN, NaN, 1.8181818, NaN, NaN, 1.6666667, NaN, NaN, 1.5384615, NaN, NaN, 2, NaN, NaN, 2.1818182, NaN, NaN, 2.3333333, NaN, NaN, 2.4615385, NaN, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x21$singleNumberOfEventsPerStage))))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x21), NA)))
+ expect_output(print(x21)$show())
+ invisible(capture.output(expect_error(summary(x21), NA)))
+ expect_output(summary(x21)$show())
+ x21CodeBased <- eval(parse(text = getObjectRCode(x21, stringWrapParagraphWidth = NULL)))
+ expect_equal(x21CodeBased$eventsPerStage, x21$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$iterations, x21$iterations, tolerance = 1e-07)
+ expect_equal(x21CodeBased$rejectAtLeastOne, x21$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x21CodeBased$rejectedArmsPerStage, x21$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$futilityStop, x21$futilityStop, tolerance = 1e-07)
+ expect_equal(x21CodeBased$futilityPerStage, x21$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$earlyStop, x21$earlyStop, tolerance = 1e-07)
+ expect_equal(x21CodeBased$successPerStage, x21$successPerStage, tolerance = 1e-07)
+ expect_equal(x21CodeBased$selectedArms, x21$selectedArms, tolerance = 1e-07)
+ expect_equal(x21CodeBased$numberOfActiveArms, x21$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x21CodeBased$expectedNumberOfEvents, x21$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x21CodeBased$singleNumberOfEventsPerStage, x21$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_type(names(x21), "character")
+ df <- as.data.frame(x21)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x21)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x22 <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ activeArms = 4, directionUpper = FALSE, threshold = 0.1,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(0.1, 0.3, 0.1), intersectionTest = "Bonferroni",
+ conditionalPower = 0.8, minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x22' with expected results
+ expect_equal(unlist(as.list(x22$eventsPerStage)), c(6.4545455, 10.090909, 10.090909, 6, 9.1343922, 9.1343922, 5.6153846, 8.7178796, 8.7178796, 5.6363636, 9.2727273, 9.2727273, 5.3333333, 8.8427255, 8.8427255, 5.0769231, 8.7046706, 8.7046706, 4.8181818, 8.4545455, 8.4545455, 4.6666667, 8.1381491, 8.1381491, 4.5384615, 7.6409565, 7.6409565, 4, 8, 8, 4, 7.4677255, 7.4677255, 4, 7.7908192, 7.7908192), tolerance = 1e-07, label = paste0(unlist(as.list(x22$eventsPerStage))))
+ expect_equal(x22$iterations[1, ], c(10, 10, 10), label = paste0(x22$iterations[1, ]))
+ expect_equal(x22$iterations[2, ], c(1, 4, 3), label = paste0(x22$iterations[2, ]))
+ expect_equal(x22$iterations[3, ], c(0, 0, 0), label = paste0(x22$iterations[3, ]))
+ expect_equal(x22$rejectAtLeastOne, c(0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0(x22$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x22$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0.1, 0, 0, 0.2, 0, 0, 0.2, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x22$rejectedArmsPerStage))))
+ expect_equal(x22$futilityStop, c(0.9, 0.7, 0.8), tolerance = 1e-07, label = paste0(x22$futilityStop))
+ expect_equal(x22$futilityPerStage[1, ], c(0.9, 0.6, 0.7), tolerance = 1e-07, label = paste0(x22$futilityPerStage[1, ]))
+ expect_equal(x22$futilityPerStage[2, ], c(0, 0.1, 0.1), tolerance = 1e-07, label = paste0(x22$futilityPerStage[2, ]))
+ expect_equal(x22$earlyStop[1, ], c(0.9, 0.6, 0.7), tolerance = 1e-07, label = paste0(x22$earlyStop[1, ]))
+ expect_equal(x22$earlyStop[2, ], c(0.1, 0.4, 0.3), tolerance = 1e-07, label = paste0(x22$earlyStop[2, ]))
+ expect_equal(x22$successPerStage[1, ], c(0, 0, 0), label = paste0(x22$successPerStage[1, ]))
+ expect_equal(x22$successPerStage[2, ], c(0.1, 0.3, 0.2), tolerance = 1e-07, label = paste0(x22$successPerStage[2, ]))
+ expect_equal(x22$successPerStage[3, ], c(0, 0, 0), label = paste0(x22$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x22$selectedArms)), c(1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0.1, 0, 1, 0.1, 0, 1, 0, 0, 1, 0.1, 0, 1, 0, 0, 1, 0.1, 0, 1, 0.2, 0, 1, 0.2, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x22$selectedArms))))
+ expect_equal(x22$numberOfActiveArms[1, ], c(4, 4, 4), label = paste0(x22$numberOfActiveArms[1, ]))
+ expect_equal(x22$numberOfActiveArms[2, ], c(1, 1, 1), label = paste0(x22$numberOfActiveArms[2, ]))
+ expect_equal(x22$numberOfActiveArms[3, ], c(NaN, NaN, NaN), label = paste0(x22$numberOfActiveArms[3, ]))
+ expect_equal(x22$expectedNumberOfEvents, c(NaN, NaN, NaN), label = paste0(x22$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x22$singleNumberOfEventsPerStage)), c(2.8181818, 0, NaN, 2.6666667, 0, NaN, 2.5384615, 0, NaN, 2, 0, NaN, 2, 0.375, NaN, 2, 0.52525253, NaN, 1.1818182, 0, NaN, 1.3333333, 0.33709021, NaN, 1.4615385, 0, NaN, 0.36363636, 0.36363636, NaN, 0.66666667, 0.33333333, NaN, 0.92307692, 0.68832425, NaN, 3.6363636, 3.6363636, NaN, 3.3333333, 3.1343922, NaN, 3.0769231, 3.102495, NaN), tolerance = 1e-07, label = paste0(unlist(as.list(x22$singleNumberOfEventsPerStage))))
+ expect_equal(x22$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x22$conditionalPowerAchieved[1, ]))
+ expect_equal(x22$conditionalPowerAchieved[2, ], c(0.99998124, 0.93006261, 0.86196268), tolerance = 1e-07, label = paste0(x22$conditionalPowerAchieved[2, ]))
+ expect_equal(x22$conditionalPowerAchieved[3, ], c(NaN, NaN, NaN), label = paste0(x22$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x22), NA)))
+ expect_output(print(x22)$show())
+ invisible(capture.output(expect_error(summary(x22), NA)))
+ expect_output(summary(x22)$show())
+ x22CodeBased <- eval(parse(text = getObjectRCode(x22, stringWrapParagraphWidth = NULL)))
+ expect_equal(x22CodeBased$eventsPerStage, x22$eventsPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$iterations, x22$iterations, tolerance = 1e-07)
+ expect_equal(x22CodeBased$rejectAtLeastOne, x22$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(x22CodeBased$rejectedArmsPerStage, x22$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$futilityStop, x22$futilityStop, tolerance = 1e-07)
+ expect_equal(x22CodeBased$futilityPerStage, x22$futilityPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$earlyStop, x22$earlyStop, tolerance = 1e-07)
+ expect_equal(x22CodeBased$successPerStage, x22$successPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$selectedArms, x22$selectedArms, tolerance = 1e-07)
+ expect_equal(x22CodeBased$numberOfActiveArms, x22$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(x22CodeBased$expectedNumberOfEvents, x22$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(x22CodeBased$singleNumberOfEventsPerStage, x22$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(x22CodeBased$conditionalPowerAchieved, x22$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x22), "character")
+ df <- as.data.frame(x22)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x22)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmSurvival': using calcSubjectsFunction", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- calcSubjectsFunctionSimulationMultiArmSurvival <- function(..., stage, minNumberOfEventsPerStage) {
- return(ifelse(stage == 3, 33, minNumberOfEventsPerStage[stage]))
- }
-
- x <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
- directionUpper = FALSE,
- minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
- maxNumberOfIterations = 10, calcEventsFunction = calcSubjectsFunctionSimulationMultiArmSurvival
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x' with expected results
- expect_equal(unlist(as.list(x$eventsPerStage)), c(5.6153846, 8.5080558, 32.538332, 5.2857143, 7.9818379, 30.224858, 5, 7.6798535, 30.027381, 4.75, 7.4486928, 28.520044, 5.0769231, 8.1039238, 33.365555, 4.8571429, 7.7179724, 31.319816, 4.6666667, 7.3312821, 29.521667, 4.5, 6.9975232, 27.961662, 4.5384615, 7.765565, 33.68068, 4.4285714, 7.692437, 34.619328, 4.3333333, 7.4419048, 32.624048, 4.25, 7.3932749, 34.276803, 4, 6.9887723, 31.899976, 4, 7.2675522, 34.224858, 4, 7.0265201, 31.574048, 4, 6.6197454, 28.704254), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(9, 10, 8, 9), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.3, 0.4, 0.7, 0.3), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.1, 0.2, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0.3, 0, 0.1, 0.3, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.1, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0.1, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0.2, 0.4, 0.5, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.1, 0.1, 1, 0, 0, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.4, 0.4, 1, 0.4, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.4, 0.3, 1, 0.2, 0.2), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfEvents, c(43.7, 47, 40.4, 43.7), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$singleNumberOfEventsPerStage)), c(2.5384615, 0.18082192, 1.6575342, 2.4285714, 0, 0, 2.3333333, 0.18666667, 1.925, 2.25, 0.37894737, 1.7368421, 2, 0.31515152, 2.8888889, 2, 0.16470588, 1.3588235, 2, 0.17142857, 1.7678571, 2, 0.17777778, 1.6296296, 1.4615385, 0.51525424, 3.5423729, 1.5714286, 0.56774194, 4.683871, 1.6666667, 0.61538462, 4.7596154, 1.75, 0.82352941, 7.5490196, 0.92307692, 0.27692308, 2.5384615, 1.1428571, 0.57142857, 4.7142857, 1.3333333, 0.53333333, 4.125, 1.5, 0.3, 2.75, 3.0769231, 2.7118493, 22.372742, 2.8571429, 2.6961236, 22.24302, 2.6666667, 2.4931868, 20.422527, 2.5, 2.3197454, 19.334509), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.13227215, 0.33500952, 0.32478794, 0.19174696), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.28682503, 0.6076832, 0.60939504, 0.37477275), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$eventsPerStage, x$eventsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfEvents, x$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(xCodeBased$singleNumberOfEventsPerStage, x$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ calcSubjectsFunctionSimulationMultiArmSurvival <- function(..., stage, minNumberOfEventsPerStage) {
+ return(ifelse(stage == 3, 33, minNumberOfEventsPerStage[stage]))
+ }
+
+ x <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2),
+ directionUpper = FALSE,
+ minNumberOfEventsPerStage = c(10, 4, 4), maxNumberOfEventsPerStage = c(10, 100, 100),
+ maxNumberOfIterations = 10, calcEventsFunction = calcSubjectsFunctionSimulationMultiArmSurvival
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x' with expected results
+ expect_equal(unlist(as.list(x$eventsPerStage)), c(5.6153846, 8.5080558, 32.538332, 5.2857143, 7.9818379, 30.224858, 5, 7.6798535, 30.027381, 4.75, 7.4486928, 28.520044, 5.0769231, 8.1039238, 33.365555, 4.8571429, 7.7179724, 31.319816, 4.6666667, 7.3312821, 29.521667, 4.5, 6.9975232, 27.961662, 4.5384615, 7.765565, 33.68068, 4.4285714, 7.692437, 34.619328, 4.3333333, 7.4419048, 32.624048, 4.25, 7.3932749, 34.276803, 4, 6.9887723, 31.899976, 4, 7.2675522, 34.224858, 4, 7.0265201, 31.574048, 4, 6.6197454, 28.704254), tolerance = 1e-07, label = paste0(unlist(as.list(x$eventsPerStage))))
+ expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(9, 10, 8, 9), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.3, 0.4, 0.7, 0.3), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0.1, 0.1, 0, 0, 0, 0, 0.1, 0.2, 0, 0, 0.1, 0, 0, 0.1, 0, 0, 0.3, 0, 0.1, 0.3, 0, 0, 0.1), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.1, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0.1, 0, 0.2, 0.1), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0.2, 0.4, 0.5, 0.2), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.1, 0.1, 1, 0, 0, 1, 0.1, 0.1, 1, 0.2, 0.1, 1, 0.2, 0.2, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.1, 0.1, 1, 0.4, 0.3, 1, 0.4, 0.4, 1, 0.4, 0.3, 1, 0.5, 0.5, 1, 0.3, 0.3, 1, 0.5, 0.5, 1, 0.4, 0.3, 1, 0.2, 0.2), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfEvents, c(43.7, 47, 40.4, 43.7), tolerance = 1e-07, label = paste0(x$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x$singleNumberOfEventsPerStage)), c(2.5384615, 0.18082192, 1.6575342, 2.4285714, 0, 0, 2.3333333, 0.18666667, 1.925, 2.25, 0.37894737, 1.7368421, 2, 0.31515152, 2.8888889, 2, 0.16470588, 1.3588235, 2, 0.17142857, 1.7678571, 2, 0.17777778, 1.6296296, 1.4615385, 0.51525424, 3.5423729, 1.5714286, 0.56774194, 4.683871, 1.6666667, 0.61538462, 4.7596154, 1.75, 0.82352941, 7.5490196, 0.92307692, 0.27692308, 2.5384615, 1.1428571, 0.57142857, 4.7142857, 1.3333333, 0.53333333, 4.125, 1.5, 0.3, 2.75, 3.0769231, 2.7118493, 22.372742, 2.8571429, 2.6961236, 22.24302, 2.6666667, 2.4931868, 20.422527, 2.5, 2.3197454, 19.334509), tolerance = 1e-07, label = paste0(unlist(as.list(x$singleNumberOfEventsPerStage))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.13227215, 0.33500952, 0.32478794, 0.19174696), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.28682503, 0.6076832, 0.60939504, 0.37477275), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$eventsPerStage, x$eventsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfEvents, x$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(xCodeBased$singleNumberOfEventsPerStage, x$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmSurvival': using selectArmsFunction", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- selectArmsFunctionSimulationMultiArmSurvival <- function(effectSizes) {
- return(c(TRUE, FALSE, FALSE, FALSE))
- }
-
- x <- getSimulationMultiArmSurvival(
- seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
- typeOfShape = "linear", activeArms = 4,
- plannedEvents = c(10, 30, 50), omegaMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2), directionUpper = FALSE,
- maxNumberOfIterations = 10, selectArmsFunction = selectArmsFunctionSimulationMultiArmSurvival, typeOfSelection = "userDefined"
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x' with expected results
- expect_equal(unlist(as.list(x$eventsPerStage)), c(5.6153846, 25.615385, 45.615385, 5.2857143, 25.285714, 45.285714, 5, 25, 45, 4.75, 24.75, 44.75, 5.0769231, 16.035827, 26.994731, 4.8571429, 15.667954, 26.478764, 4.6666667, 15.333333, 26, 4.5, 15.026316, 25.552632, 4.5384615, 15.497366, 26.45627, 4.4285714, 15.239382, 26.050193, 4.3333333, 15, 25.666667, 4.25, 14.776316, 25.302632, 4, 14.958904, 25.917808, 4, 14.810811, 25.621622, 4, 14.666667, 25.333333, 4, 14.526316, 25.052632), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(10, 10, 10, 9), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfEvents, c(50, 50, 50, 48), label = paste0("c(", paste0(x$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$singleNumberOfEventsPerStage)), c(2.5384615, 9.0410959, 9.0410959, 2.4285714, 9.1891892, 9.1891892, 2.3333333, 9.3333333, 9.3333333, 2.25, 9.4736842, 9.4736842, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 1.4615385, 0, 0, 1.5714286, 0, 0, 1.6666667, 0, 0, 1.75, 0, 0, 0.92307692, 0, 0, 1.1428571, 0, 0, 1.3333333, 0, 0, 1.5, 0, 0, 3.0769231, 10.958904, 10.958904, 2.8571429, 10.810811, 10.810811, 2.6666667, 10.666667, 10.666667, 2.5, 10.526316, 10.526316), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.33564601, 0.59192905, 0.61161484, 0.44432847), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.10158651, 0.080642472, 0.3234231, 0.034914809), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$eventsPerStage, x$eventsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfEvents, x$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(xCodeBased$singleNumberOfEventsPerStage, x$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ selectArmsFunctionSimulationMultiArmSurvival <- function(effectSizes) {
+ return(c(TRUE, FALSE, FALSE, FALSE))
+ }
+
+ x <- getSimulationMultiArmSurvival(
+ seed = 1234, getDesignInverseNormal(informationRates = c(0.2, 0.6, 1)),
+ typeOfShape = "linear", activeArms = 4,
+ plannedEvents = c(10, 30, 50), omegaMaxVector = seq(0.3, 0.6, 0.1), adaptations = rep(TRUE, 2), directionUpper = FALSE,
+ maxNumberOfIterations = 10, selectArmsFunction = selectArmsFunctionSimulationMultiArmSurvival, typeOfSelection = "userDefined"
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x' with expected results
+ expect_equal(unlist(as.list(x$eventsPerStage)), c(5.6153846, 25.615385, 45.615385, 5.2857143, 25.285714, 45.285714, 5, 25, 45, 4.75, 24.75, 44.75, 5.0769231, 16.035827, 26.994731, 4.8571429, 15.667954, 26.478764, 4.6666667, 15.333333, 26, 4.5, 15.026316, 25.552632, 4.5384615, 15.497366, 26.45627, 4.4285714, 15.239382, 26.050193, 4.3333333, 15, 25.666667, 4.25, 14.776316, 25.302632, 4, 14.958904, 25.917808, 4, 14.810811, 25.621622, 4, 14.666667, 25.333333, 4, 14.526316, 25.052632), tolerance = 1e-07, label = paste0(unlist(as.list(x$eventsPerStage))))
+ expect_equal(x$iterations[1, ], c(10, 10, 10, 10), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(10, 10, 10, 10), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(10, 10, 10, 9), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0, 0, 0, 0), label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0, 0, 0, 0), label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0, 0, 0, 0), label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0, 0, 0.1), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.9, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(4, 4, 4, 4), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(1, 1, 1, 1), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfEvents, c(50, 50, 50, 48), label = paste0(x$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x$singleNumberOfEventsPerStage)), c(2.5384615, 9.0410959, 9.0410959, 2.4285714, 9.1891892, 9.1891892, 2.3333333, 9.3333333, 9.3333333, 2.25, 9.4736842, 9.4736842, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 1.4615385, 0, 0, 1.5714286, 0, 0, 1.6666667, 0, 0, 1.75, 0, 0, 0.92307692, 0, 0, 1.1428571, 0, 0, 1.3333333, 0, 0, 1.5, 0, 0, 3.0769231, 10.958904, 10.958904, 2.8571429, 10.810811, 10.810811, 2.6666667, 10.666667, 10.666667, 2.5, 10.526316, 10.526316), tolerance = 1e-07, label = paste0(unlist(as.list(x$singleNumberOfEventsPerStage))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.33564601, 0.59192905, 0.61161484, 0.44432847), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.10158651, 0.080642472, 0.3234231, 0.034914809), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$eventsPerStage, x$eventsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfEvents, x$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(xCodeBased$singleNumberOfEventsPerStage, x$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmSurvival': typeOfShape = sigmoidEmax", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- designIN <- getDesignInverseNormal(typeOfDesign = "P", kMax = 3, futilityBounds = c(0, 0))
- x <- getSimulationMultiArmSurvival(designIN,
- activeArms = 3, typeOfShape = "sigmoidEmax",
- omegaMaxVector = seq(1, 1.9, 0.3), gED50 = 2, plannedEvents = cumsum(rep(50, 3)),
- intersectionTest = "Sidak", typeOfSelection = "rBest", rValue = 2, threshold = -Inf,
- successCriterion = "all", maxNumberOfIterations = 100, seed = 3456
- )
-
- ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x' with expected results
- expect_equal(unlist(as.list(x$eventsPerStage)), c(25, 54.166667, 83.179012, 23.702032, 48.059626, 73.088162, 22.633745, 47.376736, 72.759392, 21.73913, 42.12314, 62.760088, 25, 52.5, 80.895062, 24.266366, 53.226501, 81.514068, 23.662551, 48.016442, 72.194538, 23.1569, 49.755556, 76.303771, 25, 51.666667, 77.592593, 24.604966, 51.66004, 78.734811, 24.279835, 53.095902, 81.487679, 24.007561, 52.639961, 81.090004), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$eventsPerStage)), collapse = ", "), ")"))
- expect_equal(x$iterations[1, ], c(100, 100, 100, 100), label = paste0("c(", paste0(x$iterations[1, ], collapse = ", "), ")"))
- expect_equal(x$iterations[2, ], c(40, 57, 66, 79), label = paste0("c(", paste0(x$iterations[2, ], collapse = ", "), ")"))
- expect_equal(x$iterations[3, ], c(27, 48, 55, 70), label = paste0("c(", paste0(x$iterations[3, ], collapse = ", "), ")"))
- expect_equal(x$rejectAtLeastOne, c(0.02, 0.07, 0.19, 0.21), tolerance = 1e-07, label = paste0("c(", paste0(x$rejectAtLeastOne, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0.01, 0.01, 0.01, 0.02, 0.01, 0.02, 0, 0.02, 0.02, 0.01, 0, 0, 0, 0.01, 0.02, 0.03, 0.03, 0.01, 0.03, 0.06, 0.01, 0.01, 0, 0, 0.01, 0.01, 0.02, 0.04, 0.03, 0.07, 0.03, 0.09, 0.06), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$rejectedArmsPerStage)), collapse = ", "), ")"))
- expect_equal(x$futilityStop, c(0.73, 0.51, 0.41, 0.24), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityStop, collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[1, ], c(0.6, 0.43, 0.34, 0.21), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$futilityPerStage[2, ], c(0.13, 0.08, 0.07, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(x$futilityPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[1, ], c(0.6, 0.43, 0.34, 0.21), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[1, ], collapse = ", "), ")"))
- expect_equal(x$earlyStop[2, ], c(0.13, 0.09, 0.11, 0.09), tolerance = 1e-07, label = paste0("c(", paste0(x$earlyStop[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0("c(", paste0(x$successPerStage[1, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[2, ], c(0, 0.01, 0.04, 0.06), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[2, ], collapse = ", "), ")"))
- expect_equal(x$successPerStage[3, ], c(0, 0.02, 0.03, 0.05), tolerance = 1e-07, label = paste0("c(", paste0(x$successPerStage[3, ], collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.3, 0.2, 1, 0.31, 0.28, 1, 0.42, 0.37, 1, 0.35, 0.32, 1, 0.26, 0.19, 1, 0.45, 0.36, 1, 0.38, 0.31, 1, 0.59, 0.52, 1, 0.24, 0.15, 1, 0.38, 0.32, 1, 0.52, 0.42, 1, 0.64, 0.56), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$selectedArms)), collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[1, ], c(3, 3, 3, 3), label = paste0("c(", paste0(x$numberOfActiveArms[1, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x$numberOfActiveArms[2, ], collapse = ", "), ")"))
- expect_equal(x$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0("c(", paste0(x$numberOfActiveArms[3, ], collapse = ", "), ")"))
- expect_equal(x$expectedNumberOfEvents, c(83.5, 102.5, 110.5, 124.5), tolerance = 1e-07, label = paste0("c(", paste0(x$expectedNumberOfEvents, collapse = ", "), ")"))
- expect_equal(unlist(as.list(x$singleNumberOfEventsPerStage)), c(12.5, 12.5, 12.345679, 12.41535, 9.1711925, 9.8330988, 12.345679, 10.786517, 11.406391, 12.287335, 7.5764768, 7.8193452, 12.5, 10.833333, 11.728395, 12.979684, 13.773733, 13.092131, 13.374486, 10.397417, 10.201831, 13.705104, 13.791123, 13.730612, 12.5, 10, 9.2592593, 13.318284, 11.868672, 11.879334, 13.99177, 14.859592, 14.415513, 14.555766, 15.824867, 15.63244, 12.5, 16.666667, 16.666667, 11.286682, 15.186402, 15.195437, 10.288066, 13.956474, 13.976265, 9.4517958, 12.807533, 12.817602), tolerance = 1e-07, label = paste0("c(", paste0(unlist(as.list(x$singleNumberOfEventsPerStage)), collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x$conditionalPowerAchieved[1, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[2, ], c(0.066083689, 0.14406787, 0.27240426, 0.24161087), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[2, ], collapse = ", "), ")"))
- expect_equal(x$conditionalPowerAchieved[3, ], c(0.13321164, 0.19096794, 0.29528894, 0.30979546), tolerance = 1e-07, label = paste0("c(", paste0(x$conditionalPowerAchieved[3, ], collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(x), NA)))
- expect_output(print(x)$show())
- invisible(capture.output(expect_error(summary(x), NA)))
- expect_output(summary(x)$show())
- xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
- expect_equal(xCodeBased$eventsPerStage, x$eventsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
- expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
- expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
- expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
- expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
- expect_equal(xCodeBased$expectedNumberOfEvents, x$expectedNumberOfEvents, tolerance = 1e-07)
- expect_equal(xCodeBased$singleNumberOfEventsPerStage, x$singleNumberOfEventsPerStage, tolerance = 1e-07)
- expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
- expect_type(names(x), "character")
- df <- as.data.frame(x)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(x)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ # @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
+ designIN <- getDesignInverseNormal(typeOfDesign = "P", kMax = 3, futilityBounds = c(0, 0))
+ x <- getSimulationMultiArmSurvival(designIN,
+ activeArms = 3, typeOfShape = "sigmoidEmax",
+ omegaMaxVector = seq(1, 1.9, 0.3), gED50 = 2, plannedEvents = cumsum(rep(50, 3)),
+ intersectionTest = "Sidak", typeOfSelection = "rBest", rValue = 2, threshold = -Inf,
+ successCriterion = "all", maxNumberOfIterations = 100, seed = 3456
+ )
+
+ ## Comparison of the results of SimulationResultsMultiArmSurvival object 'x' with expected results
+ expect_equal(unlist(as.list(x$eventsPerStage)), c(25, 54.166667, 83.179012, 23.702032, 48.059626, 73.088162, 22.633745, 47.376736, 72.759392, 21.73913, 42.12314, 62.760088, 25, 52.5, 80.895062, 24.266366, 53.226501, 81.514068, 23.662551, 48.016442, 72.194538, 23.1569, 49.755556, 76.303771, 25, 51.666667, 77.592593, 24.604966, 51.66004, 78.734811, 24.279835, 53.095902, 81.487679, 24.007561, 52.639961, 81.090004), tolerance = 1e-07, label = paste0(unlist(as.list(x$eventsPerStage))))
+ expect_equal(x$iterations[1, ], c(100, 100, 100, 100), label = paste0(x$iterations[1, ]))
+ expect_equal(x$iterations[2, ], c(40, 57, 66, 79), label = paste0(x$iterations[2, ]))
+ expect_equal(x$iterations[3, ], c(27, 48, 55, 70), label = paste0(x$iterations[3, ]))
+ expect_equal(x$rejectAtLeastOne, c(0.02, 0.07, 0.19, 0.21), tolerance = 1e-07, label = paste0(x$rejectAtLeastOne))
+ expect_equal(unlist(as.list(x$rejectedArmsPerStage)), c(0, 0, 0, 0.01, 0.01, 0.01, 0.02, 0.01, 0.02, 0, 0.02, 0.02, 0.01, 0, 0, 0, 0.01, 0.02, 0.03, 0.03, 0.01, 0.03, 0.06, 0.01, 0.01, 0, 0, 0.01, 0.01, 0.02, 0.04, 0.03, 0.07, 0.03, 0.09, 0.06), tolerance = 1e-07, label = paste0(unlist(as.list(x$rejectedArmsPerStage))))
+ expect_equal(x$futilityStop, c(0.73, 0.51, 0.41, 0.24), tolerance = 1e-07, label = paste0(x$futilityStop))
+ expect_equal(x$futilityPerStage[1, ], c(0.6, 0.43, 0.34, 0.21), tolerance = 1e-07, label = paste0(x$futilityPerStage[1, ]))
+ expect_equal(x$futilityPerStage[2, ], c(0.13, 0.08, 0.07, 0.03), tolerance = 1e-07, label = paste0(x$futilityPerStage[2, ]))
+ expect_equal(x$earlyStop[1, ], c(0.6, 0.43, 0.34, 0.21), tolerance = 1e-07, label = paste0(x$earlyStop[1, ]))
+ expect_equal(x$earlyStop[2, ], c(0.13, 0.09, 0.11, 0.09), tolerance = 1e-07, label = paste0(x$earlyStop[2, ]))
+ expect_equal(x$successPerStage[1, ], c(0, 0, 0, 0), label = paste0(x$successPerStage[1, ]))
+ expect_equal(x$successPerStage[2, ], c(0, 0.01, 0.04, 0.06), tolerance = 1e-07, label = paste0(x$successPerStage[2, ]))
+ expect_equal(x$successPerStage[3, ], c(0, 0.02, 0.03, 0.05), tolerance = 1e-07, label = paste0(x$successPerStage[3, ]))
+ expect_equal(unlist(as.list(x$selectedArms)), c(1, 0.3, 0.2, 1, 0.31, 0.28, 1, 0.42, 0.37, 1, 0.35, 0.32, 1, 0.26, 0.19, 1, 0.45, 0.36, 1, 0.38, 0.31, 1, 0.59, 0.52, 1, 0.24, 0.15, 1, 0.38, 0.32, 1, 0.52, 0.42, 1, 0.64, 0.56), tolerance = 1e-07, label = paste0(unlist(as.list(x$selectedArms))))
+ expect_equal(x$numberOfActiveArms[1, ], c(3, 3, 3, 3), label = paste0(x$numberOfActiveArms[1, ]))
+ expect_equal(x$numberOfActiveArms[2, ], c(2, 2, 2, 2), label = paste0(x$numberOfActiveArms[2, ]))
+ expect_equal(x$numberOfActiveArms[3, ], c(2, 2, 2, 2), label = paste0(x$numberOfActiveArms[3, ]))
+ expect_equal(x$expectedNumberOfEvents, c(83.5, 102.5, 110.5, 124.5), tolerance = 1e-07, label = paste0(x$expectedNumberOfEvents))
+ expect_equal(unlist(as.list(x$singleNumberOfEventsPerStage)), c(12.5, 12.5, 12.345679, 12.41535, 9.1711925, 9.8330988, 12.345679, 10.786517, 11.406391, 12.287335, 7.5764768, 7.8193452, 12.5, 10.833333, 11.728395, 12.979684, 13.773733, 13.092131, 13.374486, 10.397417, 10.201831, 13.705104, 13.791123, 13.730612, 12.5, 10, 9.2592593, 13.318284, 11.868672, 11.879334, 13.99177, 14.859592, 14.415513, 14.555766, 15.824867, 15.63244, 12.5, 16.666667, 16.666667, 11.286682, 15.186402, 15.195437, 10.288066, 13.956474, 13.976265, 9.4517958, 12.807533, 12.817602), tolerance = 1e-07, label = paste0(unlist(as.list(x$singleNumberOfEventsPerStage))))
+ expect_equal(x$conditionalPowerAchieved[1, ], c(NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(x$conditionalPowerAchieved[1, ]))
+ expect_equal(x$conditionalPowerAchieved[2, ], c(0.066083689, 0.14406787, 0.27240426, 0.24161087), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[2, ]))
+ expect_equal(x$conditionalPowerAchieved[3, ], c(0.13321164, 0.19096794, 0.29528894, 0.30979546), tolerance = 1e-07, label = paste0(x$conditionalPowerAchieved[3, ]))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(x), NA)))
+ expect_output(print(x)$show())
+ invisible(capture.output(expect_error(summary(x), NA)))
+ expect_output(summary(x)$show())
+ xCodeBased <- eval(parse(text = getObjectRCode(x, stringWrapParagraphWidth = NULL)))
+ expect_equal(xCodeBased$eventsPerStage, x$eventsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$iterations, x$iterations, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectAtLeastOne, x$rejectAtLeastOne, tolerance = 1e-07)
+ expect_equal(xCodeBased$rejectedArmsPerStage, x$rejectedArmsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityStop, x$futilityStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$futilityPerStage, x$futilityPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$earlyStop, x$earlyStop, tolerance = 1e-07)
+ expect_equal(xCodeBased$successPerStage, x$successPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$selectedArms, x$selectedArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$numberOfActiveArms, x$numberOfActiveArms, tolerance = 1e-07)
+ expect_equal(xCodeBased$expectedNumberOfEvents, x$expectedNumberOfEvents, tolerance = 1e-07)
+ expect_equal(xCodeBased$singleNumberOfEventsPerStage, x$singleNumberOfEventsPerStage, tolerance = 1e-07)
+ expect_equal(xCodeBased$conditionalPowerAchieved, x$conditionalPowerAchieved, tolerance = 1e-07)
+ expect_type(names(x), "character")
+ df <- as.data.frame(x)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(x)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getSimulationMultiArmSurvival': comparison of base and multi-arm, inverse normal design", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- allocationRatioPlanned <- 1
- design <- getDesignInverseNormal(
- typeOfDesign = "WT", deltaWT = 0.05,
- futilityBounds = c(-0.5, 0.5), informationRates = c(0.2, 0.8, 1)
- )
-
- x <- getSimulationMultiArmSurvival(design,
- activeArms = 1, omegaMaxVector = 1 / seq(1, 1.8, 0.4), plannedEvents = c(20, 40, 60),
- conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
- maxNumberOfIterations = 100, directionUpper = FALSE, allocationRatioPlanned = allocationRatioPlanned, seed = 1234
- )
-
- y <- getSimulationSurvival(design,
- pi2 = 0.2, hazardRatio = 1 / seq(1, 1.8, 0.4),
- plannedEvents = c(20, 40, 60), maxNumberOfSubjects = 500,
- conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
- maxNumberOfIterations = 100, directionUpper = FALSE, allocation1 = 1, allocation2 = 1, seed = 1234
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(-0.02, 0.01, 0.06), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(-0.02, 0.02, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(0, -0.01, 0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(-0.06, -0.02, -0.03), tolerance = 1e-07, label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(0.08, 0.06, 0), tolerance = 1e-07, label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$overallEventsPerStage - x$eventsPerStage[, , 1], 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(1.2, -0.4, 1), tolerance = 1e-07, label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(1.7, -0.8, 1), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfEvents - x$expectedNumberOfEvents, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(6.9, -4.7, 3.6), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(-0.43, -0.73, -0.52), tolerance = 1e-07, label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(-0.13, -0.32, -0.04), tolerance = 1e-07, label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ allocationRatioPlanned <- 1
+ design <- getDesignInverseNormal(
+ typeOfDesign = "WT", deltaWT = 0.05,
+ futilityBounds = c(-0.5, 0.5), informationRates = c(0.2, 0.8, 1)
+ )
+
+ x <- getSimulationMultiArmSurvival(design,
+ activeArms = 1, omegaMaxVector = 1 / seq(1, 1.8, 0.4), plannedEvents = c(20, 40, 60),
+ conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
+ maxNumberOfIterations = 100, directionUpper = FALSE, allocationRatioPlanned = allocationRatioPlanned, seed = 1234
+ )
+
+ y <- getSimulationSurvival(design,
+ pi2 = 0.2, hazardRatio = 1 / seq(1, 1.8, 0.4),
+ plannedEvents = c(20, 40, 60), maxNumberOfSubjects = 500,
+ conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
+ maxNumberOfIterations = 100, directionUpper = FALSE, allocation1 = 1, allocation2 = 1, seed = 1234
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(-0.02, 0.01, 0.06), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(0, 0, 0), label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(-0.02, 0.02, 0.03), tolerance = 1e-07, label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(0, -0.01, 0.03), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(-0.06, -0.02, -0.03), tolerance = 1e-07, label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(0.08, 0.06, 0), tolerance = 1e-07, label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$overallEventsPerStage - x$eventsPerStage[, , 1], 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(1.2, -0.4, 1), tolerance = 1e-07, label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(1.7, -0.8, 1), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfEvents - x$expectedNumberOfEvents, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(6.9, -4.7, 3.6), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(-0.43, -0.73, -0.52), tolerance = 1e-07, label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(-0.13, -0.32, -0.04), tolerance = 1e-07, label = paste0(comp6[2, ]))
})
test_that("'getSimulationMultiArmSurvival': comparison of base and multi-arm, Fisher design", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- design <- getDesignFisher(alpha0Vec = c(0.6, 0.4), informationRates = c(0.5, 0.6, 1))
-
- x <- getSimulationMultiArmSurvival(design,
- activeArms = 1, omegaMaxVector = 1 / seq(1, 1.8, 0.4),
- plannedEvents = c(20, 40, 60),
- conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
- maxNumberOfIterations = 100, directionUpper = FALSE, seed = 1234
- )
-
- y <- getSimulationSurvival(design,
- pi2 = 0.2, hazardRatio = 1 / seq(1, 1.8, 0.4),
- plannedEvents = c(20, 40, 60), maxNumberOfSubjects = 500,
- conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
- maxNumberOfIterations = 100, directionUpper = FALSE, allocation1 = 1, allocation2 = 1, seed = 1234
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(-0.02, -0.01, 0.02), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(-0.02, 0.01, -0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(0, -0.03, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(0, 0.01, 0.02), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(-0.03, 0.01, -0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(0.05, 0.05, -0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$overallEventsPerStage - x$eventsPerStage[, , 1], 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(-0.6, 0.8, -0.3), tolerance = 1e-07, label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(-0.6, 0.8, -0.3), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfEvents - x$expectedNumberOfEvents, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(4.7, -5.3, 3.6), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(-0.27, -0.42, -0.29), tolerance = 1e-07, label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(-0.22, -0.54, -0.18), tolerance = 1e-07, label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
-
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ design <- getDesignFisher(alpha0Vec = c(0.6, 0.4), informationRates = c(0.5, 0.6, 1))
+
+ x <- getSimulationMultiArmSurvival(design,
+ activeArms = 1, omegaMaxVector = 1 / seq(1, 1.8, 0.4),
+ plannedEvents = c(20, 40, 60),
+ conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
+ maxNumberOfIterations = 100, directionUpper = FALSE, seed = 1234
+ )
+
+ y <- getSimulationSurvival(design,
+ pi2 = 0.2, hazardRatio = 1 / seq(1, 1.8, 0.4),
+ plannedEvents = c(20, 40, 60), maxNumberOfSubjects = 500,
+ conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
+ maxNumberOfIterations = 100, directionUpper = FALSE, allocation1 = 1, allocation2 = 1, seed = 1234
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(-0.02, -0.01, 0.02), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(-0.02, 0.01, -0.01), tolerance = 1e-07, label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(0, -0.03, 0.01), tolerance = 1e-07, label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(0, 0.01, 0.02), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(-0.03, 0.01, -0.01), tolerance = 1e-07, label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(0.05, 0.05, -0.01), tolerance = 1e-07, label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$overallEventsPerStage - x$eventsPerStage[, , 1], 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(-0.6, 0.8, -0.3), tolerance = 1e-07, label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(-0.6, 0.8, -0.3), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfEvents - x$expectedNumberOfEvents, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(4.7, -5.3, 3.6), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(-0.27, -0.42, -0.29), tolerance = 1e-07, label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(-0.22, -0.54, -0.18), tolerance = 1e-07, label = paste0(comp6[2, ]))
})
test_that("'getSimulationMultiArmSurvival': comparison of base and multi-arm, inverse normal design with user alpha spending", {
-
- .skipTestIfDisabled()
-
- # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
- # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
- # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
- # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
- # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
- # @refFS[Formula]{fs:simulationMultiArmSelections}
- # @refFS[Formula]{fs:multiarmRejectionRule}
- design <- getDesignInverseNormal(
- typeOfDesign = "asUser",
- userAlphaSpending = c(0, 0, 0.025), informationRates = c(0.2, 0.8, 1)
- )
-
- x <- getSimulationMultiArmSurvival(design,
- activeArms = 1, omegaMaxVector = 1 / seq(1, 1.8, 0.4), plannedEvents = c(20, 40, 60),
- conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
- maxNumberOfIterations = 100, directionUpper = FALSE, seed = 1234
- )
-
- y <- getSimulationSurvival(design,
- pi2 = 0.2, hazardRatio = 1 / seq(1, 1.8, 0.4),
- plannedEvents = c(20, 40, 60), maxNumberOfSubjects = 500,
- conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
- maxNumberOfIterations = 100, directionUpper = FALSE, allocation1 = 1, allocation2 = 1, seed = 1234
- )
-
- comp1 <- y$overallReject - x$rejectAtLeastOne
-
- ## Comparison of the results of numeric object 'comp1' with expected results
- expect_equal(comp1, c(-0.01, 0.02, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp1, collapse = ", "), ")"))
-
- comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
-
- ## Comparison of the results of matrixarray object 'comp2' with expected results
- expect_equal(comp2[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp2[1, ], collapse = ", "), ")"))
- expect_equal(comp2[2, ], c(0, 0, 0), label = paste0("c(", paste0(comp2[2, ], collapse = ", "), ")"))
- expect_equal(comp2[3, ], c(-0.01, 0.02, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(comp2[3, ], collapse = ", "), ")"))
-
- comp3 <- y$futilityPerStage - x$futilityPerStage
-
- ## Comparison of the results of matrixarray object 'comp3' with expected results
- expect_equal(comp3[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp3[1, ], collapse = ", "), ")"))
- expect_equal(comp3[2, ], c(0, 0, 0), label = paste0("c(", paste0(comp3[2, ], collapse = ", "), ")"))
-
- comp4 <- round(y$overallEventsPerStage - x$eventsPerStage[, , 1], 1)
-
- ## Comparison of the results of matrixarray object 'comp4' with expected results
- expect_equal(comp4[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp4[1, ], collapse = ", "), ")"))
- expect_equal(comp4[2, ], c(0, 0, 0), label = paste0("c(", paste0(comp4[2, ], collapse = ", "), ")"))
- expect_equal(comp4[3, ], c(-0.2, -3.5, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(comp4[3, ], collapse = ", "), ")"))
-
- comp5 <- round(y$expectedNumberOfEvents - x$expectedNumberOfEvents, 1)
-
- ## Comparison of the results of numeric object 'comp5' with expected results
- expect_equal(comp5, c(-0.2, -3.5, 0.6), tolerance = 1e-07, label = paste0("c(", paste0(comp5, collapse = ", "), ")"))
-
- comp6 <- x$earlyStop - y$earlyStop
-
- ## Comparison of the results of matrixarray object 'comp6' with expected results
- expect_equal(comp6[1, ], c(0, 0, 0), label = paste0("c(", paste0(comp6[1, ], collapse = ", "), ")"))
- expect_equal(comp6[2, ], c(0, 0, 0), label = paste0("c(", paste0(comp6[2, ], collapse = ", "), ")"))
+ .skipTestIfDisabled()
+
+ # @refFS[Sec.]{fs:sec:reproducibilityOfSimulationResults}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDesigns}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmDoseResponseRelationShips}
+ # @refFS[Sec.]{fs:sec:simulatingMultiArmSelections}
+ # @refFS[Tab.]{fs:tab:output:getSimulationMultiArmSurvival}
+ # @refFS[Formula]{fs:simulationMultiArmDoseResponse}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCholeskyTransformation}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalCorrMatrix}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalEvents}
+ # @refFS[Formula]{fs:simulationMultiArmSurvivalLogRanks}
+ # @refFS[Formula]{fs:simulationMultiArmSelections}
+ # @refFS[Formula]{fs:multiarmRejectionRule}
+ design <- getDesignInverseNormal(
+ typeOfDesign = "asUser",
+ userAlphaSpending = c(0, 0, 0.025), informationRates = c(0.2, 0.8, 1)
+ )
+
+ x <- getSimulationMultiArmSurvival(design,
+ activeArms = 1, omegaMaxVector = 1 / seq(1, 1.8, 0.4), plannedEvents = c(20, 40, 60),
+ conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
+ maxNumberOfIterations = 100, directionUpper = FALSE, seed = 1234
+ )
+
+ y <- getSimulationSurvival(design,
+ pi2 = 0.2, hazardRatio = 1 / seq(1, 1.8, 0.4),
+ plannedEvents = c(20, 40, 60), maxNumberOfSubjects = 500,
+ conditionalPower = 0.99, maxNumberOfEventsPerStage = c(NA, 100, 100), minNumberOfEventsPerStage = c(NA, 10, 10),
+ maxNumberOfIterations = 100, directionUpper = FALSE, allocation1 = 1, allocation2 = 1, seed = 1234
+ )
+
+ comp1 <- y$overallReject - x$rejectAtLeastOne
+
+ ## Comparison of the results of numeric object 'comp1' with expected results
+ expect_equal(comp1, c(-0.01, 0.02, 0.01), tolerance = 1e-07, label = paste0(comp1))
+
+ comp2 <- y$rejectPerStage - x$rejectedArmsPerStage[, , 1]
+
+ ## Comparison of the results of matrixarray object 'comp2' with expected results
+ expect_equal(comp2[1, ], c(0, 0, 0), label = paste0(comp2[1, ]))
+ expect_equal(comp2[2, ], c(0, 0, 0), label = paste0(comp2[2, ]))
+ expect_equal(comp2[3, ], c(-0.01, 0.02, 0.01), tolerance = 1e-07, label = paste0(comp2[3, ]))
+
+ comp3 <- y$futilityPerStage - x$futilityPerStage
+
+ ## Comparison of the results of matrixarray object 'comp3' with expected results
+ expect_equal(comp3[1, ], c(0, 0, 0), label = paste0(comp3[1, ]))
+ expect_equal(comp3[2, ], c(0, 0, 0), label = paste0(comp3[2, ]))
+
+ comp4 <- round(y$overallEventsPerStage - x$eventsPerStage[, , 1], 1)
+
+ ## Comparison of the results of matrixarray object 'comp4' with expected results
+ expect_equal(comp4[1, ], c(0, 0, 0), label = paste0(comp4[1, ]))
+ expect_equal(comp4[2, ], c(0, 0, 0), label = paste0(comp4[2, ]))
+ expect_equal(comp4[3, ], c(-0.2, -3.5, 0.6), tolerance = 1e-07, label = paste0(comp4[3, ]))
+
+ comp5 <- round(y$expectedNumberOfEvents - x$expectedNumberOfEvents, 1)
+
+ ## Comparison of the results of numeric object 'comp5' with expected results
+ expect_equal(comp5, c(-0.2, -3.5, 0.6), tolerance = 1e-07, label = paste0(comp5))
+
+ comp6 <- x$earlyStop - y$earlyStop
+
+ ## Comparison of the results of matrixarray object 'comp6' with expected results
+ expect_equal(comp6[1, ], c(0, 0, 0), label = paste0(comp6[1, ]))
+ expect_equal(comp6[2, ], c(0, 0, 0), label = paste0(comp6[2, ]))
})
-