diff --git a/DESCRIPTION b/DESCRIPTION
index ea7f2979..2492f3e1 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: rpact
Title: Confirmatory Adaptive Clinical Trial Design and Analysis
-Version: 4.0.0.9239
-Date: 2024-04-05
+Version: 4.0.0.9243
+Date: 2024-05-28
Authors@R: c(
person(
given = "Gernot",
diff --git a/NAMESPACE b/NAMESPACE
index 86e9bd59..0ec6664d 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -101,7 +101,6 @@ export(getSampleSizeCounts)
export(getSampleSizeMeans)
export(getSampleSizeRates)
export(getSampleSizeSurvival)
-export(getSimulationCounts)
export(getSimulationEnrichmentMeans)
export(getSimulationEnrichmentRates)
export(getSimulationEnrichmentSurvival)
diff --git a/NEWS.md b/NEWS.md
index 734ca698..74233464 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -3,13 +3,16 @@
## New features
+* All reference classes in the package have been replaced by [R6](https://cran.r-project.org/package=R6) classes. This change brings significant advantages, including improved performance, more flexible and cleaner object-oriented programming, and enhanced encapsulation of methods and properties. The transition to R6 classes allows for more efficient memory management and faster execution, making the package more robust and scalable. Additionally, R6 classes provide a more intuitive and user-friendly interface for developers, facilitating the creation and maintenance of complex data structures and workflows.
* Extension of the function `getPerformanceScore()` for sample size recalculation rules to the setting of binary endpoints according to [Bokelmann et al. (2024)](https://doi.org/10.1186/s12874-024-02150-4)
-* The new functions `getSimulationCounts()` can be used to perform power simulations and the assessment of test characteristics for clinical trials with negative binomial distributed count data.
+* The `getSimulationMultiArmMeans()`, `getSimulationMultiArmRates()`, and `getSimulationMultiArmSurvival()` functions now support an enhanced `selectArmsFunction` argument. Previously, only `effectVector` and `stage` were allowed as arguments. Now, users can optionally utilize additional arguments for more powerful custom function implementations, including `conditionalPower`, `conditionalCriticalValue`, `plannedSubjects/plannedEvents`, `allocationRatioPlanned`, `selectedArms`, `thetaH1` (for means and survival), `stDevH1` (for means), `overallEffects`, and for rates additionally: `piTreatmentsH1`, `piControlH1`, `overallRates`, and `overallRatesControl`.
+* Same as above for`getSimulationEnrichmentMeans()`, `getSimulationEnrichmentRates()`, and `getSimulationEnrichmentSurvival()`. Specifically, support for population selection with `selectPopulationsFunction` argument based on predictive/posterior probabilities added (see [#32](https://github.com/rpact-com/rpact/issues/32))
+
## Improvements, issues, and changes
-* All reference classes were replaced by [R6](https://cran.r-project.org/package=R6) classes due to better performance
-* Issue [#25](https://github.com/rpact-com/rpact/issues/25) fixed
+* Issues [#25](https://github.com/rpact-com/rpact/issues/25), [#35](https://github.com/rpact-com/rpact/issues/35), and [#36](https://github.com/rpact-com/rpact/issues/36) fixed
+* Minor improvements
# rpact 3.5.1
diff --git a/R/class_core_plot_settings.R b/R/class_core_plot_settings.R
index b23843b1..601903af 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: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7916 $
+## | Last changed: $Date: 2024-05-22 17:52:27 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -476,22 +476,22 @@ PlotSettings <- R6::R6Class("PlotSettings",
p <- p + ggplot2::theme(aspect.ratio = 1)
},
"1" = {
- p <- p + ggplot2::theme(legend.position = c(0.05, 1), legend.justification = c(0, 1))
+ p <- p + ggplot2::theme(legend.position = "inside", legend.position.inside = c(0.05, 1), legend.justification = c(0, 1))
},
"2" = {
- p <- p + ggplot2::theme(legend.position = c(0.05, 0.5), legend.justification = c(0, 0.5))
+ p <- p + ggplot2::theme(legend.position = "inside", legend.position.inside = c(0.05, 0.5), legend.justification = c(0, 0.5))
},
"3" = {
- p <- p + ggplot2::theme(legend.position = c(0.05, 0.05), legend.justification = c(0, 0))
+ p <- p + ggplot2::theme(legend.position = "inside", legend.position.inside = c(0.05, 0.05), legend.justification = c(0, 0))
},
"4" = {
- p <- p + ggplot2::theme(legend.position = c(0.95, 1), legend.justification = c(1, 1))
+ p <- p + ggplot2::theme(legend.position = "inside", legend.position.inside = c(0.95, 1), legend.justification = c(1, 1))
},
"5" = {
- p <- p + ggplot2::theme(legend.position = c(0.95, 0.5), legend.justification = c(1, 0.5))
+ p <- p + ggplot2::theme(legend.position = "inside", legend.position.inside = c(0.95, 0.5), legend.justification = c(1, 0.5))
},
"6" = {
- p <- p + ggplot2::theme(legend.position = c(0.95, 0.05), legend.justification = c(1, 0))
+ p <- p + ggplot2::theme(legend.position = "inside", legend.position.inside = c(0.95, 0.05), legend.justification = c(1, 0))
}
)
diff --git a/R/class_design_plan.R b/R/class_design_plan.R
index cfd24134..fbe3df6b 100644
--- a/R/class_design_plan.R
+++ b/R/class_design_plan.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7750 $
-## | Last changed: $Date: 2024-03-26 15:44:44 +0100 (Di, 26 Mrz 2024) $
+## | File version: $Revision: 7940 $
+## | Last changed: $Date: 2024-05-27 15:47:41 +0200 (Mo, 27 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -898,16 +898,23 @@ TrialDesignPlanSurvival <- R6::R6Class("TrialDesignPlanSurvival",
if (any(is.na(pi1))) {
pi1Temp <- self$pi1
}
+ } else {
+ if (self$.objectType == "sampleSize") {
+ pi1Temp <- C_PI_1_SAMPLE_SIZE_DEFAULT
+ } else {
+ pi1Temp <- C_PI_1_DEFAULT
+ }
}
accrualTimeTemp <- self$.getParameterValueIfUserDefinedOrDefault("accrualTime")
if (!is.null(accrualTimeTemp) && length(accrualTimeTemp) > 0 &&
- !all(is.na(accrualTimeTemp)) && accrualTimeTemp[1] != 0) {
- accrualTimeTemp <- c(0, accrualTimeTemp)
+ !all(is.na(accrualTimeTemp)) && accrualTimeTemp[1] != 0L) {
+ accrualTimeTemp <- c(0L, as.integer(accrualTimeTemp))
}
accrualIntensityTemp <- self$.getParameterValueIfUserDefinedOrDefault("accrualIntensity")
if (all(is.na(accrualIntensityTemp))) {
accrualIntensityTemp <- C_ACCRUAL_INTENSITY_DEFAULT
}
+
if (self$.objectType == "sampleSize") {
return(getSampleSizeSurvival(
design = self$.design,
@@ -917,7 +924,7 @@ TrialDesignPlanSurvival <- R6::R6Class("TrialDesignPlanSurvival",
pi2 = self$.getParameterValueIfUserDefinedOrDefault("pi2"),
allocationRatioPlanned = self$allocationRatioPlanned,
accountForObservationTimes = self$.getParameterValueIfUserDefinedOrDefault("accountForObservationTimes"),
- eventTime = self$eventTime,
+ eventTime = ifelse(all(is.na(self$eventTime)), C_EVENT_TIME_DEFAULT, self$eventTime),
accrualTime = accrualTimeTemp,
accrualIntensity = accrualIntensityTemp,
kappa = self$kappa,
@@ -944,7 +951,7 @@ TrialDesignPlanSurvival <- R6::R6Class("TrialDesignPlanSurvival",
pi2 = self$.getParameterValueIfUserDefinedOrDefault("pi2"),
directionUpper = directionUpperTemp,
allocationRatioPlanned = self$allocationRatioPlanned,
- eventTime = self$eventTime,
+ eventTime = ifelse(all(is.na(self$eventTime)), C_EVENT_TIME_DEFAULT, self$eventTime),
accrualTime = accrualTimeTemp,
accrualIntensity = accrualIntensityTemp,
kappa = self$kappa,
diff --git a/R/class_summary.R b/R/class_summary.R
index fbf9377d..1f2de7bb 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: 7763 $
-## | Last changed: $Date: 2024-03-28 14:35:29 +0100 (Do, 28 Mrz 2024) $
+## | File version: $Revision: 7946 $
+## | Last changed: $Date: 2024-05-28 12:08:57 +0200 (Di, 28 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -123,7 +123,7 @@ knit_print.SummaryFactory <- function(x, ...) {
paste0(utils::capture.output(x$object$.catMarkdownText()), collapse = "\n")
)
}
-
+
if (isTRUE(x[["markdown"]])) {
sep <- "\n-----\n\n"
result <- paste0(sep, result)
@@ -2190,11 +2190,14 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
))
}
if (!is.null(designPlan[["followUpTime"]]) &&
- designPlan$.getParameterType("followUpTime") == C_PARAM_USER_DEFINED &&
+ designPlan$.getParameterType("followUpTime") %in% c(C_PARAM_USER_DEFINED, C_PARAM_DEFAULT_VALUE) &&
length(designPlan$followUpTime) == 1 &&
!is.na(designPlan$followUpTime)) {
header <- .concatenateSummaryText(header, paste0(
- "follow-up time = ", designPlan$followUpTime[1]
+ "follow-up time = ", round(
+ designPlan$followUpTime[1],
+ as.integer(getOption("rpact.summary.digits", 3))
+ )
))
}
if (settings$survivalEnabled && !is.null(designPlan[["dropoutTime"]])) {
@@ -2378,20 +2381,24 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
.createSummary <- function(object, digits = NA_integer_, output = c("all", "title", "overview", "body")) {
output <- match.arg(output)
-
+
markdown <- attr(object, "markdown")
if (is.null(markdown) || length(markdown) == 0 || !is.logical(markdown)) {
markdown <- FALSE
}
-
+
if (inherits(object, "TrialDesignCharacteristics")) {
- return(.createSummaryDesignPlan(object, digits = digits, output = output,
- showStageLevels = TRUE, markdown = markdown))
+ return(.createSummaryDesignPlan(object,
+ digits = digits, output = output,
+ showStageLevels = TRUE, markdown = markdown
+ ))
}
if (.isTrialDesign(object) || .isTrialDesignPlan(object) || inherits(object, "SimulationResults")) {
- return(.createSummaryDesignPlan(object, digits = digits, output = output,
- showStageLevels = !.isTrialDesignPlan(object), markdown = markdown))
+ return(.createSummaryDesignPlan(object,
+ digits = digits, output = output,
+ showStageLevels = !.isTrialDesignPlan(object), markdown = markdown
+ ))
}
if (inherits(object, "AnalysisResults")) {
@@ -2405,9 +2412,9 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
stop(C_EXCEPTION_TYPE_RUNTIME_ISSUE, "function 'summary' not implemented yet for class ", .getClassName(object))
}
-.createSummaryPerformanceScore <- function(object, ...,
- digits = NA_integer_,
- output = c("all", "title", "overview", "body"),
+.createSummaryPerformanceScore <- function(object, ...,
+ digits = NA_integer_,
+ output = c("all", "title", "overview", "body"),
markdown = FALSE) {
.createSummaryDesignPlan(object$.simulationResults,
digits = digits, output = output,
@@ -2440,7 +2447,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
#'
#' @noRd
#'
-.createSummaryAnalysisResults <- function(object, ..., digits = NA_integer_,
+.createSummaryAnalysisResults <- function(object, ..., digits = NA_integer_,
output = c("all", "title", "overview", "body"), markdown = FALSE) {
output <- match.arg(output)
if (!inherits(object, "AnalysisResults")) {
@@ -2478,8 +2485,10 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
}
}
- summaryFactory <- SummaryFactory$new(object = object,
- intervalFormat = intervalFormat, output = output, markdown = markdown)
+ summaryFactory <- SummaryFactory$new(
+ object = object,
+ intervalFormat = intervalFormat, output = output, markdown = markdown
+ )
.addDesignInformationToSummary(design, object, summaryFactory, output = output)
@@ -2788,6 +2797,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
.assertIsInClosedInterval(digits, "digits", lower = -1, upper = 12, naAllowed = TRUE)
digitsSampleSize <- 1
+ digitsTime <- 2
if (digits > 0) {
digitsGeneral <- digits
digitsProbabilities <- NA_integer_
@@ -2807,12 +2817,14 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
digitsSampleSize <- digits
digitsGeneral <- digits
digitsProbabilities <- digits
+ digitsTime <- digits
}
return(list(
digits = digits,
digitsSampleSize = digitsSampleSize,
digitsGeneral = digitsGeneral,
- digitsProbabilities = digitsProbabilities
+ digitsProbabilities = digitsProbabilities,
+ digitsTime = digitsTime
))
}
@@ -2843,31 +2855,26 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
)
return(invisible(summaryFactory))
}
-
- informationRatesCaption <- ifelse(inherits(designPlan, "SimulationResults") ||
- inherits(designPlan, "AnalysisResults"), "Fixed weight", "Information")
-
- if (inherits(designPlan, "SimulationResults") || inherits(designPlan, "AnalysisResults")) {
- if (.isTrialDesignFisher(design)) {
- weights <- .getWeightsFisher(design)
- } else if (.isTrialDesignInverseNormal(design)) {
- weights <- .getWeightsInverseNormal(design)
- } else {
- weights <- design$informationRates
- }
- summaryFactory$addItem(informationRatesCaption, .getSummaryValuesInPercent(weights, FALSE))
+
+ informationRatesCaption <- "Planned information rate"
+ percentFormatEnabled <- TRUE
+ if (.isTrialDesignFisher(design)) {
+ weights <- .getWeightsFisher(design)
+ informationRatesCaption <- "Fixed weight"
+ percentFormatEnabled <- FALSE
+ } else if (.isTrialDesignInverseNormal(design)) {
+ weights <- .getWeightsInverseNormal(design)
+ informationRatesCaption <- "Fixed weight"
+ percentFormatEnabled <- FALSE
} else {
- summaryFactory$addItem(
- paste0(
- informationRatesCaption,
- ifelse(inherits(designPlan, "SimulationResults"), "", " rate")
- ),
- .getSummaryValuesInPercent(design$informationRates)
- )
+ weights <- design$informationRates
}
+ summaryFactory$addItem(informationRatesCaption,
+ .getSummaryValuesInPercent(weights, percentFormatEnabled = percentFormatEnabled))
if (design$.isDelayedResponseDesign()) {
- summaryFactory$addItem("Delayed information", .getSummaryValuesInPercent(design$delayedInformation, TRUE))
+ summaryFactory$addItem("Delayed information",
+ .getSummaryValuesInPercent(design$delayedInformation, percentFormatEnabled = TRUE))
}
return(invisible(summaryFactory))
@@ -2912,7 +2919,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
if (!is.null(powerObject)) {
summaryFactory$addParameter(powerObject,
parameterName = "power",
- parameterCaption = ifelse(design$kMax == 1, "Power", "Overall power"),
+ parameterCaption = ifelse(design$kMax == 1, "Power", "Cumulative power"),
roundDigits = digitsProbabilities, smoothedZeroFormat = TRUE
)
}
@@ -3003,6 +3010,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
digitsSampleSize <- digitSettings$digitsSampleSize
digitsGeneral <- digitSettings$digitsGeneral
digitsProbabilities <- digitSettings$digitsProbabilities
+ digitsTime <- digitSettings$digitsTime
outputSize <- getOption("rpact.summary.output.size", C_SUMMARY_OUTPUT_SIZE_DEFAULT)
@@ -3266,7 +3274,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
if (any(!is.na(designPlan[[parameterName]]))) {
summaryFactory$addParameter(designPlan,
parameterName = parameterName,
- parameterCaption = ifelse(design$kMax == 1, "Power", "Overall power"),
+ parameterCaption = ifelse(design$kMax == 1, "Power", "Cumulative power"),
roundDigits = digitsProbabilities, cumsumEnabled = TRUE, smoothedZeroFormat = TRUE
)
}
@@ -3299,7 +3307,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
summaryFactory$addParameter(designPlan,
parameterName = "calendarTime",
parameterCaption = "Calendar time",
- roundDigits = digitsGeneral
+ roundDigits = digitsTime
)
}
@@ -3308,7 +3316,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
summaryFactory$addParameter(designPlan,
parameterName = "expectedStudyDurationH1",
parameterCaption = "Expected study duration under H1",
- roundDigits = digitsGeneral,
+ roundDigits = digitsTime,
transpose = TRUE
)
}
@@ -3318,7 +3326,7 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
summaryFactory$addParameter(designPlan,
parameterName = "studyTime",
parameterCaption = "Study time",
- roundDigits = digitsGeneral
+ roundDigits = digitsTime
)
}
@@ -3435,14 +3443,17 @@ SummaryFactory <- R6::R6Class("SummaryFactory",
if (outputSize == "large") {
summaryFactory$addParameter(designPlan,
parameterName = "analysisTime",
- parameterCaption = "Analysis time", roundDigits = digitsGeneral
+ parameterCaption = "Analysis time",
+ roundDigits = digitsTime
)
}
summaryFactory$addParameter(designPlan,
parameterName = "studyDuration",
parameterCaption = "Expected study duration",
- roundDigits = digitsSampleSize, smoothedZeroFormat = TRUE, transpose = TRUE
+ roundDigits = digitsTime,
+ smoothedZeroFormat = TRUE,
+ transpose = TRUE
)
}
}
diff --git a/R/class_time.R b/R/class_time.R
index 8226ba10..d4f11c52 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: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7823 $
+## | Last changed: $Date: 2024-04-16 08:27:22 +0200 (Di, 16 Apr 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -847,7 +847,8 @@ PiecewiseSurvivalTime <- R6::R6Class("PiecewiseSurvivalTime",
hazardRatioCalculationEnabled <- TRUE
if (all(is.na(self$pi1))) {
- if (length(self$hazardRatio) > 0 && !all(is.na(self$hazardRatio))) {
+ if ((all(is.na(self$median1)) || all(is.na(self$median2))) &&
+ length(self$hazardRatio) > 0 && !all(is.na(self$hazardRatio))) {
self$.setParameterType("hazardRatio", C_PARAM_USER_DEFINED)
hazardRatioCalculationEnabled <- FALSE
}
@@ -931,7 +932,7 @@ PiecewiseSurvivalTime <- R6::R6Class("PiecewiseSurvivalTime",
)
}
- if (!any(is.na(self$lambda1)) && !is.na(self$lambda2)) {
+ if (!any(is.na(self$lambda1)) && !any(is.na(self$lambda2))) {
.logDebug(".init: calculate hazardRatio by lambda1 and lambda2")
self$hazardRatio <- (self$lambda1 / self$lambda2)^self$kappa
self$.setParameterType("hazardRatio", C_PARAM_GENERATED)
@@ -1163,10 +1164,12 @@ PiecewiseSurvivalTime <- R6::R6Class("PiecewiseSurvivalTime",
},
.initHazardRatio = function() {
.logDebug(".initHazardRatio")
-
+
if (!is.null(self$hazardRatio) && length(self$hazardRatio) > 0 && !all(is.na(self$hazardRatio))) {
if ((length(self$lambda1) == 1 && is.na(self$lambda1)) ||
- self$.getParameterType("lambda1") == C_PARAM_GENERATED) {
+ (self$.getParameterType("lambda1") == C_PARAM_GENERATED &&
+ (self$.getParameterType("median1") != C_PARAM_USER_DEFINED ||
+ self$.getParameterType("median2") != C_PARAM_USER_DEFINED))) {
self$.setParameterType("hazardRatio", C_PARAM_USER_DEFINED)
return(invisible())
}
diff --git a/R/f_analysis_base_survival.R b/R/f_analysis_base_survival.R
index 9b7d0e67..053c533f 100644
--- a/R/f_analysis_base_survival.R
+++ b/R/f_analysis_base_survival.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7879 $
+## | Last changed: $Date: 2024-05-13 10:19:43 +0200 (Mo, 13 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -1121,12 +1121,11 @@ NULL
directionUpperSign <- ifelse(directionUpper, 1, -1)
if (stageGroupSeq == 1) {
- finalConfidenceInterval <- exp(stderr * finalConfidenceIntervalGeneral)
- medianUnbiased <- exp(stderr * medianUnbiasedGeneral)
+ finalConfidenceInterval <- exp(stderr * finalConfidenceIntervalGeneral + log(thetaH0))
+ medianUnbiased <- exp(stderr * medianUnbiasedGeneral + log(thetaH0))
} else {
finalConfidenceInterval[1] <- exp(finalConfidenceIntervalGeneral[1] *
- (1 + y$overallAllocationRatios[finalStage]) /
- sqrt(y$overallAllocationRatios[finalStage]) +
+ (1 + y$overallAllocationRatios[finalStage]) / sqrt(y$overallAllocationRatios[finalStage]) +
directionUpperSign * log(thetaH0))
finalConfidenceInterval[2] <- exp(finalConfidenceIntervalGeneral[2] *
(1 + y$overallAllocationRatios[finalStage]) /
@@ -1247,8 +1246,8 @@ NULL
directionUpperSign <- ifelse(directionUpper, 1, -1)
if (stageInvNormal == 1) {
- finalConfidenceInterval <- exp(stderr * finalConfidenceIntervalGeneral)
- medianUnbiased <- exp(stderr * medianUnbiasedGeneral)
+ finalConfidenceInterval <- exp(stderr * finalConfidenceIntervalGeneral + log(thetaH0))
+ medianUnbiased <- exp(stderr * medianUnbiasedGeneral + log(thetaH0))
} else {
finalConfidenceInterval[1] <- exp(finalConfidenceIntervalGeneral[1] *
(1 + y$overallAllocationRatios[finalStage]) / sqrt(y$overallAllocationRatios[finalStage]) +
diff --git a/R/f_as251.R b/R/f_as251.R
index 73aa4ad4..6785fb81 100644
--- a/R/f_as251.R
+++ b/R/f_as251.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7947 $
+## | Last changed: $Date: 2024-05-28 14:25:47 +0200 (Di, 28 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -36,7 +36,7 @@
#'
#' @description
#' Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
#'
#' @details
#' This is a wrapper function for the original Fortran 77 code.
@@ -82,7 +82,7 @@ mvnprd <- function(..., A, B, BPD, EPS = 1e-06, INF, IERC = 1, HINC = 0) {
#'
#' @description
#' Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
#'
#' @details
#' For a multivariate normal vector with correlation structure
@@ -142,7 +142,7 @@ as251Normal <- function(lower, upper, sigma, ...,
#'
#' @description
#' Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
#'
#' @details
#' This is a wrapper function for the original Fortran 77 code.
@@ -201,7 +201,7 @@ mvstud <- function(..., NDF, A, B, BPD, D, EPS = 1e-06, INF, IERC = 1, HINC = 0)
#'
#' @description
#' Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+#' by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
#'
#' @details
#' For a multivariate normal vector with correlation structure
diff --git a/R/f_core_constants.R b/R/f_core_constants.R
index a4f8ba02..2ae17e61 100644
--- a/R/f_core_constants.R
+++ b/R/f_core_constants.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7946 $
+## | Last changed: $Date: 2024-05-28 12:08:57 +0200 (Di, 28 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -165,7 +165,7 @@ C_ALLOCATION_1_DEFAULT <- 1
C_ALLOCATION_2_DEFAULT <- 1
C_MAX_ITERATIONS_DEFAULT <- 10L
C_MAX_SIMULATION_ITERATIONS_DEFAULT <- 1000L
-C_ACCRUAL_TIME_DEFAULT <- c(0, 12)
+C_ACCRUAL_TIME_DEFAULT <- c(0L, 12L)
C_ACCRUAL_INTENSITY_DEFAULT <- 0.1
C_FOLLOW_UP_TIME_DEFAULT <- 6
@@ -1023,6 +1023,40 @@ C_PARAMETER_NAMES_PLOT_SETTINGS <- createDictionary("C_PARAMETER_NAMES_PLOT_SETT
"scalingFactor" = "Scaling factor"
))
+.getParameterNameTrialDesign <- function(parameterName, obj) {
+ if (inherits(obj, "TrialDesignSet") && length(obj$designs) > 0) {
+ obj <- obj$designs[[1]]
+ }
+
+ if (!inherits(obj, "TrialDesign")) {
+ return(parameterName)
+ }
+
+ 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")
+ }
+ }
+ 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")
+ }
+ return(parameterName)
+}
+
.getParameterCaption <- function(parameterName, obj = NULL, ..., tableOutputEnabled = FALSE) {
if (is.null(obj)) {
if (tableOutputEnabled) {
@@ -1031,35 +1065,16 @@ C_PARAMETER_NAMES_PLOT_SETTINGS <- createDictionary("C_PARAMETER_NAMES_PLOT_SETT
return(C_PARAMETER_NAMES[[parameterName]])
}
+
+ parameterName <- .getParameterNameTrialDesign(parameterName, obj)
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")
- }
- }
- 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")
- }
- }
+ parameterName <- .getParameterNameTrialDesign(parameterName, obj)
+
+ pluralExt <- ifelse(tableOutputEnabled, "", "s")
if (identical(parameterName, "futilityBounds") &&
inherits(obj, "TrialDesignSet") && length(obj$designs) > 1) {
@@ -1068,7 +1083,7 @@ C_PARAMETER_NAMES_PLOT_SETTINGS <- createDictionary("C_PARAMETER_NAMES_PLOT_SETT
bindingFutilityValues <- unique(c(bindingFutilityValues, design$bindingFutility))
}
if (length(bindingFutilityValues) > 1) {
- return("Futility bound")
+ return(paste0("Futility bound", pluralExt))
}
}
@@ -1105,7 +1120,6 @@ C_PARAMETER_NAMES_PLOT_SETTINGS <- createDictionary("C_PARAMETER_NAMES_PLOT_SETT
}
if (inherits(obj, "AnalysisResults")) {
- pluralExt <- ifelse(tableOutputEnabled, "", "s")
if (identical(parameterName, "repeatedConfidenceIntervalLowerBounds")) {
if (.isTrialDesignConditionalDunnett(obj$.design)) {
return(paste0("Overall confidence interval", pluralExt, " (lower)"))
diff --git a/R/f_core_utilities.R b/R/f_core_utilities.R
index bd9b4cb6..9c633145 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: 7750 $
-## | Last changed: $Date: 2024-03-26 15:44:44 +0100 (Di, 26 Mrz 2024) $
+## | File version: $Revision: 7940 $
+## | Last changed: $Date: 2024-05-27 15:47:41 +0200 (Mo, 27 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -166,17 +166,20 @@ NULL
if (length(arg) > 1) {
return(FALSE)
}
+
+ return(is.na(arg))
},
- error = function(e) {
+ warning = function(w) {
paramName <- deparse(substitute(arg))
.logWarn(
"Failed to execute '.isUndefinedArgument(%s)' ('%s' is an instance of class '%s'): %s",
- paramName, paramName, .getClassName(arg), e
+ paramName, paramName, .getClassName(arg), w$message
)
+ return(FALSE)
}
)
-
- return(is.na(arg))
+
+ return(FALSE)
}
.isDefinedArgument <- function(arg, argumentExistsValidationEnabled = TRUE) {
@@ -212,8 +215,10 @@ NULL
if (length(arg) > 1) {
return(TRUE)
}
+
+ return(!is.na(arg))
},
- error = function(e) {
+ warning = function(e) {
paramName <- deparse(substitute(arg))
.logWarn(
"Failed to execute '.isDefinedArgument(%s)' ('%s' is an instance of class '%s'): %s",
@@ -222,7 +227,7 @@ NULL
}
)
- return(!is.na(arg))
+ return(FALSE)
}
.getConcatenatedValues <- function(x, separator = ", ", mode = c("csv", "vector", "and", "or")) {
diff --git a/R/f_design_plan_survival.R b/R/f_design_plan_survival.R
index 4542d985..21dee798 100644
--- a/R/f_design_plan_survival.R
+++ b/R/f_design_plan_survival.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7902 $
+## | Last changed: $Date: 2024-05-21 08:44:08 +0200 (Di, 21 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -2067,6 +2067,13 @@ getSampleSizeSurvival <- function(design = NULL, ...,
accrualSetup$followUpTimeMustBeUserDefined) {
if (is.na(followUpTime)) {
if (accrualSetup$piecewiseAccrualEnabled && !accrualSetup$endOfAccrualIsUserDefined) {
+ if (length(accrualIntensity) + 1 < length(accrualTime)) {
+ stop(
+ C_EXCEPTION_TYPE_CONFLICTING_ARGUMENTS,
+ "length of 'accrualTime' (", length(accrualTime), ") must be greater ",
+ "than length of 'accrualIntensity' (", length(accrualIntensity), ") + 1"
+ )
+ }
stop(
C_EXCEPTION_TYPE_MISSING_ARGUMENT,
"'followUpTime', 'maxNumberOfSubjects' or end of accrual must be defined"
diff --git a/R/f_quality_assurance.R b/R/f_quality_assurance.R
index ce8df6b5..3baf6198 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: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -29,6 +29,19 @@ NULL
}
}
+.skipTestIfCppCompilerIsMissing <- function() {
+ if (.Platform$OS.type != "windows") {
+ return(invisible())
+ }
+
+ if (.isPackageInstalled("pkgbuild") &&
+ isTRUE(eval(parse(text = "pkgbuild::has_build_tools(debug = FALSE)")))) {
+ return(invisible())
+ }
+
+ testthat::skip("The test requires a C++ compiler")
+}
+
.skipTestIfNotX64 <- function() {
if (!.isMachine64Bit() && !.isMinimumRVersion4() && base::requireNamespace("testthat", quietly = TRUE)) {
testthat::skip("The test is only intended for R version 4.x or 64-bit computers (x86-64)")
diff --git a/R/f_simulation_base_count_data.R b/R/f_simulation_base_count_data.R
index 0e7a165a..ec8faf01 100644
--- a/R/f_simulation_base_count_data.R
+++ b/R/f_simulation_base_count_data.R
@@ -13,9 +13,9 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7747 $
-## | Last changed: $Date: 2024-03-25 17:58:00 +0100 (Mo, 25 Mrz 2024) $
-## | Last changed by: $Author: wassmer $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
+## | Last changed by: $Author: pahlke $
## |
.getInformationCountData <- function(lambda1,
@@ -126,15 +126,6 @@
#' \code{$show(showStatistics = FALSE)} or \code{$setShowStatistics(FALSE)} can be used to disable
#' the output of the aggregated simulated data.\cr
#'
-#' Example 1: \cr
-#' \code{simulationResults <- getSimulationRates(plannedSubjects = 40)} \cr
-#' \code{simulationResults$show(showStatistics = FALSE)}\cr
-#'
-#' Example 2: \cr
-#' \code{simulationResults <- getSimulationRates(plannedSubjects = 40)} \cr
-#' \code{simulationResults$setShowStatistics(FALSE)}\cr
-#' \code{simulationResults}\cr
-#'
#' \code{\link[=getData]{getData()}} can be used to get the aggregated simulated data from the
#' object as \code{\link[base]{data.frame}}. The data frame contains the following columns:
#' \enumerate{
@@ -166,14 +157,12 @@
#' @template return_object_simulation_results
#' @template how_to_get_help_for_generics
#'
-#' @template examples_get_simulation_count_data
-#'
-#' @export
+#' @keywords internal
#'
getSimulationCounts <- function(design = NULL,
...,
plannedCalendarTime,
- maxNumberOfSubjects = NA_real_,
+ plannedMaxSubjects = NA_real_,
lambda1 = NA_real_,
lambda2 = NA_real_,
lambda = NA_real_,
@@ -225,7 +214,7 @@ getSimulationCounts <- function(design = NULL,
sided <- design$sided
sampleSizeEnabled <- FALSE
- allocationRatioPlanned <- .assertIsValidAllocationRatioPlannedSampleSize(allocationRatioPlanned, maxNumberOfSubjects)
+ allocationRatioPlanned <- .assertIsValidAllocationRatioPlannedSampleSize(allocationRatioPlanned, plannedMaxSubjects)
.assertIsValidEffectCountData(
sampleSizeEnabled, sided, lambda1, lambda2, lambda, theta,
thetaH0, overdispersion
@@ -242,7 +231,7 @@ getSimulationCounts <- function(design = NULL,
followUpTime = followUpTime,
accrualTime = accrualTime,
accrualIntensity = accrualIntensity,
- maxNumberOfSubjects = maxNumberOfSubjects
+ maxNumberOfSubjects = plannedMaxSubjects
)
.assertAreValidCalendarTimes(plannedCalendarTime, kMax)
if (any(is.na(accrualTime))) {
@@ -266,7 +255,7 @@ getSimulationCounts <- function(design = NULL,
}
.setValueAndParameterType(simulationResults, "plannedCalendarTime", plannedCalendarTime, NA_real_)
- .setValueAndParameterType(simulationResults, "maxNumberOfSubjects", maxNumberOfSubjects, NA_real_, notApplicableIfNA = TRUE)
+ .setValueAndParameterType(simulationResults, "plannedMaxSubjects", plannedMaxSubjects, NA_real_, notApplicableIfNA = TRUE)
.setValueAndParameterType(simulationResults, "lambda1", lambda1, NA_real_, notApplicableIfNA = TRUE)
.setValueAndParameterType(simulationResults, "lambda2", lambda2, NA_real_, notApplicableIfNA = TRUE)
.setValueAndParameterType(simulationResults, "lambda", lambda, NA_real_, notApplicableIfNA = TRUE)
@@ -350,7 +339,7 @@ getSimulationCounts <- function(design = NULL,
n2 <- length(recruit2)
nTotal <- n1 + n2
} else {
- n2 <- maxNumberOfSubjects / (1 + allocationRatioPlanned)
+ n2 <- plannedMaxSubjects / (1 + allocationRatioPlanned)
n1 <- allocationRatioPlanned * n2
nTotal <- n1 + n2
recruit1 <- seq(0, accrualTime, length.out = n1)
diff --git a/R/f_simulation_calc_subjects_function.R b/R/f_simulation_calc_subjects_function.R
index c5a496d3..c0b07077 100644
--- a/R/f_simulation_calc_subjects_function.R
+++ b/R/f_simulation_calc_subjects_function.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7019 $
-## | Last changed: $Date: 2023-05-31 07:23:47 +0200 (Mi, 31 Mai 2023) $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -397,6 +397,12 @@ C_SIMULATION_CALC_SUBJECTS_FUNCTION_ARGUMENTS[[C_SIMULATION_CALC_SUBJECTS_FUNCTI
if (.isCppCode(calcFunction)) {
tryCatch(
{
+ if (.isPackageInstalled("pkgbuild") &&
+ !isTRUE(eval(parse(text = "pkgbuild::has_build_tools(debug = FALSE)")))) {
+ stop("no C++ compiler found", ifelse(.Platform$OS.type == "windows",
+ " (install RTools to solve the issue)", ""))
+ }
+
survivalEnabled <- inherits(simulationResults, "SimulationResultsSurvival")
expectedFunctionName <- ifelse(survivalEnabled,
"calcEventsFunctionCppTemp", "calcSubjectsFunctionCppTemp"
diff --git a/R/f_simulation_enrichment.R b/R/f_simulation_enrichment.R
index 8598f91f..d6331c3b 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: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -69,9 +69,13 @@ NULL
return(selectedVector)
}
-
-.selectPopulations <- function(stage, effectVector, typeOfSelection,
- epsilonValue, rValue, threshold, selectPopulationsFunction) {
+.selectPopulations <- function(typeOfSelection,
+ epsilonValue,
+ rValue,
+ threshold,
+ selectPopulationsFunction,
+ selectPopulationsFunctionArgs) {
+ effectVector <- selectPopulationsFunctionArgs$effectVector
gMax <- length(effectVector)
if (typeOfSelection != "userDefined") {
@@ -92,26 +96,20 @@ NULL
selectedPopulations[effectVector <= threshold] <- FALSE
} else {
functionArgumentNames <- .getFunctionArgumentNames(selectPopulationsFunction, ignoreThreeDots = TRUE)
- if (length(functionArgumentNames) == 1) {
- .assertIsValidFunction(
- fun = selectPopulationsFunction,
- funArgName = "selectPopulationsFunction",
- expectedArguments = c("effectVector"), validateThreeDots = FALSE
- )
- selectedPopulations <- selectPopulationsFunction(effectVector)
- } else {
- .assertIsValidFunction(
- fun = selectPopulationsFunction,
- funArgName = "selectPopulationsFunction",
- expectedArguments = c("effectVector", "stage"), validateThreeDots = FALSE
- )
- selectedPopulations <- selectPopulationsFunction(effectVector = effectVector, stage = stage)
- }
+ .assertIsValidFunction(
+ fun = selectPopulationsFunction,
+ funArgName = "selectPopulationsFunction",
+ expectedArguments = names(selectPopulationsFunctionArgs),
+ validateThreeDots = FALSE
+ )
+ selectedPopulations <- do.call(what = selectPopulationsFunction,
+ args = selectPopulationsFunctionArgs[functionArgumentNames])
selectedPopulations[is.na(effectVector)] <- FALSE
msg <- paste0(
C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
- "'selectPopulationsFunction' returned an illegal or undefined result (", .arrayToString(selectedPopulations), "); "
+ "'selectPopulationsFunction' returned an illegal or undefined result (",
+ .arrayToString(selectedPopulations), "); "
)
if (length(selectedPopulations) != gMax) {
stop(msg, "the output must be a logical vector of length 'gMax' (", gMax, ")")
@@ -727,7 +725,5 @@ NULL
.setValueAndParameterType(simulationResults, "successCriterion", successCriterion, C_SUCCESS_CRITERION_DEFAULT)
.setValueAndParameterType(simulationResults, "effectMeasure", effectMeasure, C_EFFECT_MEASURE_DEFAULT)
- warning("Simulation of enrichment designs is experimental and hence not fully validated (see www.rpact.com/experimental)", call. = FALSE)
-
return(simulationResults)
}
diff --git a/R/f_simulation_enrichment_means.R b/R/f_simulation_enrichment_means.R
index 8f3d2b4f..19cd0542 100644
--- a/R/f_simulation_enrichment_means.R
+++ b/R/f_simulation_enrichment_means.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7383 $
-## | Last changed: $Date: 2023-11-02 15:18:21 +0100 (Do, 02 Nov 2023) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -273,18 +273,35 @@ NULL
}
if (adaptations[k]) {
+ selectPopulationsFunctionArgs <- list(
+ effectVector = NULL,
+ stage = k,
+ conditionalPower = conditionalPower,
+ conditionalCriticalValue = conditionalCriticalValue,
+ plannedSubjects = plannedSubjects,
+ allocationRatioPlanned = allocationRatioPlanned,
+ selectedPopulations = selectedPopulations,
+ thetaH1 = thetaH1,
+ stDevH1 = stDevH1,
+ overallEffects = overallEffects
+ )
if (effectMeasure == "testStatistic") {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] & .selectPopulations(
- k, overallTestStatistics[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- overallTestStatistics[, k]
} else if (effectMeasure == "effectEstimate") {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] & .selectPopulations(
- k, overallEffects[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- overallEffects[, k]
}
+ args <- list(
+ typeOfSelection = typeOfSelection,
+ epsilonValue = epsilonValue,
+ rValue = rValue,
+ threshold = threshold,
+ selectPopulationsFunction = selectPopulationsFunction,
+ selectPopulationsFunctionArgs = selectPopulationsFunctionArgs
+ )
+
+ selectedPopulations[, k + 1] <- (selectedPopulations[, k] & do.call(.selectPopulations, args))
+
newSubjects <- calcSubjectsFunction(
stage = k + 1, # to be consistent with non-enrichment situation, cf. line 36
conditionalPower = conditionalPower,
diff --git a/R/f_simulation_enrichment_rates.R b/R/f_simulation_enrichment_rates.R
index 967dd97a..3c51f113 100644
--- a/R/f_simulation_enrichment_rates.R
+++ b/R/f_simulation_enrichment_rates.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -169,7 +169,6 @@ NULL
round(subjectsPerStage[selsubs, k] / (1 + const)), piControls[selsubs]
)
-
if (gMax == 1) {
rm <- (simEventsControl[1, k] + simEventsTreatment[1, k]) / subjectsPerStage[1, k]
if (rm <= 0 || rm >= 1) {
@@ -195,6 +194,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[1, 1:k]) * const / (1 + const)^2)
}
} else if (gMax == 2) {
+
# Population S1
rm <- (simEventsControl[1, k] + simEventsTreatment[1, k]) / subjectsPerStage[1, k]
if (!is.na(rm)) {
@@ -223,6 +223,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[1, 1:k]) * const / (1 + const)^2)
}
}
+
# Full population
if (stratifiedAnalysis) {
rm <- (simEventsControl[1:2, k] + simEventsTreatment[1:2, k]) / subjectsPerStage[1:2, k]
@@ -271,6 +272,7 @@ NULL
}
}
} else if (gMax == 3) {
+
# Population S1
if (stratifiedAnalysis) {
rm <- (simEventsControl[c(1, 3), k] + simEventsTreatment[c(1, 3), k]) / subjectsPerStage[c(1, 3), k]
@@ -318,6 +320,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[c(1, 3), 1:k], na.rm = TRUE) * const / (1 + const)^2)
}
}
+
# Population S2
if (stratifiedAnalysis) {
rm <- (simEventsControl[c(2, 3), k] + simEventsTreatment[c(2, 3), k]) / subjectsPerStage[c(2, 3), k]
@@ -365,6 +368,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[c(2, 3), 1:k], na.rm = TRUE) * const / (1 + const)^2)
}
}
+
# Full population
if (stratifiedAnalysis) {
rm <- (simEventsControl[1:4, k] + simEventsTreatment[1:4, k]) / subjectsPerStage[1:4, k]
@@ -413,6 +417,7 @@ NULL
}
}
} else if (gMax == 4) {
+
# Population S1
if (stratifiedAnalysis) {
rm <- (simEventsControl[c(1, 4, 5, 7), k] + simEventsTreatment[c(1, 4, 5, 7), k]) / subjectsPerStage[c(1, 4, 5, 7), k]
@@ -460,6 +465,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[c(1, 4, 5, 7), 1:k], na.rm = TRUE) * const / (1 + const)^2)
}
}
+
# Population S2
if (stratifiedAnalysis) {
rm <- (simEventsControl[c(2, 4, 6, 7), k] + simEventsTreatment[c(2, 4, 6, 7), k]) / subjectsPerStage[c(2, 4, 6, 7), k]
@@ -507,6 +513,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[c(2, 4, 6, 7), 1:k], na.rm = TRUE) * const / (1 + const)^2)
}
}
+
# Population S3
if (stratifiedAnalysis) {
rm <- (simEventsControl[c(3, 5, 6, 7), k] + simEventsTreatment[c(3, 5, 6, 7), k]) / subjectsPerStage[c(3, 5, 6, 7), k]
@@ -554,6 +561,7 @@ NULL
sqrt(rm * (1 - rm)) * sqrt(sum(subjectsPerStage[c(3, 5, 6, 7), 1:k], na.rm = TRUE) * const / (1 + const)^2)
}
}
+
# Full population
if (stratifiedAnalysis) {
rm <- (simEventsControl[1:8, k] + simEventsTreatment[1:8, k]) / subjectsPerStage[1:8, k]
@@ -633,20 +641,37 @@ NULL
}
if (adaptations[k]) {
+ selectPopulationsFunctionArgs <- list(
+ effectVector = NULL,
+ stage = k,
+ directionUpper = directionUpper,
+ conditionalPower = conditionalPower,
+ conditionalCriticalValue = conditionalCriticalValue,
+ plannedSubjects = plannedSubjects,
+ allocationRatioPlanned = allocationRatioPlanned,
+ selectedPopulations = selectedPopulations,
+ piTreatmentH1 = piTreatmentH1,
+ piControlH1 = piControlH1,
+ overallRatesTreatment = overallRatesTreatment,
+ overallRatesControl = overallRatesControl
+ )
if (effectMeasure == "testStatistic") {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] &
- .selectPopulations(
- k, overallTestStatistics[, k] + runif(gMax, -1e-05, 1e-05),
- typeOfSelection, epsilonValue, rValue, threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- overallTestStatistics[, k] + runif(gMax, -1e-05, 1e-05)
} else if (effectMeasure == "effectEstimate") {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] &
- .selectPopulations(
- k, overallEffectSizes[, k] + runif(gMax, -1e-05, 1e-05),
- typeOfSelection, epsilonValue, rValue, threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- overallEffectSizes[, k] + runif(gMax, -1e-05, 1e-05)
}
+ args <- list(
+ typeOfSelection = typeOfSelection,
+ epsilonValue = epsilonValue,
+ rValue = rValue,
+ threshold = threshold,
+ selectPopulationsFunction = selectPopulationsFunction,
+ selectPopulationsFunctionArgs = selectPopulationsFunctionArgs
+ )
+
+ selectedPopulations[, k + 1] <- (selectedPopulations[, k] & do.call(.selectPopulations, args))
+
newSubjects <- calcSubjectsFunction(
stage = k + 1, # to be consistent with non-enrichment situation, cf. line 40
directionUpper = directionUpper,
diff --git a/R/f_simulation_enrichment_survival.R b/R/f_simulation_enrichment_survival.R
index 657cba7d..e14fb401 100644
--- a/R/f_simulation_enrichment_survival.R
+++ b/R/f_simulation_enrichment_survival.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -278,25 +278,42 @@ NULL
}
if (adaptations[k]) {
+ selectPopulationsFunctionArgs <- list(
+ effectVector = NULL,
+ stage = k,
+ directionUpper = directionUpper,
+ conditionalPower = conditionalPower,
+ conditionalCriticalValue = conditionalCriticalValue,
+ plannedEvents = plannedEvents,
+ allocationRatioPlanned = allocationRatioPlanned,
+ selectedPopulations = selectedPopulations,
+ thetaH1 = thetaH1,
+ overallEffects = overallEffects
+ )
+
+ args <- list(
+ typeOfSelection = typeOfSelection,
+ epsilonValue = epsilonValue,
+ rValue = rValue,
+ threshold = threshold,
+ selectPopulationsFunction = selectPopulationsFunction
+ )
+
if (effectMeasure == "testStatistic") {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] & .selectPopulations(
- k, overallTestStatistics[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- overallTestStatistics[, k]
} else if (effectMeasure == "effectEstimate") {
if (directionUpper) {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] & .selectPopulations(
- k, overallEffects[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- overallEffects[, k]
} else {
- selectedPopulations[, k + 1] <- (selectedPopulations[, k] & .selectPopulations(
- k, 1 / overallEffects[, k],
- typeOfSelection, epsilonValue, rValue, 1 / threshold, selectPopulationsFunction
- ))
+ selectPopulationsFunctionArgs$effectVector <- 1 / overallEffects[, k]
+ args$threshold <- 1 / threshold
}
}
+ args$selectPopulationsFunctionArgs <- selectPopulationsFunctionArgs
+
+ selectedPopulations[, k + 1] <- (selectedPopulations[, k] & do.call(.selectPopulations, args))
+
newEvents <- calcEventsFunction(
stage = k + 1, # to be consistent with non-enrichment situation, cf. line 38
directionUpper = directionUpper,
diff --git a/R/f_simulation_multiarm.R b/R/f_simulation_multiarm.R
index 6a47e898..43d78beb 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: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -29,8 +29,14 @@ NULL
return(indices)
}
-.selectTreatmentArms <- function(stage, effectVector, typeOfSelection,
- epsilonValue, rValue, threshold, selectArmsFunction, survival = FALSE) {
+.selectTreatmentArms <- function(typeOfSelection,
+ epsilonValue,
+ rValue,
+ threshold,
+ selectArmsFunction,
+ selectArmsFunctionArgs,
+ survival = FALSE) {
+ effectVector <- selectArmsFunctionArgs$effectVector
gMax <- length(effectVector)
if (typeOfSelection != "userDefined") {
@@ -51,21 +57,13 @@ NULL
selectedArms[effectVector <= threshold] <- FALSE
} else {
functionArgumentNames <- .getFunctionArgumentNames(selectArmsFunction, ignoreThreeDots = TRUE)
- if (length(functionArgumentNames) == 1) {
- .assertIsValidFunction(
- fun = selectArmsFunction,
- funArgName = "selectArmsFunction",
- expectedArguments = c("effectVector"), validateThreeDots = FALSE
- )
- selectedArms <- selectArmsFunction(effectVector)
- } else {
- .assertIsValidFunction(
- fun = selectArmsFunction,
- funArgName = "selectArmsFunction",
- expectedArguments = c("effectVector", "stage"), validateThreeDots = FALSE
- )
- selectedArms <- selectArmsFunction(effectVector = effectVector, stage = stage)
- }
+ .assertIsValidFunction(
+ fun = selectArmsFunction,
+ funArgName = "selectArmsFunction",
+ expectedArguments = names(selectArmsFunctionArgs),
+ validateThreeDots = FALSE
+ )
+ selectedArms <- do.call(what = selectArmsFunction, args = selectArmsFunctionArgs[functionArgumentNames])
msg <- paste0(
C_EXCEPTION_TYPE_ILLEGAL_ARGUMENT,
diff --git a/R/f_simulation_multiarm_means.R b/R/f_simulation_multiarm_means.R
index 7a687365..5576ab16 100644
--- a/R/f_simulation_multiarm_means.R
+++ b/R/f_simulation_multiarm_means.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7383 $
-## | Last changed: $Date: 2023-11-02 15:18:21 +0100 (Do, 02 Nov 2023) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -157,18 +157,37 @@ NULL
}
if (adaptations[k]) {
+ selectArmsFunctionArgs <- list(
+ effectVector = NULL,
+ stage = k,
+ conditionalPower = conditionalPower,
+ conditionalCriticalValue = conditionalCriticalValue,
+ plannedSubjects = plannedSubjects,
+ allocationRatioPlanned = allocationRatioPlanned,
+ selectedArms = selectedArms,
+ thetaH1 = thetaH1,
+ stDevH1 = stDevH1,
+ overallEffects = overallEffects
+ )
+
if (effectMeasure == "testStatistic") {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(
- k, overallTestStatistics[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectArmsFunction
- ))
+ selectArmsFunctionArgs$effectVector <- overallTestStatistics[, k]
} else if (effectMeasure == "effectEstimate") {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(
- k, overallEffects[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectArmsFunction
- ))
+ selectArmsFunctionArgs$effectVector <- overallEffects[, k]
}
+ args <- list(
+ typeOfSelection = typeOfSelection,
+ epsilonValue = epsilonValue,
+ rValue = rValue,
+ threshold = threshold,
+ selectArmsFunction = selectArmsFunction,
+ selectArmsFunctionArgs = selectArmsFunctionArgs,
+ survival = FALSE
+ )
+
+ selectedArms[, k + 1] <- (selectedArms[, k] & do.call(.selectTreatmentArms, args))
+
newSubjects <- calcSubjectsFunction(
stage = k + 1, # to be consistent with non-multiarm situation, cf. line 37
conditionalPower = conditionalPower,
@@ -416,7 +435,7 @@ getSimulationMultiArmMeans <- function(design = NULL, ...,
simulatedNumberOfActiveArms <- matrix(0, nrow = kMax, ncol = cols)
simulatedSubjectsPerStage <- array(0, dim = c(kMax, cols, gMax + 1))
simulatedSuccessStopping <- matrix(0, nrow = kMax, ncol = cols)
- simulatedFutilityStopping <- matrix(0, cols * (kMax - 1), nrow = kMax - 1, ncol = cols)
+ simulatedFutilityStopping <- matrix(0, nrow = kMax - 1, ncol = cols)
simulatedConditionalPower <- matrix(0, nrow = kMax, ncol = cols)
simulatedRejectAtLeastOne <- rep(0, cols)
expectedNumberOfSubjects <- rep(0, cols)
@@ -434,7 +453,6 @@ getSimulationMultiArmMeans <- function(design = NULL, ...,
dataNumberOfSubjects <- rep(NA_real_, len)
dataNumberOfCumulatedSubjects <- rep(NA_real_, len)
dataRejectPerStage <- rep(NA, len)
- dataFutilityStop <- rep(NA_real_, len)
dataSuccessStop <- rep(NA, len)
dataFutilityStop <- rep(NA, len)
dataTestStatistics <- rep(NA_real_, len)
diff --git a/R/f_simulation_multiarm_rates.R b/R/f_simulation_multiarm_rates.R
index f231aa8b..f36fe909 100644
--- a/R/f_simulation_multiarm_rates.R
+++ b/R/f_simulation_multiarm_rates.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7383 $
-## | Last changed: $Date: 2023-11-02 15:18:21 +0100 (Do, 02 Nov 2023) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -190,18 +190,39 @@ NULL
}
if (adaptations[k]) {
+ selectArmsFunctionArgs <- list(
+ effectVector = NULL,
+ stage = k,
+ directionUpper = directionUpper,
+ conditionalPower = conditionalPower,
+ conditionalCriticalValue = conditionalCriticalValue,
+ plannedSubjects = plannedSubjects,
+ allocationRatioPlanned = allocationRatioPlanned,
+ selectedArms = selectedArms,
+ piTreatmentsH1 = piTreatmentsH1,
+ piControlH1 = piControlH1,
+ overallRates = overallRates,
+ overallRatesControl = overallRatesControl
+ )
+
if (effectMeasure == "testStatistic") {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(
- k, overallTestStatistics[, k] + runif(gMax, -1e-05, 1e-05),
- typeOfSelection, epsilonValue, rValue, threshold, selectArmsFunction
- ))
+ selectArmsFunctionArgs$effectVector <- overallTestStatistics[, k] + runif(gMax, -1e-05, 1e-05)
} else if (effectMeasure == "effectEstimate") {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(
- k, overallEffectSizes[, k] + runif(gMax, -1e-05, 1e-05),
- typeOfSelection, epsilonValue, rValue, threshold, selectArmsFunction
- ))
+ selectArmsFunctionArgs$effectVector <- overallEffectSizes[, k] + runif(gMax, -1e-05, 1e-05)
}
+ args <- list(
+ typeOfSelection = typeOfSelection,
+ epsilonValue = epsilonValue,
+ rValue = rValue,
+ threshold = threshold,
+ selectArmsFunction = selectArmsFunction,
+ selectArmsFunctionArgs = selectArmsFunctionArgs,
+ survival = FALSE
+ )
+
+ selectedArms[, k + 1] <- (selectedArms[, k] & do.call(.selectTreatmentArms, args))
+
newSubjects <- calcSubjectsFunction(
stage = k + 1, # to be consistent with non-multiarm situation, cf. line 39
directionUpper = directionUpper,
diff --git a/R/f_simulation_multiarm_survival.R b/R/f_simulation_multiarm_survival.R
index 08a32ef2..f4aebea6 100644
--- a/R/f_simulation_multiarm_survival.R
+++ b/R/f_simulation_multiarm_survival.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7910 $
+## | Last changed: $Date: 2024-05-22 10:02:23 +0200 (Mi, 22 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -211,25 +211,44 @@ NULL
}
if (adaptations[k]) {
+ selectArmsFunctionArgs <- list(
+ effectVector = NULL,
+ stage = k,
+ directionUpper = directionUpper,
+ conditionalPower = conditionalPower,
+ conditionalCriticalValue = conditionalCriticalValue,
+ plannedEvents = plannedEvents,
+ allocationRatioPlanned = allocationRatioPlanned,
+ selectedArms = selectedArms,
+ thetaH1 = thetaH1,
+ overallEffects = overallEffects
+ )
+
+ args <- list(
+ typeOfSelection = typeOfSelection,
+ epsilonValue = epsilonValue,
+ rValue = rValue,
+ threshold = threshold,
+ selectArmsFunction = selectArmsFunction,
+ selectArmsFunctionArgs = NULL,
+ survival = TRUE
+ )
+
if (effectMeasure == "testStatistic") {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(k, overallTestStatistics[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectArmsFunction,
- survival = TRUE
- ))
+ selectArmsFunctionArgs$effectVector <- overallTestStatistics[, k]
} else if (effectMeasure == "effectEstimate") {
if (directionUpper) {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(k, overallEffects[, k],
- typeOfSelection, epsilonValue, rValue, threshold, selectArmsFunction,
- survival = TRUE
- ))
+ selectArmsFunctionArgs$effectVector <- overallEffects[, k]
} else {
- selectedArms[, k + 1] <- (selectedArms[, k] & .selectTreatmentArms(k, 1 / overallEffects[, k],
- typeOfSelection, epsilonValue, rValue, 1 / threshold, selectArmsFunction,
- survival = TRUE
- ))
+ selectArmsFunctionArgs$effectVector <- 1 / overallEffects[, k]
+ args$threshold <- 1 / threshold
}
}
+ args$selectArmsFunctionArgs <- selectArmsFunctionArgs
+
+ selectedArms[, k + 1] <- (selectedArms[, k] & do.call(.selectTreatmentArms, args))
+
newEvents <- calcEventsFunction(
stage = k + 1, # to be consistent with non-multiarm situation, cf. line 38
directionUpper = directionUpper,
diff --git a/R/f_simulation_performance_score.R b/R/f_simulation_performance_score.R
index 0c5072d6..aac2aedb 100644
--- a/R/f_simulation_performance_score.R
+++ b/R/f_simulation_performance_score.R
@@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7947 $
+## | Last changed: $Date: 2024-05-28 14:25:47 +0200 (Di, 28 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -24,8 +24,8 @@
#'
#' @description
#' Calculates the conditional performance score, its sub-scores and components according to
-#' [Herrmann et al. (2020)](https://doi.org/10.1002/sim.8534) and
-#' [Bokelmann et al. (2024)](https://doi.org/10.1186/s12874-024-02150-4) for a given
+#' (Herrmann et al. (2020), \doi{10.1002/sim.8534}) and
+#' (Bokelmann et al. (2024), \doi{10.1186/s12874-024-02150-4}) for a given
#' simulation result from a two-stage design with continuous or binary endpoint.
#' Larger (sub-)score and component values refer to a better performance.
#'
@@ -178,10 +178,12 @@ getPerformanceScore <- function(simulationResult) {
performanceScore$.setParameterType(paramName, C_PARAM_GENERATED)
}
- warning("The performance score function is experimental and hence not fully validated ",
- "(see www.rpact.com/experimental)",
- call. = FALSE
- )
+ if (inherits(simulationResult, "SimulationResultsRates")) {
+ warning("The performance score function is experimental and hence not fully validated ",
+ "(see www.rpact.com/experimental)",
+ call. = FALSE
+ )
+ }
return(performanceScore)
}
diff --git a/R/parameter_descriptions.R b/R/parameter_descriptions.R
index 564fb012..61672665 100644
--- a/R/parameter_descriptions.R
+++ b/R/parameter_descriptions.R
@@ -13,9 +13,9 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
-## | File version: $Revision: 7747 $
-## | Last changed: $Date: 2024-03-25 17:58:00 +0100 (Mo, 25 Mrz 2024) $
-## | Last changed by: $Author: wassmer $
+## | File version: $Revision: 7941 $
+## | Last changed: $Date: 2024-05-28 08:44:36 +0200 (Di, 28 Mai 2024) $
+## | Last changed by: $Author: pahlke $
## |
#' Parameter Description: "..."
@@ -56,14 +56,17 @@ NULL
NULL
#' Parameter Description: Sided
-#' @param sided Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}. Must be a positive integer of length 1.
+#' @param sided Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}.
+#' Must be a positive integer of length 1.
#' @name param_sided
#' @keywords internal
NULL
#' Parameter Description: Information Rates
-#' @param informationRates The information rates (that must be fixed prior to the trial),
-#' default is \code{(1:kMax) / kMax}.
+#' @param informationRates The information rates t_1, ..., t_kMax (that must be fixed prior to the trial),
+#' default is \code{(1:kMax) / kMax}. For the weighted inverse normal design, the weights are derived
+#' through w_1 = sqrt(t_1), and w_k = sqrt(t_k - t_(k-1)). For the weighted Fisher's combination test, the
+#' weights (scales) are w_k = sqrt((t_k - t_(k-1)) / t_1) (see the documentation).
#' @name param_informationRates
#' @keywords internal
NULL
@@ -815,8 +818,11 @@ NULL
#' Parameter Description: Select Arms Function
#' @param selectArmsFunction Optionally, a function can be entered that defines the way of how treatment arms
-#' are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms}
-#' and \code{stage} (see examples).
+#' are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms},
+#' \code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+#' \code{"allocationRatioPlanned"}, \code{"selectedArms"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+#' \code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+#' \code{"overallRatesControl"}.
#' @name param_selectArmsFunction
#' @keywords internal
NULL
@@ -824,7 +830,10 @@ NULL
#' Parameter Description: Select Populations Function
#' @param selectPopulationsFunction Optionally, a function can be entered that defines the way of how populations
#' are selected. This function is allowed to depend on \code{effectVector} with length \code{populations}
-#' and \code{stage} (see examples).
+#' \code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+#' \code{"allocationRatioPlanned"}, \code{"selectedPopulations"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+#' \code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+#' \code{"overallRatesControl"}.
#' @name param_selectPopulationsFunction
#' @keywords internal
NULL
diff --git a/inst/doc/rpact_getting_started.html b/inst/doc/rpact_getting_started.html
index 3d6053bc..f8760d03 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-04-05
+2024-05-28
diff --git a/man-roxygen/examples_get_simulation_count_data.R b/man-roxygen/examples_get_simulation_count_data.R
deleted file mode 100644
index 9cdbc024..00000000
--- a/man-roxygen/examples_get_simulation_count_data.R
+++ /dev/null
@@ -1,220 +0,0 @@
-library(rpact)
-
-## Fixed sample size ###
-alpha <- 0.025
-beta <- 0.15
-accrualTime <- 24/52
-lambda1 <- 0.55
-lambda2 <- 5.5
-overdispersion <- (7.3 + 14) / 2
-directionUpper <- (lambda1 > lambda2)
-
-design <- getDesignGroupSequential(typeOfDesign = "asHSD", gammaA = -4, futilityBounds = c(0, 0))
-
-y <- getSampleSizeCounts(design = design,
- accrualTime = accrualTime,
- lambda1 = lambda1,
- lambda2 = lambda2,
- overdispersion = overdispersion,
- fixedExposureTime = 24/52)
-y$nFixed
-y$calendarTime
-
-z <- getPowerCounts(alpha = alpha,
- directionUpper = directionUpper,
- maxNumberOfSubjects = 100,
- lambda1 = lambda1,
- lambda2 = lambda2,
- overdispersion = overdispersion,
- fixedExposureTime = 24/52)
-
-z$overallReject
-
-tictoc::tic()
-s <- getSimulationCounts(design = design,
- directionUpper = directionUpper,
- plannedMaxSubjects = 100,
- plannedCalendarTime = as.numeric(y$calendarTime),
- lambda1 = lambda2,
- lambda2 = lambda2,
- overdispersion = overdispersion,
- maxNumberOfIterations = 10000,
- accrualTime = accrualTime,
- fixedExposureTime = 24/52)
-s$overallReject
-tictoc::toc()
-
-
-## Fixed sample size ###
-alpha <- 0.025
-beta <- 0.1
-accrualTime <- 12
-lambda1 <- 0.6
-lambda2 <- 0.3
-overdispersion <- 2
-directionUpper <- (lambda1 > lambda2)
-
-# Case variable exposure
-followUpTime <- 6
-y <- getSampleSizeCounts(alpha = alpha, beta = beta,
- lambda1 = lambda1, lambda2 = lambda2, overdispersion = overdispersion,
- accrualTime = accrualTime, followUpTime = followUpTime)
-
-y$calendarTime
-y$nFixed
-
-
-z <- getPowerCounts(alpha = alpha,
- directionUpper = directionUpper,
- maxNumberOfSubjects = y$nFixed,
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- accrualTime = accrualTime,
- followUpTime = followUpTime)
-
-z$overallReject
-
-tictoc::tic()
-s <- getSimulationCounts(alpha = alpha,
- directionUpper = directionUpper,
- plannedMaxSubjects = y$nFixed,
- plannedCalendarTime = as.numeric(y$calendarTime),
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- maxNumberOfIterations = 500,
- accrualTime = accrualTime,
- followUpTime = followUpTime)
-s$overallReject
-tictoc::toc()
-
-
-# Case fixed exposure
-fixedExposureTime <- 1
-y <- getSampleSizeCounts(alpha = alpha, beta = beta,
- lambda1 = lambda1, lambda2 = lambda2, overdispersion = overdispersion,
- accrualTime = accrualTime, fixedExposureTime = fixedExposureTime)
-y$calendarTime
-y$nFixed
-
-z <- getPowerCounts(alpha = alpha,
- directionUpper = directionUpper,
- maxNumberOfSubjects = y$nFixed,
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- fixedExposureTime = fixedExposureTime,
- accrualTime = accrualTime
-)
-z$overallReject
-
-tictoc::tic()
-s <- getSimulationCounts(alpha = alpha,
- directionUpper = directionUpper,
- plannedMaxSubjects = y$nFixed,
- plannedCalendarTime = y$calendarTime,
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- maxNumberOfIterations = 500,
- fixedExposureTime = fixedExposureTime,
- accrualTime = accrualTime)
-s$overallReject
-tictoc::toc()
-
-
-#################################################################
-#################################################################
-
-## Group sequential design
-alpha <- 0.025
-beta <- 0.2
-accrualTime <- 12
-lambda1 <- 0.3
-lambda2 <- 0.7
-overdispersion <- 2
-directionUpper <- (lambda1 > lambda2)
-informationRates <- c(0.3, 0.55, 1)
-
-design <- getDesignGroupSequential(informationRates = informationRates, alpha = alpha, beta = beta,
- typeOfDesign = "asOF", typeBetaSpending = "bsOF", bindingFutility = TRUE)
-
-# Case variable exposure
-y <- getSampleSizeCounts(design,
- lambda1 = lambda1, lambda2 = lambda2, overdispersion = overdispersion,
- accrualTime = accrualTime, followUpTime = followUpTime
-)
-
-y$calendarTime
-y$maxNumberOfSubjects
-
-z <- getPowerCounts(design = design,
- directionUpper = directionUpper,
- maxNumberOfSubjects = y$maxNumberOfSubjects,
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- accrualTime = accrualTime,
- followUpTime = followUpTime)
-
-z$rejectPerStage
-z$futilityPerStage
-z$overallReject
-
-tictoc::tic()
-s <- getSimulationCounts(design = design,
- directionUpper = directionUpper,
- plannedMaxSubjects = 400,
- plannedCalendarTime = y$calendarTime,
- lambda1 = c(lambda2),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- maxNumberOfIterations = 10000,
- accrualTime = accrualTime,
- followUpTime = followUpTime)
-
-s$rejectPerStage
-s$futilityPerStage
-s$overallReject
-tictoc::toc()
-
-sqrt((1- 0.025)*0.025) / 100
-
-# Case fixed exposure
-fixedExposureTime <- 1
-y <- getSampleSizeCounts(design,
- lambda1 = lambda1, lambda2 = lambda2, overdispersion = overdispersion,
- accrualTime = accrualTime, fixedExposureTime = fixedExposureTime
-)
-y$calendarTime
-y$maxNumberOfSubjects
-
-z <- getPowerCounts(design = design,
- directionUpper = directionUpper,
- maxNumberOfSubjects = y$maxNumberOfSubjects,
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- fixedExposureTime = fixedExposureTime)
-
-z$rejectPerStage
-z$futilityPerStage
-z$overallReject
-
-tictoc::tic()
-s <- getSimulationCounts(design = design,
- directionUpper = directionUpper,
- plannedMaxSubjects = y$maxNumberOfSubjects,
- plannedCalendarTime = y$calendarTime,
- lambda1 = c(lambda2, lambda1),
- lambda2 = lambda2,
- overdispersion = overdispersion,
- accrualTime = accrualTime,
- fixedExposureTime = fixedExposureTime,
- maxNumberOfIterations = 500
-)
-s$rejectPerStage
-s$futilityPerStage
-s$overallReject
-tictoc::toc()
diff --git a/man/as251Normal.Rd b/man/as251Normal.Rd
index 9486e74d..df3afd9e 100644
--- a/man/as251Normal.Rd
+++ b/man/as251Normal.Rd
@@ -33,7 +33,7 @@ fourth derivative is used. If set to zero, error control based on halving interv
}
\description{
Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
}
\details{
For a multivariate normal vector with correlation structure
diff --git a/man/as251StudentT.Rd b/man/as251StudentT.Rd
index 4c405fa5..8df5b554 100644
--- a/man/as251StudentT.Rd
+++ b/man/as251StudentT.Rd
@@ -36,7 +36,7 @@ fourth derivative is used. If set to zero, error control based on halving interv
}
\description{
Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
}
\details{
For a multivariate normal vector with correlation structure
diff --git a/man/getDesignFisher.Rd b/man/getDesignFisher.Rd
index 1b02f42f..696dff3e 100644
--- a/man/getDesignFisher.Rd
+++ b/man/getDesignFisher.Rd
@@ -39,10 +39,13 @@ alpha-spending (Type I error rate) up to each interim stage: \code{0 <= alpha_1
\item{alpha0Vec}{Stopping for futility bounds for stage-wise p-values.}
-\item{informationRates}{The information rates (that must be fixed prior to the trial),
-default is \code{(1:kMax) / kMax}.}
+\item{informationRates}{The information rates t_1, ..., t_kMax (that must be fixed prior to the trial),
+default is \code{(1:kMax) / kMax}. For the weighted inverse normal design, the weights are derived
+through w_1 = sqrt(t_1), and w_k = sqrt(t_k - t_(k-1)). For the weighted Fisher's combination test, the
+weights (scales) are w_k = sqrt((t_k - t_(k-1)) / t_1) (see the documentation).}
-\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}. Must be a positive integer of length 1.}
+\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}.
+Must be a positive integer of length 1.}
\item{bindingFutility}{If \code{bindingFutility = TRUE} is specified the calculation of
the critical values is affected by the futility bounds (default is \code{TRUE}).}
diff --git a/man/getDesignGroupSequential.Rd b/man/getDesignGroupSequential.Rd
index dbadd18d..63d66255 100644
--- a/man/getDesignGroupSequential.Rd
+++ b/man/getDesignGroupSequential.Rd
@@ -46,10 +46,13 @@ The maximum selectable \code{kMax} is \code{20} for group sequential or inverse
(e.g., \code{\link[=getSampleSizeMeans]{getSampleSizeMeans()}}), beta spending function designs,
or optimum designs, default is \code{0.20}. Must be a positive numeric of length 1.}
-\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}. Must be a positive integer of length 1.}
+\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}.
+Must be a positive integer of length 1.}
-\item{informationRates}{The information rates (that must be fixed prior to the trial),
-default is \code{(1:kMax) / kMax}.}
+\item{informationRates}{The information rates t_1, ..., t_kMax (that must be fixed prior to the trial),
+default is \code{(1:kMax) / kMax}. For the weighted inverse normal design, the weights are derived
+through w_1 = sqrt(t_1), and w_k = sqrt(t_k - t_(k-1)). For the weighted Fisher's combination test, the
+weights (scales) are w_k = sqrt((t_k - t_(k-1)) / t_1) (see the documentation).}
\item{futilityBounds}{The futility bounds, defined on the test statistic z scale
(numeric vector of length \code{kMax - 1}).}
diff --git a/man/getDesignInverseNormal.Rd b/man/getDesignInverseNormal.Rd
index 0634cd43..0753586f 100644
--- a/man/getDesignInverseNormal.Rd
+++ b/man/getDesignInverseNormal.Rd
@@ -45,10 +45,13 @@ The maximum selectable \code{kMax} is \code{20} for group sequential or inverse
(e.g., \code{\link[=getSampleSizeMeans]{getSampleSizeMeans()}}), beta spending function designs,
or optimum designs, default is \code{0.20}. Must be a positive numeric of length 1.}
-\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}. Must be a positive integer of length 1.}
+\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}.
+Must be a positive integer of length 1.}
-\item{informationRates}{The information rates (that must be fixed prior to the trial),
-default is \code{(1:kMax) / kMax}.}
+\item{informationRates}{The information rates t_1, ..., t_kMax (that must be fixed prior to the trial),
+default is \code{(1:kMax) / kMax}. For the weighted inverse normal design, the weights are derived
+through w_1 = sqrt(t_1), and w_k = sqrt(t_k - t_(k-1)). For the weighted Fisher's combination test, the
+weights (scales) are w_k = sqrt((t_k - t_(k-1)) / t_1) (see the documentation).}
\item{futilityBounds}{The futility bounds, defined on the test statistic z scale
(numeric vector of length \code{kMax - 1}).}
diff --git a/man/getGroupSequentialProbabilities.Rd b/man/getGroupSequentialProbabilities.Rd
index 1b67ee52..c26d10a9 100644
--- a/man/getGroupSequentialProbabilities.Rd
+++ b/man/getGroupSequentialProbabilities.Rd
@@ -9,8 +9,10 @@ getGroupSequentialProbabilities(decisionMatrix, informationRates)
\arguments{
\item{decisionMatrix}{A matrix with either 2 or 4 rows and kMax = length(informationRates) columns, see details.}
-\item{informationRates}{The information rates (that must be fixed prior to the trial),
-default is \code{(1:kMax) / kMax}.}
+\item{informationRates}{The information rates t_1, ..., t_kMax (that must be fixed prior to the trial),
+default is \code{(1:kMax) / kMax}. For the weighted inverse normal design, the weights are derived
+through w_1 = sqrt(t_1), and w_k = sqrt(t_k - t_(k-1)). For the weighted Fisher's combination test, the
+weights (scales) are w_k = sqrt((t_k - t_(k-1)) / t_1) (see the documentation).}
}
\value{
Returns a numeric matrix containing the probabilities described in the details section.
diff --git a/man/getPerformanceScore.Rd b/man/getPerformanceScore.Rd
index 3ff783db..81e3ceb8 100644
--- a/man/getPerformanceScore.Rd
+++ b/man/getPerformanceScore.Rd
@@ -11,8 +11,8 @@ getPerformanceScore(simulationResult)
}
\description{
Calculates the conditional performance score, its sub-scores and components according to
-\href{https://doi.org/10.1002/sim.8534}{Herrmann et al. (2020)} and
-\href{https://doi.org/10.1186/s12874-024-02150-4}{Bokelmann et al. (2024)} for a given
+(Herrmann et al. (2020), \doi{10.1002/sim.8534}) and
+(Bokelmann et al. (2024), \doi{10.1186/s12874-024-02150-4}) for a given
simulation result from a two-stage design with continuous or binary endpoint.
Larger (sub-)score and component values refer to a better performance.
}
diff --git a/man/getSimulationCounts.Rd b/man/getSimulationCounts.Rd
index e394c827..fedc6bb9 100644
--- a/man/getSimulationCounts.Rd
+++ b/man/getSimulationCounts.Rd
@@ -8,7 +8,7 @@ getSimulationCounts(
design = NULL,
...,
plannedCalendarTime,
- maxNumberOfSubjects = NA_real_,
+ plannedMaxSubjects = NA_real_,
lambda1 = NA_real_,
lambda2 = NA_real_,
lambda = NA_real_,
@@ -38,9 +38,6 @@ that a warning will be displayed if unknown arguments are passed.}
\item{plannedCalendarTime}{For simulating count data, the time points where an analysis is planned to be performed.
Should be a vector of length \code{kMax}}
-\item{maxNumberOfSubjects}{\code{maxNumberOfSubjects > 0} needs to be specified for power calculations or calculation
-of necessary follow-up (count data). For two treatment arms, it is the maximum number of subjects for both treatment arms.}
-
\item{lambda1}{A numeric value or vector that represents the assumed rate of a homogeneous Poisson process in
the active treatment group, there is no default.}
@@ -132,15 +129,6 @@ The summary statistics "Simulated data" contains the following parameters: media
\code{$show(showStatistics = FALSE)} or \code{$setShowStatistics(FALSE)} can be used to disable
the output of the aggregated simulated data.\cr
-Example 1: \cr
-\code{simulationResults <- getSimulationRates(plannedSubjects = 40)} \cr
-\code{simulationResults$show(showStatistics = FALSE)}\cr
-
-Example 2: \cr
-\code{simulationResults <- getSimulationRates(plannedSubjects = 40)} \cr
-\code{simulationResults$setShowStatistics(FALSE)}\cr
-\code{simulationResults}\cr
-
\code{\link[=getData]{getData()}} can be used to get the aggregated simulated data from the
object as \code{\link[base]{data.frame}}. The data frame contains the following columns:
\enumerate{
@@ -181,3 +169,4 @@ There you can find, e.g., \code{plot.AnalysisResults} and
obtain the specific help documentation linked above by typing \code{?plot.AnalysisResults}.
}
+\keyword{internal}
diff --git a/man/getSimulationEnrichmentMeans.Rd b/man/getSimulationEnrichmentMeans.Rd
index d510003b..29ad14a9 100644
--- a/man/getSimulationEnrichmentMeans.Rd
+++ b/man/getSimulationEnrichmentMeans.Rd
@@ -135,7 +135,10 @@ recalculation. By default, sample size recalculation is performed with condition
\item{selectPopulationsFunction}{Optionally, a function can be entered that defines the way of how populations
are selected. This function is allowed to depend on \code{effectVector} with length \code{populations}
-and \code{stage} (see examples).}
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedPopulations"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
\item{showStatistics}{Logical. If \code{TRUE}, summary statistics of the simulated data
are displayed for the \code{print} command, otherwise the output is suppressed, default
diff --git a/man/getSimulationEnrichmentRates.Rd b/man/getSimulationEnrichmentRates.Rd
index eda5c78c..1b9badd6 100644
--- a/man/getSimulationEnrichmentRates.Rd
+++ b/man/getSimulationEnrichmentRates.Rd
@@ -141,7 +141,10 @@ recalculation. By default, sample size recalculation is performed with condition
\item{selectPopulationsFunction}{Optionally, a function can be entered that defines the way of how populations
are selected. This function is allowed to depend on \code{effectVector} with length \code{populations}
-and \code{stage} (see examples).}
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedPopulations"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
\item{showStatistics}{Logical. If \code{TRUE}, summary statistics of the simulated data
are displayed for the \code{print} command, otherwise the output is suppressed, default
diff --git a/man/getSimulationEnrichmentSurvival.Rd b/man/getSimulationEnrichmentSurvival.Rd
index 39b526be..e83d46d5 100644
--- a/man/getSimulationEnrichmentSurvival.Rd
+++ b/man/getSimulationEnrichmentSurvival.Rd
@@ -130,7 +130,10 @@ recalculation. By default, event number recalculation is performed with conditio
\item{selectPopulationsFunction}{Optionally, a function can be entered that defines the way of how populations
are selected. This function is allowed to depend on \code{effectVector} with length \code{populations}
-and \code{stage} (see examples).}
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedPopulations"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
\item{showStatistics}{Logical. If \code{TRUE}, summary statistics of the simulated data
are displayed for the \code{print} command, otherwise the output is suppressed, default
diff --git a/man/getSimulationMultiArmMeans.Rd b/man/getSimulationMultiArmMeans.Rd
index 2a686b6a..36495753 100644
--- a/man/getSimulationMultiArmMeans.Rd
+++ b/man/getSimulationMultiArmMeans.Rd
@@ -161,8 +161,11 @@ recalculation. By default, sample size recalculation is performed with condition
\code{minNumberOfSubjectsPerStage} and \code{maxNumberOfSubjectsPerStage} (see details and examples).}
\item{selectArmsFunction}{Optionally, a function can be entered that defines the way of how treatment arms
-are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms}
-and \code{stage} (see examples).}
+are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms},
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedArms"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
\item{showStatistics}{Logical. If \code{TRUE}, summary statistics of the simulated data
are displayed for the \code{print} command, otherwise the output is suppressed, default
diff --git a/man/getSimulationMultiArmRates.Rd b/man/getSimulationMultiArmRates.Rd
index cb5fd819..b85e6bac 100644
--- a/man/getSimulationMultiArmRates.Rd
+++ b/man/getSimulationMultiArmRates.Rd
@@ -164,8 +164,11 @@ recalculation. By default, sample size recalculation is performed with condition
\code{minNumberOfSubjectsPerStage} and \code{maxNumberOfSubjectsPerStage} (see details and examples).}
\item{selectArmsFunction}{Optionally, a function can be entered that defines the way of how treatment arms
-are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms}
-and \code{stage} (see examples).}
+are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms},
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedArms"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
\item{showStatistics}{Logical. If \code{TRUE}, summary statistics of the simulated data
are displayed for the \code{print} command, otherwise the output is suppressed, default
diff --git a/man/getSimulationMultiArmSurvival.Rd b/man/getSimulationMultiArmSurvival.Rd
index 8e85bab2..11992066 100644
--- a/man/getSimulationMultiArmSurvival.Rd
+++ b/man/getSimulationMultiArmSurvival.Rd
@@ -159,8 +159,11 @@ recalculation. By default, event number recalculation is performed with conditio
\code{minNumberOfEventsPerStage} and \code{maxNumberOfEventsPerStage} (see details and examples).}
\item{selectArmsFunction}{Optionally, a function can be entered that defines the way of how treatment arms
-are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms}
-and \code{stage} (see examples).}
+are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms},
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedArms"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
\item{showStatistics}{Logical. If \code{TRUE}, summary statistics of the simulated data
are displayed for the \code{print} command, otherwise the output is suppressed, default
diff --git a/man/mvnprd.Rd b/man/mvnprd.Rd
index 8604c820..29b2eb7a 100644
--- a/man/mvnprd.Rd
+++ b/man/mvnprd.Rd
@@ -31,7 +31,7 @@ fourth derivative is used. If set to zero, error control based on halving inter
}
\description{
Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
}
\details{
This is a wrapper function for the original Fortran 77 code.
diff --git a/man/mvstud.Rd b/man/mvstud.Rd
index e5a726e6..9aa31cab 100644
--- a/man/mvstud.Rd
+++ b/man/mvstud.Rd
@@ -35,7 +35,7 @@ fourth derivative is used. If set to zero, error control based on halving inter
}
\description{
Calculates the Multivariate Normal Distribution with Product Correlation Structure published
-by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3 \doi{10.2307/2347754}.
+by Charles Dunnett, Algorithm AS 251.1 Appl.Statist. (1989), Vol.38, No.3, \doi{10.2307/2347754}.
}
\details{
This is a wrapper function for the original Fortran 77 code.
diff --git a/man/param_informationRates.Rd b/man/param_informationRates.Rd
index 732f5ac0..a82a3b71 100644
--- a/man/param_informationRates.Rd
+++ b/man/param_informationRates.Rd
@@ -4,8 +4,10 @@
\alias{param_informationRates}
\title{Parameter Description: Information Rates}
\arguments{
-\item{informationRates}{The information rates (that must be fixed prior to the trial),
-default is \code{(1:kMax) / kMax}.}
+\item{informationRates}{The information rates t_1, ..., t_kMax (that must be fixed prior to the trial),
+default is \code{(1:kMax) / kMax}. For the weighted inverse normal design, the weights are derived
+through w_1 = sqrt(t_1), and w_k = sqrt(t_k - t_(k-1)). For the weighted Fisher's combination test, the
+weights (scales) are w_k = sqrt((t_k - t_(k-1)) / t_1) (see the documentation).}
}
\description{
Parameter Description: Information Rates
diff --git a/man/param_selectArmsFunction.Rd b/man/param_selectArmsFunction.Rd
index 14f5c524..be231373 100644
--- a/man/param_selectArmsFunction.Rd
+++ b/man/param_selectArmsFunction.Rd
@@ -5,8 +5,11 @@
\title{Parameter Description: Select Arms Function}
\arguments{
\item{selectArmsFunction}{Optionally, a function can be entered that defines the way of how treatment arms
-are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms}
-and \code{stage} (see examples).}
+are selected. This function is allowed to depend on \code{effectVector} with length \code{activeArms},
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedArms"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
}
\description{
Parameter Description: Select Arms Function
diff --git a/man/param_selectPopulationsFunction.Rd b/man/param_selectPopulationsFunction.Rd
index 3e1cac20..e1ddcd49 100644
--- a/man/param_selectPopulationsFunction.Rd
+++ b/man/param_selectPopulationsFunction.Rd
@@ -6,7 +6,10 @@
\arguments{
\item{selectPopulationsFunction}{Optionally, a function can be entered that defines the way of how populations
are selected. This function is allowed to depend on \code{effectVector} with length \code{populations}
-and \code{stage} (see examples).}
+\code{stage}, \code{"conditionalPower"}, \code{"conditionalCriticalValue"}, \code{"plannedSubjects/plannedEvents"},
+\code{"allocationRatioPlanned"}, \code{"selectedPopulations"}, \code{"thetaH1"} (for means and survival), \code{"stDevH1"} (for means),
+\code{"overallEffects"}, and for rates additionally: \code{"piTreatmentsH1"}, \code{"piControlH1"}, \code{"overallRates"}, and
+\code{"overallRatesControl"}.}
}
\description{
Parameter Description: Select Populations Function
diff --git a/man/param_sided.Rd b/man/param_sided.Rd
index 3ddaaeb2..1913f5b6 100644
--- a/man/param_sided.Rd
+++ b/man/param_sided.Rd
@@ -4,7 +4,8 @@
\alias{param_sided}
\title{Parameter Description: Sided}
\arguments{
-\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}. Must be a positive integer of length 1.}
+\item{sided}{Is the alternative one-sided (\code{1}) or two-sided (\code{2}), default is \code{1}.
+Must be a positive integer of length 1.}
}
\description{
Parameter Description: Sided
diff --git a/tests/testthat/test-class_design_plan.R b/tests/testthat/test-class_design_plan.R
index 32326d82..b36d2248 100644
--- a/tests/testthat/test-class_design_plan.R
+++ b/tests/testthat/test-class_design_plan.R
@@ -14,9 +14,9 @@
## | Contact us for information about our services: info@rpact.com
## |
## | File name: test-class_design_plan.R
-## | Creation date: 26 February 2024, 10:31:43
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | Creation date: 27 May 2024, 11:11:19
+## | File version: $Revision: 7940 $
+## | Last changed: $Date: 2024-05-27 15:47:41 +0200 (Mo, 27 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -102,6 +102,7 @@ test_that("Sample size rates result object clone function", {
expect_equal(x1$thetaH0, x2$thetaH0, tolerance = 1e-07)
expect_equal(x1$normalApproximation, x2$normalApproximation)
expect_equal(x1$pi1, x2$pi1, tolerance = 1e-07)
+ expect_equal(x1$pi2, x2$pi2, tolerance = 1e-07)
expect_equal(x1$groups, x2$groups)
expect_equal(x1$allocationRatioPlanned, x2$allocationRatioPlanned)
expect_equal(x1$optimumAllocationRatio, x2$optimumAllocationRatio)
@@ -130,6 +131,7 @@ test_that("Power rates result object clone function", {
expect_equal(x1$thetaH0, x2$thetaH0, tolerance = 1e-07)
expect_equal(x1$normalApproximation, x2$normalApproximation)
expect_equal(x1$pi1, x2$pi1, tolerance = 1e-07)
+ expect_equal(x1$pi2, x2$pi2, tolerance = 1e-07)
expect_equal(x1$groups, x2$groups)
expect_equal(x1$allocationRatioPlanned, x2$allocationRatioPlanned)
expect_equal(x1$optimumAllocationRatio, x2$optimumAllocationRatio)
@@ -172,12 +174,18 @@ test_that("Sample size survival result object clone function", {
expect_equal(x1$lambda1, x2$lambda1, tolerance = 1e-07)
expect_equal(x1$lambda2, x2$lambda2, tolerance = 1e-07)
expect_equal(x1$hazardRatio, x2$hazardRatio, tolerance = 1e-07)
+ expect_equal(x1$maxNumberOfSubjects, x2$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(x2$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
+ expect_equal(x2$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
+ expect_equal(x2$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
expect_equal(x1$maxNumberOfEvents, x2$maxNumberOfEvents, tolerance = 1e-07)
expect_equal(x1$allocationRatioPlanned, x2$allocationRatioPlanned)
expect_equal(x1$optimumAllocationRatio, x2$optimumAllocationRatio)
+ expect_equal(x1$accountForObservationTimes, x2$accountForObservationTimes)
expect_equal(x1$eventTime, x2$eventTime)
expect_equal(x1$accrualTime, x2$accrualTime)
expect_equal(x1$totalAccrualTime, x2$totalAccrualTime)
+ expect_equal(x1$accrualIntensity, x2$accrualIntensity, tolerance = 1e-07)
expect_equal(x1$accrualIntensityRelative, x2$accrualIntensityRelative, tolerance = 1e-07)
expect_equal(x1$kappa, x2$kappa)
expect_equal(x1$piecewiseSurvivalTime, x2$piecewiseSurvivalTime)
@@ -185,7 +193,14 @@ test_that("Sample size survival result object clone function", {
expect_equal(x1$dropoutRate1, x2$dropoutRate1)
expect_equal(x1$dropoutRate2, x2$dropoutRate2)
expect_equal(x1$dropoutTime, x2$dropoutTime)
+ expect_equal(x1$chi, x2$chi, tolerance = 1e-07)
expect_equal(x1$eventsFixed, x2$eventsFixed, tolerance = 1e-07)
+ expect_equal(x1$nFixed, x2$nFixed, tolerance = 1e-07)
+ expect_equal(x1$nFixed1, x2$nFixed1, tolerance = 1e-07)
+ expect_equal(x1$nFixed2, x2$nFixed2, tolerance = 1e-07)
+ expect_equal(x2$analysisTime[1, ], x1$analysisTime[1, ])
+ expect_equal(x1$studyDuration, x2$studyDuration)
+ expect_equal(x1$maxStudyDuration, x2$maxStudyDuration)
expect_equal(x2$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ], tolerance = 1e-07)
expect_equal(x2$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ], tolerance = 1e-07)
expect_equal(x1$expectedEventsH1, x2$expectedEventsH1, tolerance = 1e-07)
@@ -194,6 +209,8 @@ test_that("Sample size survival result object clone function", {
})
test_that("Sample size survival result object utility functions", {
+ .skipTestIfDisabled()
+
sampleSizeResult <- getSampleSizeSurvival(alpha = 0.01)
expect_true(R6::is.R6(sampleSizeResult$getPlotSettings()))
expect_true(any(grepl("Technical developer summary", utils::capture.output(sampleSizeResult$show(showType = 2)))))
@@ -248,6 +265,8 @@ test_that("Power survival result object clone function", {
})
test_that("Power survival result object utility functions", {
+ .skipTestIfDisabled()
+
powerResult <- getPowerSurvival(maxNumberOfEvents = 40, maxNumberOfSubjects = 200)
expect_true(R6::is.R6(powerResult$getPlotSettings()))
expect_true(any(grepl("Technical developer summary", utils::capture.output(powerResult$show(showType = 2)))))
@@ -292,6 +311,8 @@ test_that("Sample size counts result object clone function", {
})
test_that("Sample size counts result object utility functions", {
+ .skipTestIfDisabled()
+
sampleSizeResult <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, lambda = 0.234, theta = 0.7,
overdispersion = 0.71, accrualTime = 7, fixedExposureTime = 1
@@ -302,6 +323,8 @@ test_that("Sample size counts result object utility functions", {
})
test_that("Power counts result object clone function", {
+ .skipTestIfDisabled()
+
x1 <- getPowerCounts(
maxNumberOfSubjects = 400, directionUpper = FALSE,
overdispersion = 1, fixedExposureTime = 1, lambda1 = seq(1.05, 1.55, 0.1), lambda2 = 1.4
@@ -342,3 +365,75 @@ test_that("Power counts result object utility functions", {
expect_true(any(grepl("Technical developer summary", utils::capture.output(powerResult$show(showType = 2)))))
expect_true(any(grepl("Power calculation for a count data endpoint", utils::capture.output(powerResult$show(showType = 3)))))
})
+
+test_that("Design plan utility functions", {
+ .skipTestIfDisabled()
+
+ trialDesignPlan <- TrialDesignPlan$new(design = NULL)
+
+ expect_error(trialDesignPlan$.isSampleSizeObject())
+ expect_error(trialDesignPlan$.isPowerObject())
+ expect_equal(trialDesignPlan$getBeta(), NA_real_)
+ expect_equal(trialDesignPlan$getTwoSidedPower(), NA)
+ expect_equal(trialDesignPlan$.toString(), "unknown data class 'TrialDesignPlan'")
+ expect_error(trialDesignPlan$.setObjectType("xxx"))
+})
+
+test_that("Sample size means recreate function", {
+ trialDesignPlan <- getSampleSizeMeans()
+ trialDesignPlanCopy <- trialDesignPlan$recreate()
+
+ ## Pairwise comparison of the results of trialDesignPlan with the results of trialDesignPlanCopy
+ expect_equal(trialDesignPlan$nFixed, trialDesignPlanCopy$nFixed, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$nFixed1, trialDesignPlanCopy$nFixed1, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$nFixed2, trialDesignPlanCopy$nFixed2, tolerance = 1e-07)
+ expect_equal(trialDesignPlanCopy$criticalValuesEffectScale[1, ], trialDesignPlan$criticalValuesEffectScale[1, ], tolerance = 1e-07)
+})
+
+test_that("Sample size rates recreate function", {
+ trialDesignPlan <- getSampleSizeRates()
+ trialDesignPlanCopy <- trialDesignPlan$recreate()
+
+ ## Pairwise comparison of the results of trialDesignPlan with the results of trialDesignPlanCopy
+ expect_equal(trialDesignPlan$directionUpper, trialDesignPlanCopy$directionUpper)
+ expect_equal(trialDesignPlan$nFixed, trialDesignPlanCopy$nFixed, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$nFixed1, trialDesignPlanCopy$nFixed1, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$nFixed2, trialDesignPlanCopy$nFixed2, tolerance = 1e-07)
+ expect_equal(trialDesignPlanCopy$criticalValuesEffectScale[1, ], trialDesignPlan$criticalValuesEffectScale[1, ], tolerance = 1e-07)
+})
+
+test_that("Sample size survival recreate function", {
+ trialDesignPlan <- getSampleSizeSurvival()
+ trialDesignPlanCopy <- trialDesignPlan$recreate()
+
+ expect_equal(trialDesignPlan$directionUpper, trialDesignPlanCopy$directionUpper)
+ expect_equal(trialDesignPlan$median1, trialDesignPlanCopy$median1, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$median2, trialDesignPlanCopy$median2, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$lambda1, trialDesignPlanCopy$lambda1, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$lambda2, trialDesignPlanCopy$lambda2, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$hazardRatio, trialDesignPlanCopy$hazardRatio, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$maxNumberOfEvents, trialDesignPlanCopy$maxNumberOfEvents, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$eventsFixed, trialDesignPlanCopy$eventsFixed, tolerance = 1e-07)
+ expect_equal(trialDesignPlanCopy$criticalValuesEffectScale[1, ], trialDesignPlan$criticalValuesEffectScale[1, ], tolerance = 1e-07)
+})
+
+test_that("Count data recreate function", {
+ trialDesignPlan <- getSampleSizeCounts(
+ alpha = 0.01, beta = 0.05, lambda = 0.234, theta = 0.7,
+ overdispersion = 0.71, accrualTime = 7, fixedExposureTime = 1
+ )
+ trialDesignPlanCopy <- trialDesignPlan$recreate()
+
+ ## Pairwise comparison of the results of trialDesignPlan with the results of trialDesignPlanCopy
+ expect_equal(trialDesignPlan$directionUpper, trialDesignPlanCopy$directionUpper)
+ expect_equal(trialDesignPlan$lambda1, trialDesignPlanCopy$lambda1, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$lambda2, trialDesignPlanCopy$lambda2, tolerance = 1e-07)
+ expect_equal(trialDesignPlan$nFixed, trialDesignPlanCopy$nFixed)
+ expect_equal(trialDesignPlan$nFixed1, trialDesignPlanCopy$nFixed1)
+ expect_equal(trialDesignPlan$nFixed2, trialDesignPlanCopy$nFixed2)
+ expect_equal(trialDesignPlan$maxNumberOfSubjects, trialDesignPlanCopy$maxNumberOfSubjects)
+ expect_equal(trialDesignPlanCopy$calendarTime[1, ], trialDesignPlan$calendarTime[1, ])
+ expect_equal(trialDesignPlan$expectedStudyDurationH1, trialDesignPlanCopy$expectedStudyDurationH1)
+ expect_equal(trialDesignPlan$expectedNumberOfSubjectsH1, trialDesignPlanCopy$expectedNumberOfSubjectsH1)
+ expect_equal(trialDesignPlan$maxInformation, trialDesignPlanCopy$maxInformation, tolerance = 1e-07)
+})
diff --git a/tests/testthat/test-class_design_set.R b/tests/testthat/test-class_design_set.R
index 8b75a755..9171e948 100644
--- a/tests/testthat/test-class_design_set.R
+++ b/tests/testthat/test-class_design_set.R
@@ -15,8 +15,8 @@
## |
## | File name: test-class_design_set.R
## | Creation date: 23 February 2024, 12:33:48
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7928 $
+## | Last changed: $Date: 2024-05-23 16:35:16 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
diff --git a/tests/testthat/test-class_dictionary.R b/tests/testthat/test-class_dictionary.R
index 56a15ee1..f4ecd02d 100644
--- a/tests/testthat/test-class_dictionary.R
+++ b/tests/testthat/test-class_dictionary.R
@@ -15,9 +15,9 @@
## |
## | File name: test-class_dictionary.R
## | Creation date: 23 February 2024, 07:45:41
-## | File version: $Revision: 7662 $
-## | Last changed: $Date: 2024-02-23 12:42:26 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing Class 'Dictionary'")
diff --git a/tests/testthat/test-class_time.R b/tests/testthat/test-class_time.R
index 8f2c8810..da10dcce 100644
--- a/tests/testthat/test-class_time.R
+++ b/tests/testthat/test-class_time.R
@@ -1,2734 +1,2778 @@
-## |
-## | *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-class_time.R
-## | Creation date: 08 November 2023, 08:49:49
-## | File version: $Revision: 7665 $
-## | Last changed: $Date: 2024-02-23 17:33:46 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
-## |
-
-test_plan_section("Testing Class 'PiecewiseSurvivalTime'")
-
-
-test_that("Testing 'getPiecewiseSurvivalTime': isPiecewiseSurvivalEnabled()", {
- # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
- expect_false(getPiecewiseSurvivalTime()$isPiecewiseSurvivalEnabled())
- expect_false(getPiecewiseSurvivalTime(piecewiseSurvivalTime = NA)$isPiecewiseSurvivalEnabled())
-
-})
-
-test_that("Testing 'getPiecewiseSurvivalTime': simple vector based definition", {
-
- # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
- pwSurvivalTime1 <- getPiecewiseSurvivalTime(lambda2 = 0.5, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime1' with expected results
- expect_equal(pwSurvivalTime1$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$lambda1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$lambda2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$median1, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$median2, 1.3862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime1$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime1), NA)))
- expect_output(print(pwSurvivalTime1)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime1), NA)))
- expect_output(summary(pwSurvivalTime1)$show())
- pwSurvivalTime1CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime1, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalTime, pwSurvivalTime1$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$lambda1, pwSurvivalTime1$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$lambda2, pwSurvivalTime1$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$hazardRatio, pwSurvivalTime1$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$pi1, pwSurvivalTime1$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$pi2, pwSurvivalTime1$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$median1, pwSurvivalTime1$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$median2, pwSurvivalTime1$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$eventTime, pwSurvivalTime1$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$kappa, pwSurvivalTime1$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime1$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$delayedResponseAllowed, pwSurvivalTime1$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$delayedResponseEnabled, pwSurvivalTime1$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime1), "character")
- df <- as.data.frame(pwSurvivalTime1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime2 <- getPiecewiseSurvivalTime(lambda2 = 0.5, lambda1 = 0.4)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
- expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median1, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median2, 1.3862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
- expect_output(print(pwSurvivalTime2)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
- expect_output(summary(pwSurvivalTime2)$show())
- pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime2), "character")
- df <- as.data.frame(pwSurvivalTime2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- .skipTestIfDisabled()
-
- pwSurvivalTime2 <- getPiecewiseSurvivalTime(pi2 = 0.5, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
- expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda1, 0.046209812, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda2, 0.057762265, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi1, 0.42565082, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median1, 15, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median2, 12, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
- expect_output(print(pwSurvivalTime2)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
- expect_output(summary(pwSurvivalTime2)$show())
- pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime2), "character")
- df <- as.data.frame(pwSurvivalTime2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime2 <- getPiecewiseSurvivalTime(pi2 = 0.5, pi1 = 0.4)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
- expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda1, 0.042568802, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda2, 0.057762265, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$hazardRatio, 0.73696559, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median1, 16.282985, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median2, 12, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
- expect_output(print(pwSurvivalTime2)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
- expect_output(summary(pwSurvivalTime2)$show())
- pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime2), "character")
- df <- as.data.frame(pwSurvivalTime2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime3 <- getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime3' with expected results
- expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$lambda1, c(0.24, 0.32), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$lambda2, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$hazardRatio, c(0.6, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$median1, c(2.8881133, 2.1660849), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$median2, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime3$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime3), NA)))
- expect_output(print(pwSurvivalTime3)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime3), NA)))
- expect_output(summary(pwSurvivalTime3)$show())
- pwSurvivalTime3CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime3, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalTime, pwSurvivalTime3$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$lambda1, pwSurvivalTime3$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$lambda2, pwSurvivalTime3$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$hazardRatio, pwSurvivalTime3$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$pi1, pwSurvivalTime3$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$pi2, pwSurvivalTime3$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$median1, pwSurvivalTime3$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$median2, pwSurvivalTime3$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$eventTime, pwSurvivalTime3$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$kappa, pwSurvivalTime3$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime3$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$delayedResponseAllowed, pwSurvivalTime3$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$delayedResponseEnabled, pwSurvivalTime3$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime3), "character")
- df <- as.data.frame(pwSurvivalTime3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime8 <- getPiecewiseSurvivalTime(pi2 = 0.4, pi1 = 0.3)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime8' with expected results
- expect_equal(pwSurvivalTime8$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime8$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$lambda1, 0.029722912, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$lambda2, 0.042568802, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$hazardRatio, 0.69823229, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$pi1, 0.3, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$pi2, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$median1, 23.320299, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$median2, 16.282985, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime8$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime8$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime8$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime8$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime8$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime8$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime8), NA)))
- expect_output(print(pwSurvivalTime8)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime8), NA)))
- expect_output(summary(pwSurvivalTime8)$show())
- pwSurvivalTime8CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime8, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime8CodeBased$piecewiseSurvivalTime, pwSurvivalTime8$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$lambda1, pwSurvivalTime8$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$lambda2, pwSurvivalTime8$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$hazardRatio, pwSurvivalTime8$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$pi1, pwSurvivalTime8$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$pi2, pwSurvivalTime8$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$median1, pwSurvivalTime8$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$median2, pwSurvivalTime8$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$eventTime, pwSurvivalTime8$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$kappa, pwSurvivalTime8$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime8$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$delayedResponseAllowed, pwSurvivalTime8$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime8CodeBased$delayedResponseEnabled, pwSurvivalTime8$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime8), "character")
- df <- as.data.frame(pwSurvivalTime8)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime9 <- getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi2 = 0.3)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime9' with expected results
- expect_equal(pwSurvivalTime9$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime9$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$lambda1, c(0.017833747, 0.02377833), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$lambda2, 0.029722912, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$hazardRatio, c(0.6, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$pi1, c(0.19265562, 0.24824135), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$pi2, 0.3, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$median1, c(38.867164, 29.150373), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$median2, 23.320299, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime9$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime9$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime9$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime9$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime9$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime9$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime9), NA)))
- expect_output(print(pwSurvivalTime9)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime9), NA)))
- expect_output(summary(pwSurvivalTime9)$show())
- pwSurvivalTime9CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime9, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime9CodeBased$piecewiseSurvivalTime, pwSurvivalTime9$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$lambda1, pwSurvivalTime9$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$lambda2, pwSurvivalTime9$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$hazardRatio, pwSurvivalTime9$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$pi1, pwSurvivalTime9$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$pi2, pwSurvivalTime9$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$median1, pwSurvivalTime9$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$median2, pwSurvivalTime9$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$eventTime, pwSurvivalTime9$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$kappa, pwSurvivalTime9$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime9$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$delayedResponseAllowed, pwSurvivalTime9$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime9CodeBased$delayedResponseEnabled, pwSurvivalTime9$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime9), "character")
- df <- as.data.frame(pwSurvivalTime9)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime9)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime10 <- getPiecewiseSurvivalTime(median2 = 1.386294, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime10' with expected results
- expect_equal(pwSurvivalTime10$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$lambda1, 0.4000001, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$lambda2, 0.50000013, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$median1, 1.7328675, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$median2, 1.386294, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime10$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime10), NA)))
- expect_output(print(pwSurvivalTime10)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime10), NA)))
- expect_output(summary(pwSurvivalTime10)$show())
- pwSurvivalTime10CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime10, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalTime, pwSurvivalTime10$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$lambda1, pwSurvivalTime10$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$lambda2, pwSurvivalTime10$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$hazardRatio, pwSurvivalTime10$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$pi1, pwSurvivalTime10$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$pi2, pwSurvivalTime10$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$median1, pwSurvivalTime10$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$median2, pwSurvivalTime10$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$eventTime, pwSurvivalTime10$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$kappa, pwSurvivalTime10$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime10$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$delayedResponseAllowed, pwSurvivalTime10$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$delayedResponseEnabled, pwSurvivalTime10$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime10), "character")
- df <- as.data.frame(pwSurvivalTime10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime11 <- getPiecewiseSurvivalTime(median2 = 1.386294, lambda1 = 0.4)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime11' with expected results
- expect_equal(pwSurvivalTime11$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$lambda1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$lambda2, 0.50000013, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$hazardRatio, 0.79999979, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$median1, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$median2, 1.386294, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime11$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime11), NA)))
- expect_output(print(pwSurvivalTime11)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime11), NA)))
- expect_output(summary(pwSurvivalTime11)$show())
- pwSurvivalTime11CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime11, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalTime, pwSurvivalTime11$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$lambda1, pwSurvivalTime11$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$lambda2, pwSurvivalTime11$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$hazardRatio, pwSurvivalTime11$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$pi1, pwSurvivalTime11$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$pi2, pwSurvivalTime11$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$median1, pwSurvivalTime11$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$median2, pwSurvivalTime11$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$eventTime, pwSurvivalTime11$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$kappa, pwSurvivalTime11$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime11$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$delayedResponseAllowed, pwSurvivalTime11$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$delayedResponseEnabled, pwSurvivalTime11$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime11), "character")
- df <- as.data.frame(pwSurvivalTime11)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime11)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime12 <- getPiecewiseSurvivalTime(median2 = 5, median1 = 6)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime12' with expected results
- expect_equal(pwSurvivalTime12$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$lambda1, 0.11552453, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$lambda2, 0.13862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$hazardRatio, 0.83333333, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$median1, 6, label = paste0("c(", paste0(pwSurvivalTime12$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$median2, 5, label = paste0("c(", paste0(pwSurvivalTime12$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime12$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime12), NA)))
- expect_output(print(pwSurvivalTime12)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime12), NA)))
- expect_output(summary(pwSurvivalTime12)$show())
- pwSurvivalTime12CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime12, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalTime, pwSurvivalTime12$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$lambda1, pwSurvivalTime12$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$lambda2, pwSurvivalTime12$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$hazardRatio, pwSurvivalTime12$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$pi1, pwSurvivalTime12$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$pi2, pwSurvivalTime12$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$median1, pwSurvivalTime12$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$median2, pwSurvivalTime12$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$eventTime, pwSurvivalTime12$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$kappa, pwSurvivalTime12$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime12$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$delayedResponseAllowed, pwSurvivalTime12$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$delayedResponseEnabled, pwSurvivalTime12$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime12), "character")
- df <- as.data.frame(pwSurvivalTime12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime13 <- getPiecewiseSurvivalTime(median2 = 1.386294, lambda1 = c(0.3, 0.4))
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime13' with expected results
- expect_equal(pwSurvivalTime13$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$lambda1, c(0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$lambda2, 0.50000013, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$hazardRatio, c(0.59999984, 0.79999979), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$median1, c(2.3104906, 1.732868), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$median2, 1.386294, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime13$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime13), NA)))
- expect_output(print(pwSurvivalTime13)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime13), NA)))
- expect_output(summary(pwSurvivalTime13)$show())
- pwSurvivalTime13CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime13, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalTime, pwSurvivalTime13$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$lambda1, pwSurvivalTime13$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$lambda2, pwSurvivalTime13$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$hazardRatio, pwSurvivalTime13$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$pi1, pwSurvivalTime13$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$pi2, pwSurvivalTime13$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$median1, pwSurvivalTime13$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$median2, pwSurvivalTime13$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$eventTime, pwSurvivalTime13$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$kappa, pwSurvivalTime13$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime13$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$delayedResponseAllowed, pwSurvivalTime13$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$delayedResponseEnabled, pwSurvivalTime13$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime13), "character")
- df <- as.data.frame(pwSurvivalTime13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime14 <- getPiecewiseSurvivalTime(median2 = 5, median1 = c(6:8))
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime14' with expected results
- expect_equal(pwSurvivalTime14$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$lambda1, c(0.11552453, 0.099021026, 0.086643398), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime14$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$lambda2, 0.13862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime14$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$hazardRatio, c(0.83333333, 0.71428571, 0.625), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime14$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$median1, c(6, 7, 8), label = paste0("c(", paste0(pwSurvivalTime14$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$median2, 5, label = paste0("c(", paste0(pwSurvivalTime14$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime14$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime14$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime14$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime14$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime14$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime14), NA)))
- expect_output(print(pwSurvivalTime14)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime14), NA)))
- expect_output(summary(pwSurvivalTime14)$show())
- pwSurvivalTime14CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime14, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime14CodeBased$piecewiseSurvivalTime, pwSurvivalTime14$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$lambda1, pwSurvivalTime14$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$lambda2, pwSurvivalTime14$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$hazardRatio, pwSurvivalTime14$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$pi1, pwSurvivalTime14$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$pi2, pwSurvivalTime14$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$median1, pwSurvivalTime14$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$median2, pwSurvivalTime14$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$eventTime, pwSurvivalTime14$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$kappa, pwSurvivalTime14$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime14$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$delayedResponseAllowed, pwSurvivalTime14$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime14CodeBased$delayedResponseEnabled, pwSurvivalTime14$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime14), "character")
- df <- as.data.frame(pwSurvivalTime14)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime14)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime15 <- getPiecewiseSurvivalTime(median2 = 2, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime15' with expected results
- expect_equal(pwSurvivalTime15$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$lambda1, 0.27725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$lambda2, 0.34657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$median1, 2.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$median2, 2, label = paste0("c(", paste0(pwSurvivalTime15$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime15$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime15$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime15$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime15$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime15$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime15), NA)))
- expect_output(print(pwSurvivalTime15)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime15), NA)))
- expect_output(summary(pwSurvivalTime15)$show())
- pwSurvivalTime15CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime15, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime15CodeBased$piecewiseSurvivalTime, pwSurvivalTime15$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$lambda1, pwSurvivalTime15$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$lambda2, pwSurvivalTime15$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$hazardRatio, pwSurvivalTime15$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$pi1, pwSurvivalTime15$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$pi2, pwSurvivalTime15$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$median1, pwSurvivalTime15$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$median2, pwSurvivalTime15$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$eventTime, pwSurvivalTime15$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$kappa, pwSurvivalTime15$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime15$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$delayedResponseAllowed, pwSurvivalTime15$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime15CodeBased$delayedResponseEnabled, pwSurvivalTime15$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime15), "character")
- df <- as.data.frame(pwSurvivalTime15)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime15)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime16 <- getPiecewiseSurvivalTime(median1 = c(2, 2), hazardRatio = c(1.4, 1.4))
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime16' with expected results
- expect_equal(pwSurvivalTime16$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$lambda1, c(0.34657359, 0.34657359), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$lambda2, c(0.24755256, 0.24755256), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$hazardRatio, c(1.4, 1.4), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$median1, c(2, 2), label = paste0("c(", paste0(pwSurvivalTime16$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$median2, c(2.8, 2.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime16$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime16$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime16$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime16$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime16$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime16), NA)))
- expect_output(print(pwSurvivalTime16)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime16), NA)))
- expect_output(summary(pwSurvivalTime16)$show())
- pwSurvivalTime16CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime16, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime16CodeBased$piecewiseSurvivalTime, pwSurvivalTime16$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$lambda1, pwSurvivalTime16$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$lambda2, pwSurvivalTime16$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$hazardRatio, pwSurvivalTime16$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$pi1, pwSurvivalTime16$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$pi2, pwSurvivalTime16$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$median1, pwSurvivalTime16$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$median2, pwSurvivalTime16$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$eventTime, pwSurvivalTime16$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$kappa, pwSurvivalTime16$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime16$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$delayedResponseAllowed, pwSurvivalTime16$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime16CodeBased$delayedResponseEnabled, pwSurvivalTime16$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime16), "character")
- df <- as.data.frame(pwSurvivalTime16)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime16)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime17 <- getPiecewiseSurvivalTime(median1 = c(2, 3), median2 = 4)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime17' with expected results
- expect_equal(pwSurvivalTime17$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$lambda1, c(0.34657359, 0.23104906), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime17$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$lambda2, 0.1732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime17$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$hazardRatio, c(2, 1.3333333), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime17$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$median1, c(2, 3), label = paste0("c(", paste0(pwSurvivalTime17$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$median2, 4, label = paste0("c(", paste0(pwSurvivalTime17$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime17$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime17$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime17$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime17$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime17$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime17), NA)))
- expect_output(print(pwSurvivalTime17)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime17), NA)))
- expect_output(summary(pwSurvivalTime17)$show())
- pwSurvivalTime17CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime17, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime17CodeBased$piecewiseSurvivalTime, pwSurvivalTime17$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$lambda1, pwSurvivalTime17$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$lambda2, pwSurvivalTime17$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$hazardRatio, pwSurvivalTime17$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$pi1, pwSurvivalTime17$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$pi2, pwSurvivalTime17$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$median1, pwSurvivalTime17$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$median2, pwSurvivalTime17$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$eventTime, pwSurvivalTime17$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$kappa, pwSurvivalTime17$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime17$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$delayedResponseAllowed, pwSurvivalTime17$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime17CodeBased$delayedResponseEnabled, pwSurvivalTime17$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime17), "character")
- df <- as.data.frame(pwSurvivalTime17)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime17)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime18 <- getPiecewiseSurvivalTime(median1 = c(2, 3), lambda2 = 0.4)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime18' with expected results
- expect_equal(pwSurvivalTime18$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime18$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$lambda1, c(0.34657359, 0.23104906), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$lambda2, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$hazardRatio, c(0.86643398, 0.57762265), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime18$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime18$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$median1, c(2, 3), label = paste0("c(", paste0(pwSurvivalTime18$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$median2, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime18$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime18$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime18$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime18$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime18$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime18$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime18), NA)))
- expect_output(print(pwSurvivalTime18)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime18), NA)))
- expect_output(summary(pwSurvivalTime18)$show())
- pwSurvivalTime18CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime18, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime18CodeBased$piecewiseSurvivalTime, pwSurvivalTime18$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$lambda1, pwSurvivalTime18$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$lambda2, pwSurvivalTime18$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$hazardRatio, pwSurvivalTime18$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$pi1, pwSurvivalTime18$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$pi2, pwSurvivalTime18$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$median1, pwSurvivalTime18$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$median2, pwSurvivalTime18$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$eventTime, pwSurvivalTime18$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$kappa, pwSurvivalTime18$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime18$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$delayedResponseAllowed, pwSurvivalTime18$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime18CodeBased$delayedResponseEnabled, pwSurvivalTime18$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime18), "character")
- df <- as.data.frame(pwSurvivalTime18)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime18)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime19 <- getPiecewiseSurvivalTime(pi1 = 0.45)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime19' with expected results
- expect_equal(pwSurvivalTime19$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime19$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$lambda1, 0.04981975, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$lambda2, 0.018595296, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$hazardRatio, 2.6791588, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$pi1, 0.45, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$pi2, 0.2, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$median1, 13.9131, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$median2, 37.275405, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime19$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime19$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime19$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime19$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime19$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime19$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime19), NA)))
- expect_output(print(pwSurvivalTime19)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime19), NA)))
- expect_output(summary(pwSurvivalTime19)$show())
- pwSurvivalTime19CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime19, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime19CodeBased$piecewiseSurvivalTime, pwSurvivalTime19$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$lambda1, pwSurvivalTime19$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$lambda2, pwSurvivalTime19$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$hazardRatio, pwSurvivalTime19$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$pi1, pwSurvivalTime19$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$pi2, pwSurvivalTime19$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$median1, pwSurvivalTime19$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$median2, pwSurvivalTime19$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$eventTime, pwSurvivalTime19$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$kappa, pwSurvivalTime19$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime19$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$delayedResponseAllowed, pwSurvivalTime19$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime19CodeBased$delayedResponseEnabled, pwSurvivalTime19$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime19), "character")
- df <- as.data.frame(pwSurvivalTime19)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime19)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime20 <- getPiecewiseSurvivalTime(median1 = c(2, 4), hazardRatio = c(1.4, 0.7))
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime20' with expected results
- expect_equal(pwSurvivalTime20$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$lambda1, c(0.34657359, 0.1732868), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$lambda2, c(0.24755256, 0.24755256), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$hazardRatio, c(1.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$median1, c(2, 4), label = paste0("c(", paste0(pwSurvivalTime20$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$median2, c(2.8, 2.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime20$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime20$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime20$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime20$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime20$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime20), NA)))
- expect_output(print(pwSurvivalTime20)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime20), NA)))
- expect_output(summary(pwSurvivalTime20)$show())
- pwSurvivalTime20CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime20, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime20CodeBased$piecewiseSurvivalTime, pwSurvivalTime20$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$lambda1, pwSurvivalTime20$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$lambda2, pwSurvivalTime20$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$hazardRatio, pwSurvivalTime20$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$pi1, pwSurvivalTime20$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$pi2, pwSurvivalTime20$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$median1, pwSurvivalTime20$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$median2, pwSurvivalTime20$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$eventTime, pwSurvivalTime20$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$kappa, pwSurvivalTime20$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime20$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$delayedResponseAllowed, pwSurvivalTime20$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime20CodeBased$delayedResponseEnabled, pwSurvivalTime20$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime20), "character")
- df <- as.data.frame(pwSurvivalTime20)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime20)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime21 <- getPiecewiseSurvivalTime(median1 = 3, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime21' with expected results
- expect_equal(pwSurvivalTime21$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$lambda1, 0.23104906, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$lambda2, 0.28881133, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$median1, 3, label = paste0("c(", paste0(pwSurvivalTime21$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$median2, 2.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime21$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime21$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime21$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime21$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime21$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime21), NA)))
- expect_output(print(pwSurvivalTime21)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime21), NA)))
- expect_output(summary(pwSurvivalTime21)$show())
- pwSurvivalTime21CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime21, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime21CodeBased$piecewiseSurvivalTime, pwSurvivalTime21$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$lambda1, pwSurvivalTime21$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$lambda2, pwSurvivalTime21$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$hazardRatio, pwSurvivalTime21$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$pi1, pwSurvivalTime21$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$pi2, pwSurvivalTime21$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$median1, pwSurvivalTime21$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$median2, pwSurvivalTime21$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$eventTime, pwSurvivalTime21$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$kappa, pwSurvivalTime21$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime21$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$delayedResponseAllowed, pwSurvivalTime21$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime21CodeBased$delayedResponseEnabled, pwSurvivalTime21$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime21), "character")
- df <- as.data.frame(pwSurvivalTime21)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime21)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- expect_error(getPiecewiseSurvivalTime(median2 = 1.386294, lambda2 = 0.4, hazardRatio = 0.8))
- expect_error(getPiecewiseSurvivalTime(median2 = c(1.5, 1.7), lambda1 = c(0.3, 0.4)))
- expect_error(getPiecewiseSurvivalTime(median1 = c(2, 4), hazardRatio = c(1, 0.7)))
- expect_error(getPiecewiseSurvivalTime(median1 = c(2, 4), hazardRatio = 0.7))
-
-})
-
-test_that("Testing 'getPiecewiseSurvivalTime': vector based definition", {
-
- # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
- pwSurvivalTime1 <- getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 6, 9),
- lambda2 = c(0.025, 0.04, 0.015), hazardRatio = 0.8
- )
- expect_equal(pwSurvivalTime1$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime1$lambda1, c(0.025, 0.04, 0.015) * 0.8)
- expect_false(pwSurvivalTime1$isDelayedResponseEnabled())
-
- .skipTestIfDisabled()
-
- pwSurvivalTime2 <- getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 5, 10),
- lambda2 = c(0.1, 0.2, 0.8), hazardRatio = 0.8
- )
- expect_true(pwSurvivalTime2$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime2$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime2$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, c(0, 5, 10))
- expect_equal(pwSurvivalTime2$lambda2, c(0.1, 0.2, 0.8))
-
- pwSurvivalTime3 <- getPiecewiseSurvivalTime(c(0, 6), lambda2 = c(0.01, 0.03), hazardRatio = 0.8)
- expect_true(pwSurvivalTime3$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime3$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime3$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, c(0, 6))
- expect_equal(pwSurvivalTime3$lambda2, c(0.01, 0.03))
-
- pwSurvivalTime4 <- getPiecewiseSurvivalTime(0, lambda2 = 0.01, hazardRatio = 0.8)
- expect_true(pwSurvivalTime4$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime4$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime4$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime4$piecewiseSurvivalTime, 0)
- expect_equal(pwSurvivalTime4$lambda2, 0.01)
- expect_equal(pwSurvivalTime4$lambda1, 0.01 * 0.8)
-
- pwSurvivalTime5 <- getPiecewiseSurvivalTime(NA_real_, lambda2 = 0.01, hazardRatio = 0.8)
- expect_true(pwSurvivalTime5$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime5$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime5$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime5$piecewiseSurvivalTime, 0)
- expect_equal(pwSurvivalTime5$lambda2, 0.01)
- expect_equal(pwSurvivalTime5$lambda1, 0.01 * 0.8)
-
- pwSurvivalTime6 <- getPiecewiseSurvivalTime(0, lambda2 = 0.01, lambda1 = 0.008)
- expect_true(pwSurvivalTime6$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime6$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime6$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime6$piecewiseSurvivalTime, 0)
- expect_equal(pwSurvivalTime6$lambda2, 0.01)
- expect_equal(pwSurvivalTime6$lambda1, 0.008)
-
- pwSurvivalTime7 <- getPiecewiseSurvivalTime(NA_real_, lambda2 = 0.01, lambda1 = 0.008)
- expect_true(pwSurvivalTime7$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime7$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime7$hazardRatio, 0.8)
- expect_equal(pwSurvivalTime7$piecewiseSurvivalTime, 0)
- expect_equal(pwSurvivalTime7$lambda2, 0.01)
- expect_equal(pwSurvivalTime7$lambda1, 0.008)
-
- # case 2.2
- pwSurvivalTime9 <- getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 6, 9),
- lambda2 = c(0.025, 0.04, 0.015),
- lambda1 = c(0.025, 0.04, 0.015) * 0.8
- )
- expect_true(pwSurvivalTime9$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime9$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime9$hazardRatio, 0.8)
-
- pwSurvivalTime10 <- getPiecewiseSurvivalTime(lambda2 = 0.025, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime10' with expected results
- expect_equal(pwSurvivalTime10$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime10$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime10$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime10), NA)))
- expect_output(print(pwSurvivalTime10)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime10), NA)))
- expect_output(summary(pwSurvivalTime10)$show())
- pwSurvivalTime10CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime10, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalTime, pwSurvivalTime10$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$lambda1, pwSurvivalTime10$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$lambda2, pwSurvivalTime10$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$hazardRatio, pwSurvivalTime10$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$pi1, pwSurvivalTime10$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$pi2, pwSurvivalTime10$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$median1, pwSurvivalTime10$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$median2, pwSurvivalTime10$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$eventTime, pwSurvivalTime10$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$kappa, pwSurvivalTime10$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime10$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$delayedResponseAllowed, pwSurvivalTime10$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime10CodeBased$delayedResponseEnabled, pwSurvivalTime10$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime10), "character")
- df <- as.data.frame(pwSurvivalTime10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime11 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = 0, lambda2 = 0.025, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime11' with expected results
- expect_equal(pwSurvivalTime11$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime11$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime11$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime11), NA)))
- expect_output(print(pwSurvivalTime11)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime11), NA)))
- expect_output(summary(pwSurvivalTime11)$show())
- pwSurvivalTime11CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime11, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalTime, pwSurvivalTime11$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$lambda1, pwSurvivalTime11$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$lambda2, pwSurvivalTime11$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$hazardRatio, pwSurvivalTime11$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$pi1, pwSurvivalTime11$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$pi2, pwSurvivalTime11$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$median1, pwSurvivalTime11$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$median2, pwSurvivalTime11$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$eventTime, pwSurvivalTime11$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$kappa, pwSurvivalTime11$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime11$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$delayedResponseAllowed, pwSurvivalTime11$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime11CodeBased$delayedResponseEnabled, pwSurvivalTime11$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime11), "character")
- df <- as.data.frame(pwSurvivalTime11)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime11)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime12 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = c(0.025, 0.01), hazardRatio = c(0.8, 0.9))
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime12' with expected results
- expect_equal(pwSurvivalTime12$piecewiseSurvivalTime, c(0, 6), label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$lambda1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$lambda2, c(0.025, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$hazardRatio, c(0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$median1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$median2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime12$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$piecewiseSurvivalEnabled, TRUE, label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime12$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime12), NA)))
- expect_output(print(pwSurvivalTime12)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime12), NA)))
- expect_output(summary(pwSurvivalTime12)$show())
- pwSurvivalTime12CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime12, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalTime, pwSurvivalTime12$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$lambda1, pwSurvivalTime12$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$lambda2, pwSurvivalTime12$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$hazardRatio, pwSurvivalTime12$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$pi1, pwSurvivalTime12$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$pi2, pwSurvivalTime12$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$median1, pwSurvivalTime12$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$median2, pwSurvivalTime12$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$eventTime, pwSurvivalTime12$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$kappa, pwSurvivalTime12$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime12$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$delayedResponseAllowed, pwSurvivalTime12$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime12CodeBased$delayedResponseEnabled, pwSurvivalTime12$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime12), "character")
- df <- as.data.frame(pwSurvivalTime12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime13 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = c(0.025, 0.01), hazardRatio = c(0.8, 0.9), delayedResponseAllowed = TRUE)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime13' with expected results
- expect_equal(pwSurvivalTime13$piecewiseSurvivalTime, c(0, 6), label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$lambda1, c(0.02, 0.009), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$lambda2, c(0.025, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$hazardRatio, c(0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$median1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$median2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime13$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$piecewiseSurvivalEnabled, TRUE, label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$delayedResponseAllowed, TRUE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime13$delayedResponseEnabled, TRUE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime13), NA)))
- expect_output(print(pwSurvivalTime13)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime13), NA)))
- expect_output(summary(pwSurvivalTime13)$show())
- pwSurvivalTime13CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime13, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalTime, pwSurvivalTime13$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$lambda1, pwSurvivalTime13$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$lambda2, pwSurvivalTime13$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$hazardRatio, pwSurvivalTime13$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$pi1, pwSurvivalTime13$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$pi2, pwSurvivalTime13$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$median1, pwSurvivalTime13$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$median2, pwSurvivalTime13$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$eventTime, pwSurvivalTime13$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$kappa, pwSurvivalTime13$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime13$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$delayedResponseAllowed, pwSurvivalTime13$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime13CodeBased$delayedResponseEnabled, pwSurvivalTime13$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime13), "character")
- df <- as.data.frame(pwSurvivalTime13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- # case 2.2: error expected
- expect_error(getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 6, 9),
- lambda2 = c(0.025, 0.04, 0.015),
- lambda1 = c(0.03, 0.04, 0.025)
- ),
- paste0(
- "Illegal argument: 'hazardRatio' can only be calculated if ",
- "'unique(lambda1 / lambda2)' result in a single value; ",
- "current result = c(1.2, 1, 1.667) (e.g., delayed response is not allowed)"
- ),
- fixed = TRUE
- )
-
- # case 3
- expect_false(getPiecewiseSurvivalTime(delayedResponseAllowed = TRUE)$isPiecewiseSurvivalEnabled())
- expect_false(getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = NA,
- delayedResponseAllowed = TRUE
- )$isPiecewiseSurvivalEnabled())
-
- # case 3.1
- pwSurvivalTimeSim1 <- getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 6, 9),
- lambda2 = c(0.025, 0.04, 0.015), hazardRatio = 0.8,
- delayedResponseAllowed = TRUE
- )
- expect_equal(pwSurvivalTimeSim1$hazardRatio, 0.8)
- expect_equal(pwSurvivalTimeSim1$lambda1, c(0.025, 0.04, 0.015) * 0.8)
- expect_false(pwSurvivalTimeSim1$isDelayedResponseEnabled())
-
- # case 3.2
- pwSurvivalTimeSim2 <- getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 6, 9),
- lambda2 = c(0.025, 0.04, 0.015),
- lambda1 = c(0.03, 0.04, 0.025), delayedResponseAllowed = TRUE
- )
- expect_true(pwSurvivalTimeSim2$isPiecewiseSurvivalEnabled())
- expect_true(pwSurvivalTimeSim2$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTimeSim2$hazardRatio, c(1.2, 1, 5 / 3))
-
- pwsTime1 <- getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4)
- expect_equal(pwsTime1$.isLambdaBased(minNumberOfLambdas = 1), TRUE)
-
-})
-
-test_that("Testing 'getPiecewiseSurvivalTime': check error and warnings", {
-
- # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
- expect_error(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4, pi2 = 0.4),
- "Conflicting arguments: it is not allowed to specify 'pi2' (0.4) and 'lambda2' (0.4) concurrently",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4, pi2 = 0.4, pi1 = 0.3),
- "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda2' (0.4) concurrently",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4, pi2 = 0.4, pi1 = 0.3),
- "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda2' (0.4) concurrently",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(lambda2 = 0.4, lambda1 = 0.3, pi2 = 0.4, pi1 = 0.3),
- "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda1' (0.3) concurrently",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(lambda2 = 0.4, lambda1 = 0.3, pi2 = 0.4, pi1 = 0.3),
- "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda1' (0.3) concurrently",
- fixed = TRUE
- )
-
- expect_equal(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi2 = 0.4)$.isPiBased(), TRUE)
-
- expect_warning(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi2 = 0.4, pi1 = 0.3),
- "'hazardRatio' (0.6, 0.8) will be ignored because it will be calculated",
- fixed = TRUE
- )
-
- expect_warning(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi1 = 0.3),
- "'hazardRatio' (0.6, 0.8) will be ignored because it will be calculated",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = 0.025, hazardRatio = 0.8, delayedResponseAllowed = TRUE),
- "Illegal argument: length of 'piecewiseSurvivalTime' (2) and length of 'lambda2' (1) must be equal",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6, 12), lambda2 = 0.025, hazardRatio = 0.8, delayedResponseAllowed = TRUE),
- "Illegal argument: length of 'piecewiseSurvivalTime' (3) and length of 'lambda2' (1) must be equal",
- fixed = TRUE
- )
-
- expect_error(getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = 0.025, hazardRatio = 0.8),
- "Illegal argument: length of 'piecewiseSurvivalTime' (2) and length of 'lambda2' (1) must be equal",
- fixed = TRUE
- )
-
-})
-
-test_that("Testing 'getPiecewiseSurvivalTime': list-wise definition", {
-
- # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
- pwSurvivalTime8 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list(
- "<6" = 0.025,
- "6 - <9" = 0.04,
- "9 - <15" = 0.015,
- "15 - <21" = 0.01,
- ">=21" = 0.007
- ), hazardRatio = 0.6)
- expect_true(pwSurvivalTime8$isPiecewiseSurvivalEnabled())
- expect_false(pwSurvivalTime8$isDelayedResponseEnabled())
- expect_equal(pwSurvivalTime8$hazardRatio, 0.6)
- expect_equal(pwSurvivalTime8$piecewiseSurvivalTime, c(0, 6, 9, 15, 21))
- expect_equal(pwSurvivalTime8$lambda2, c(0.025, 0.040, 0.015, 0.010, 0.007))
- expect_equal(pwSurvivalTime8$lambda1, c(0.0150, 0.0240, 0.0090, 0.0060, 0.0042))
-
- .skipTestIfDisabled()
-
- result1 <- getPiecewiseSurvivalTime(list(
- "<5" = 0.1,
- "5 - <10" = 0.2,
- ">=10" = 0.8
- ), hazardRatio = 0.8)
- expect_equal(result1$piecewiseSurvivalTime, c(0, 5, 10))
- expect_equal(result1$lambda2, c(0.1, 0.2, 0.8))
-
- result2 <- getPiecewiseSurvivalTime(list(
- "0 - <5" = 0.1,
- "5 - <10" = 0.2,
- "10 - Inf" = 0.8
- ), hazardRatio = 0.8)
- expect_equal(result2$piecewiseSurvivalTime, c(0, 5, 10))
- expect_equal(result2$lambda2, c(0.1, 0.2, 0.8))
-
- pwSurvivalTime2 <- getPiecewiseSurvivalTime(
- piecewiseSurvivalTime = c(0, 5, 10),
- lambda2 = c(0.1, 0.2, 0.8), hazardRatio = 0.8
- )
- expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, c(0, 5, 10))
- expect_equal(pwSurvivalTime2$lambda2, c(0.1, 0.2, 0.8))
-
- pwSurvivalTime3 <- getPiecewiseSurvivalTime(c(0, 6), lambda2 = c(0.01, 0.03), hazardRatio = 0.8)
- expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, c(0, 6))
- expect_equal(pwSurvivalTime3$lambda2, c(0.01, 0.03))
-
- pwSurvivalTime4 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("0 - ?" = 0.025),
- hazardRatio = 0.8, delayedResponseAllowed = TRUE)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime4' with expected results
- expect_equal(pwSurvivalTime4$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime4$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime4$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime4$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime4$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime4$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime4$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$delayedResponseAllowed, TRUE, label = paste0("c(", paste0(pwSurvivalTime4$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime4$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime4$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime4), NA)))
- expect_output(print(pwSurvivalTime4)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime4), NA)))
- expect_output(summary(pwSurvivalTime4)$show())
- pwSurvivalTime4CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime4, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime4CodeBased$piecewiseSurvivalTime, pwSurvivalTime4$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$lambda1, pwSurvivalTime4$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$lambda2, pwSurvivalTime4$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$hazardRatio, pwSurvivalTime4$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$pi1, pwSurvivalTime4$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$pi2, pwSurvivalTime4$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$median1, pwSurvivalTime4$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$median2, pwSurvivalTime4$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$eventTime, pwSurvivalTime4$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$kappa, pwSurvivalTime4$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime4$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$delayedResponseAllowed, pwSurvivalTime4$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime4CodeBased$delayedResponseEnabled, pwSurvivalTime4$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime4), "character")
- df <- as.data.frame(pwSurvivalTime4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime5 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("x" = 0.025),
- hazardRatio = 0.8, delayedResponseAllowed = TRUE)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime5' with expected results
- expect_equal(pwSurvivalTime5$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime5$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime5$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime5$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime5$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime5$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime5$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$delayedResponseAllowed, TRUE, label = paste0("c(", paste0(pwSurvivalTime5$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime5$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime5$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime5), NA)))
- expect_output(print(pwSurvivalTime5)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime5), NA)))
- expect_output(summary(pwSurvivalTime5)$show())
- pwSurvivalTime5CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime5, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime5CodeBased$piecewiseSurvivalTime, pwSurvivalTime5$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$lambda1, pwSurvivalTime5$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$lambda2, pwSurvivalTime5$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$hazardRatio, pwSurvivalTime5$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$pi1, pwSurvivalTime5$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$pi2, pwSurvivalTime5$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$median1, pwSurvivalTime5$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$median2, pwSurvivalTime5$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$eventTime, pwSurvivalTime5$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$kappa, pwSurvivalTime5$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime5$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$delayedResponseAllowed, pwSurvivalTime5$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime5CodeBased$delayedResponseEnabled, pwSurvivalTime5$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime5), "character")
- df <- as.data.frame(pwSurvivalTime5)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime5)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime6 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("0 - 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime6)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime7 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("x" = 0.025),
- hazardRatio = 0.8, delayedResponseAllowed = FALSE)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime7' with expected results
- expect_equal(pwSurvivalTime7$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime7$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime7$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime7$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime7$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime7$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime7$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime7$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime7$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime7$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime7), NA)))
- expect_output(print(pwSurvivalTime7)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime7), NA)))
- expect_output(summary(pwSurvivalTime7)$show())
- pwSurvivalTime7CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime7, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime7CodeBased$piecewiseSurvivalTime, pwSurvivalTime7$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$lambda1, pwSurvivalTime7$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$lambda2, pwSurvivalTime7$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$hazardRatio, pwSurvivalTime7$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$pi1, pwSurvivalTime7$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$pi2, pwSurvivalTime7$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$median1, pwSurvivalTime7$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$median2, pwSurvivalTime7$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$eventTime, pwSurvivalTime7$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$kappa, pwSurvivalTime7$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime7$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$delayedResponseAllowed, pwSurvivalTime7$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime7CodeBased$delayedResponseEnabled, pwSurvivalTime7$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime7), "character")
- df <- as.data.frame(pwSurvivalTime7)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime7)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime8 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("0 - 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- expect_warning(getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("<6" = 0.025), hazardRatio = 0.8),
- "Defined time period \"0 - <6\" will be ignored because 'piecewiseSurvivalTime' list has only 1 entry",
- fixed = TRUE
- )
-
-})
-
-test_plan_section("Testing Class 'AccrualTime'")
-
-
-test_that("Testing 'getAccrualTime': isAccrualTimeEnabled()", {
- expect_true(getAccrualTime()$isAccrualTimeEnabled())
- expect_true(getAccrualTime(maxNumberOfSubjects = 100)$isAccrualTimeEnabled())
-
-})
-
-test_that("Testing 'getAccrualTime': vector based definition", {
-
- accrualTime1 <- getAccrualTime(
- accrualTime = c(0, 6, 9, 15),
- accrualIntensity = c(15, 21, 27), maxNumberOfSubjects = 315
- )
- expect_equal(accrualTime1$accrualTime, c(0, 6, 9, 15))
- expect_equal(accrualTime1$accrualIntensity, c(15, 21, 27))
- expect_equal(accrualTime1$remainingTime, NA_real_)
-
- accrualTime2 <- getAccrualTime(
- accrualTime = c(0, 6, 9),
- accrualIntensity = c(15, 21, 27), maxNumberOfSubjects = 1000
- )
- expect_equal(accrualTime2$accrualTime, c(0, 6, 9, 40.37037))
- expect_equal(accrualTime2$accrualIntensity, c(15, 21, 27))
- expect_equal(accrualTime2$remainingTime, 31.37037)
-
- .skipTestIfDisabled()
-
- accrualTime3 <- getAccrualTime(
- accrualTime = c(0, 12, 13, 14, 15, 16),
- accrualIntensity = c(15, 21, 27, 33, 39, 45), maxNumberOfSubjects = 1405
- )
- expect_equal(accrualTime3$accrualTime, c(0, 12, 13, 14, 15, 16, 40.55555556))
- expect_equal(accrualTime3$accrualIntensity, c(15, 21, 27, 33, 39, 45))
- expect_equal(accrualTime3$remainingTime, 24.55555556)
-
- accrualTime4 <- getAccrualTime(
- accrualTime = c(0, 24),
- accrualIntensity = c(30), maxNumberOfSubjects = 720
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime4' with expected results
- expect_equal(accrualTime4$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime4$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime4$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime4$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime4$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime4$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime4$accrualTime, c(0, 24), label = paste0("c(", paste0(accrualTime4$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime4$accrualIntensity, 30, label = paste0("c(", paste0(accrualTime4$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime4$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime4$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime4$maxNumberOfSubjects, 720, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime4$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime4$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime4$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime4$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime4), NA)))
- expect_output(print(accrualTime4)$show())
- invisible(capture.output(expect_error(summary(accrualTime4), NA)))
- expect_output(summary(accrualTime4)$show())
- accrualTime4CodeBased <- eval(parse(text = getObjectRCode(accrualTime4, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime4CodeBased$endOfAccrualIsUserDefined, accrualTime4$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$followUpTimeMustBeUserDefined, accrualTime4$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime4$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$absoluteAccrualIntensityEnabled, accrualTime4$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$accrualTime, accrualTime4$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$accrualIntensity, accrualTime4$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$accrualIntensityRelative, accrualTime4$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$maxNumberOfSubjects, accrualTime4$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$remainingTime, accrualTime4$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$piecewiseAccrualEnabled, accrualTime4$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime4), "character")
- df <- as.data.frame(accrualTime4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime5 <- getAccrualTime(
- accrualTime = c(0, 24, 30),
- accrualIntensity = c(30, 45)
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime5' with expected results
- expect_equal(accrualTime5$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime5$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime5$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime5$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime5$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime5$accrualTime, c(0, 24, 30), label = paste0("c(", paste0(accrualTime5$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime5$accrualIntensity, c(30, 45), label = paste0("c(", paste0(accrualTime5$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime5$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime5$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime5$maxNumberOfSubjects, 990, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime5$remainingTime, 6, label = paste0("c(", paste0(accrualTime5$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime5$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime5), NA)))
- expect_output(print(accrualTime5)$show())
- invisible(capture.output(expect_error(summary(accrualTime5), NA)))
- expect_output(summary(accrualTime5)$show())
- accrualTime5CodeBased <- eval(parse(text = getObjectRCode(accrualTime5, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime5CodeBased$endOfAccrualIsUserDefined, accrualTime5$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$followUpTimeMustBeUserDefined, accrualTime5$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime5$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$absoluteAccrualIntensityEnabled, accrualTime5$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$accrualTime, accrualTime5$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$accrualIntensity, accrualTime5$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$accrualIntensityRelative, accrualTime5$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$maxNumberOfSubjects, accrualTime5$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$remainingTime, accrualTime5$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$piecewiseAccrualEnabled, accrualTime5$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime5), "character")
- df <- as.data.frame(accrualTime5)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime5)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime6 <- getAccrualTime(
- accrualTime = c(0, 24, 30),
- accrualIntensity = c(20, 25, 45), maxNumberOfSubjects = 720
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime6' with expected results
- expect_equal(accrualTime6$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime6$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime6$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime6$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime6$accrualTime, c(0, 24, 30, 32), label = paste0("c(", paste0(accrualTime6$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime6$accrualIntensity, c(20, 25, 45), label = paste0("c(", paste0(accrualTime6$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime6$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime6$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime6$maxNumberOfSubjects, 720, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime6$remainingTime, 2, label = paste0("c(", paste0(accrualTime6$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime6$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime6), NA)))
- expect_output(print(accrualTime6)$show())
- invisible(capture.output(expect_error(summary(accrualTime6), NA)))
- expect_output(summary(accrualTime6)$show())
- accrualTime6CodeBased <- eval(parse(text = getObjectRCode(accrualTime6, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime6CodeBased$endOfAccrualIsUserDefined, accrualTime6$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$followUpTimeMustBeUserDefined, accrualTime6$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime6$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$absoluteAccrualIntensityEnabled, accrualTime6$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$accrualTime, accrualTime6$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$accrualIntensity, accrualTime6$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$accrualIntensityRelative, accrualTime6$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$maxNumberOfSubjects, accrualTime6$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$remainingTime, accrualTime6$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$piecewiseAccrualEnabled, accrualTime6$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime6), "character")
- df <- as.data.frame(accrualTime6)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime6)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime8 <- getAccrualTime(accrualTime = 0, accrualIntensity = 15, maxNumberOfSubjects = 1000)
-
- ## Comparison of the results of AccrualTime object 'accrualTime8' with expected results
- expect_equal(accrualTime8$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime8$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime8$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime8$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime8$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime8$accrualTime, c(0, 66.666667), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime8$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime8$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime8$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime8$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime8$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime8$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime8$remainingTime, 66.666667, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime8$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime8$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime8$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime8), NA)))
- expect_output(print(accrualTime8)$show())
- invisible(capture.output(expect_error(summary(accrualTime8), NA)))
- expect_output(summary(accrualTime8)$show())
- accrualTime8CodeBased <- eval(parse(text = getObjectRCode(accrualTime8, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime8CodeBased$endOfAccrualIsUserDefined, accrualTime8$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$followUpTimeMustBeUserDefined, accrualTime8$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime8$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$absoluteAccrualIntensityEnabled, accrualTime8$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$accrualTime, accrualTime8$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$accrualIntensity, accrualTime8$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$accrualIntensityRelative, accrualTime8$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$maxNumberOfSubjects, accrualTime8$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$remainingTime, accrualTime8$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$piecewiseAccrualEnabled, accrualTime8$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime8), "character")
- df <- as.data.frame(accrualTime8)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime9 <- getAccrualTime(accrualTime = c(0, 5), accrualIntensity = 15)
-
- ## Comparison of the results of AccrualTime object 'accrualTime9' with expected results
- expect_equal(accrualTime9$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime9$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime9$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime9$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime9$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime9$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime9$accrualTime, c(0, 5), label = paste0("c(", paste0(accrualTime9$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime9$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime9$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime9$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime9$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime9$maxNumberOfSubjects, 75, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime9$remainingTime, 5, label = paste0("c(", paste0(accrualTime9$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime9$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime9$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime9), NA)))
- expect_output(print(accrualTime9)$show())
- invisible(capture.output(expect_error(summary(accrualTime9), NA)))
- expect_output(summary(accrualTime9)$show())
- accrualTime9CodeBased <- eval(parse(text = getObjectRCode(accrualTime9, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime9CodeBased$endOfAccrualIsUserDefined, accrualTime9$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$followUpTimeMustBeUserDefined, accrualTime9$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime9$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$absoluteAccrualIntensityEnabled, accrualTime9$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$accrualTime, accrualTime9$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$accrualIntensity, accrualTime9$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$accrualIntensityRelative, accrualTime9$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$maxNumberOfSubjects, accrualTime9$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$remainingTime, accrualTime9$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$piecewiseAccrualEnabled, accrualTime9$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime9), "character")
- df <- as.data.frame(accrualTime9)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime9)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime10 <- getAccrualTime(accrualTime = 0, accrualIntensity = 15, maxNumberOfSubjects = 10)
-
- ## Comparison of the results of AccrualTime object 'accrualTime10' with expected results
- expect_equal(accrualTime10$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime10$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime10$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime10$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime10$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime10$accrualTime, c(0, 0.66666667), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime10$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime10$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime10$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime10$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime10$maxNumberOfSubjects, 10, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime10$remainingTime, 0.66666667, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime10$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime10$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime10), NA)))
- expect_output(print(accrualTime10)$show())
- invisible(capture.output(expect_error(summary(accrualTime10), NA)))
- expect_output(summary(accrualTime10)$show())
- accrualTime10CodeBased <- eval(parse(text = getObjectRCode(accrualTime10, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime10CodeBased$endOfAccrualIsUserDefined, accrualTime10$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$followUpTimeMustBeUserDefined, accrualTime10$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime10$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$absoluteAccrualIntensityEnabled, accrualTime10$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$accrualTime, accrualTime10$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$accrualIntensity, accrualTime10$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$accrualIntensityRelative, accrualTime10$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$maxNumberOfSubjects, accrualTime10$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$remainingTime, accrualTime10$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$piecewiseAccrualEnabled, accrualTime10$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime10), "character")
- df <- as.data.frame(accrualTime10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime11 <- getAccrualTime(accrualTime = c(0, 5), accrualIntensity = 15, maxNumberOfSubjects = 75)
-
- ## Comparison of the results of AccrualTime object 'accrualTime11' with expected results
- expect_equal(accrualTime11$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime11$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime11$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime11$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime11$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime11$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime11$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime11$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime11$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime11$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime11$accrualTime, c(0, 5), label = paste0("c(", paste0(accrualTime11$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime11$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime11$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime11$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime11$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime11$maxNumberOfSubjects, 75, label = paste0("c(", paste0(accrualTime11$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime11$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime11$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime11$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime11$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime11), NA)))
- expect_output(print(accrualTime11)$show())
- invisible(capture.output(expect_error(summary(accrualTime11), NA)))
- expect_output(summary(accrualTime11)$show())
- accrualTime11CodeBased <- eval(parse(text = getObjectRCode(accrualTime11, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime11CodeBased$endOfAccrualIsUserDefined, accrualTime11$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$followUpTimeMustBeUserDefined, accrualTime11$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime11$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime11$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$absoluteAccrualIntensityEnabled, accrualTime11$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$accrualTime, accrualTime11$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$accrualIntensity, accrualTime11$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$accrualIntensityRelative, accrualTime11$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$maxNumberOfSubjects, accrualTime11$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$remainingTime, accrualTime11$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime11CodeBased$piecewiseAccrualEnabled, accrualTime11$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime11), "character")
- df <- as.data.frame(accrualTime11)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime11)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime12 <- getAccrualTime(accrualTime = c(0, 6, 15, 25), accrualIntensity = c(22, 0, 33))
-
- ## Comparison of the results of AccrualTime object 'accrualTime12' with expected results
- expect_equal(accrualTime12$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime12$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime12$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime12$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime12$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime12$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime12$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime12$accrualTime, c(0, 6, 15, 25), label = paste0("c(", paste0(accrualTime12$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime12$accrualIntensity, c(22, 0, 33), label = paste0("c(", paste0(accrualTime12$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime12$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime12$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime12$maxNumberOfSubjects, 462, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime12$remainingTime, 10, label = paste0("c(", paste0(accrualTime12$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime12$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime12$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime12), NA)))
- expect_output(print(accrualTime12)$show())
- invisible(capture.output(expect_error(summary(accrualTime12), NA)))
- expect_output(summary(accrualTime12)$show())
- accrualTime12CodeBased <- eval(parse(text = getObjectRCode(accrualTime12, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime12CodeBased$endOfAccrualIsUserDefined, accrualTime12$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$followUpTimeMustBeUserDefined, accrualTime12$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime12$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$absoluteAccrualIntensityEnabled, accrualTime12$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$accrualTime, accrualTime12$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$accrualIntensity, accrualTime12$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$accrualIntensityRelative, accrualTime12$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$maxNumberOfSubjects, accrualTime12$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$remainingTime, accrualTime12$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$piecewiseAccrualEnabled, accrualTime12$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime12), "character")
- df <- as.data.frame(accrualTime12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime13 <- getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(22, 33), maxNumberOfSubjects = 1000)
-
- ## Comparison of the results of AccrualTime object 'accrualTime13' with expected results
- expect_equal(accrualTime13$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime13$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime13$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime13$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime13$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime13$accrualTime, c(0, 6, 32.30303), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime13$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime13$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime13$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime13$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime13$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime13$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime13$remainingTime, 26.30303, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime13$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime13$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime13$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime13), NA)))
- expect_output(print(accrualTime13)$show())
- invisible(capture.output(expect_error(summary(accrualTime13), NA)))
- expect_output(summary(accrualTime13)$show())
- accrualTime13CodeBased <- eval(parse(text = getObjectRCode(accrualTime13, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime13CodeBased$endOfAccrualIsUserDefined, accrualTime13$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$followUpTimeMustBeUserDefined, accrualTime13$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime13$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$absoluteAccrualIntensityEnabled, accrualTime13$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$accrualTime, accrualTime13$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$accrualIntensity, accrualTime13$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$accrualIntensityRelative, accrualTime13$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$maxNumberOfSubjects, accrualTime13$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$remainingTime, accrualTime13$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$piecewiseAccrualEnabled, accrualTime13$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime13), "character")
- df <- as.data.frame(accrualTime13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
-})
-
-test_that("Testing 'getAccrualTime': test absolute and relative definition", {
-
- # @refFS[Tab.]{fs:tab:output:getAccrualTime}
- accrualTime1 <- getAccrualTime(
- accrualTime = c(0, 6, 30),
- accrualIntensity = c(22, 33), maxNumberOfSubjects = 924
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime1' with expected results
- expect_equal(accrualTime1$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime1$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime1$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime1$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime1$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime1$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime1$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime1$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime1$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime1$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime1$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime1$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime1$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime1$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime1$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime1$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime1$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime1$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime1$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime1$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime1$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime1$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime1), NA)))
- expect_output(print(accrualTime1)$show())
- invisible(capture.output(expect_error(summary(accrualTime1), NA)))
- expect_output(summary(accrualTime1)$show())
- accrualTime1CodeBased <- eval(parse(text = getObjectRCode(accrualTime1, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime1CodeBased$endOfAccrualIsUserDefined, accrualTime1$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$followUpTimeMustBeUserDefined, accrualTime1$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime1$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime1$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$absoluteAccrualIntensityEnabled, accrualTime1$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$accrualTime, accrualTime1$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$accrualIntensity, accrualTime1$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$accrualIntensityRelative, accrualTime1$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$maxNumberOfSubjects, accrualTime1$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$remainingTime, accrualTime1$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime1CodeBased$piecewiseAccrualEnabled, accrualTime1$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime1), "character")
- df <- as.data.frame(accrualTime1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime2 <- getAccrualTime(list(
- "0 - <6" = 22,
- "6 - <=30" = 33
- ),
- maxNumberOfSubjects = 924
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime2' with expected results
- expect_equal(accrualTime2$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime2$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime2$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime2$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime2$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime2$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime2$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime2$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime2$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime2$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime2$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime2$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime2$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime2$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime2$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime2$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime2$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime2$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime2$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime2$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime2$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime2$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime2), NA)))
- expect_output(print(accrualTime2)$show())
- invisible(capture.output(expect_error(summary(accrualTime2), NA)))
- expect_output(summary(accrualTime2)$show())
- accrualTime2CodeBased <- eval(parse(text = getObjectRCode(accrualTime2, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime2CodeBased$endOfAccrualIsUserDefined, accrualTime2$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$followUpTimeMustBeUserDefined, accrualTime2$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime2$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime2$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$absoluteAccrualIntensityEnabled, accrualTime2$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$accrualTime, accrualTime2$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$accrualIntensity, accrualTime2$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$accrualIntensityRelative, accrualTime2$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$maxNumberOfSubjects, accrualTime2$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$remainingTime, accrualTime2$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime2CodeBased$piecewiseAccrualEnabled, accrualTime2$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime2), "character")
- df <- as.data.frame(accrualTime2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- .skipTestIfDisabled()
-
- accrualTime3 <- getAccrualTime(
- accrualTime = c(0, 6, 30),
- accrualIntensity = c(0.22, 0.33), maxNumberOfSubjects = 1000
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime3' with expected results
- expect_equal(accrualTime3$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime3$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime3$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime3$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime3$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime3$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime3$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime3$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime3$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime3$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime3$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime3$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime3$accrualIntensity, c(23.809524, 35.714286), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime3$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime3$accrualIntensityRelative, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime3$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime3$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime3$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime3$remainingTime, 24, label = paste0("c(", paste0(accrualTime3$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime3$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime3$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime3), NA)))
- expect_output(print(accrualTime3)$show())
- invisible(capture.output(expect_error(summary(accrualTime3), NA)))
- expect_output(summary(accrualTime3)$show())
- accrualTime3CodeBased <- eval(parse(text = getObjectRCode(accrualTime3, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime3CodeBased$endOfAccrualIsUserDefined, accrualTime3$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$followUpTimeMustBeUserDefined, accrualTime3$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime3$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime3$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$absoluteAccrualIntensityEnabled, accrualTime3$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$accrualTime, accrualTime3$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$accrualIntensity, accrualTime3$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$accrualIntensityRelative, accrualTime3$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$maxNumberOfSubjects, accrualTime3$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$remainingTime, accrualTime3$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime3CodeBased$piecewiseAccrualEnabled, accrualTime3$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime3), "character")
- df <- as.data.frame(accrualTime3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime4 <- getAccrualTime(list(
- "0 - <6" = 0.22,
- "6 - <=30" = 0.33
- ),
- maxNumberOfSubjects = 1000
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime4' with expected results
- expect_equal(accrualTime4$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime4$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime4$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime4$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime4$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime4$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime4$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime4$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime4$accrualIntensity, c(23.809524, 35.714286), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime4$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime4$accrualIntensityRelative, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime4$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime4$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime4$remainingTime, 24, label = paste0("c(", paste0(accrualTime4$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime4$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime4$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime4), NA)))
- expect_output(print(accrualTime4)$show())
- invisible(capture.output(expect_error(summary(accrualTime4), NA)))
- expect_output(summary(accrualTime4)$show())
- accrualTime4CodeBased <- eval(parse(text = getObjectRCode(accrualTime4, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime4CodeBased$endOfAccrualIsUserDefined, accrualTime4$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$followUpTimeMustBeUserDefined, accrualTime4$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime4$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$absoluteAccrualIntensityEnabled, accrualTime4$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$accrualTime, accrualTime4$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$accrualIntensity, accrualTime4$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$accrualIntensityRelative, accrualTime4$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$maxNumberOfSubjects, accrualTime4$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$remainingTime, accrualTime4$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime4CodeBased$piecewiseAccrualEnabled, accrualTime4$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime4), "character")
- df <- as.data.frame(accrualTime4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime5 <- getAccrualTime(accrualTime = c(0, 6, 30), accrualIntensity = c(22, 33))
-
- ## Comparison of the results of AccrualTime object 'accrualTime5' with expected results
- expect_equal(accrualTime5$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime5$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime5$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime5$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime5$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime5$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime5$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime5$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime5$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime5$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime5$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime5$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime5$remainingTime, 24, label = paste0("c(", paste0(accrualTime5$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime5$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime5), NA)))
- expect_output(print(accrualTime5)$show())
- invisible(capture.output(expect_error(summary(accrualTime5), NA)))
- expect_output(summary(accrualTime5)$show())
- accrualTime5CodeBased <- eval(parse(text = getObjectRCode(accrualTime5, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime5CodeBased$endOfAccrualIsUserDefined, accrualTime5$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$followUpTimeMustBeUserDefined, accrualTime5$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime5$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$absoluteAccrualIntensityEnabled, accrualTime5$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$accrualTime, accrualTime5$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$accrualIntensity, accrualTime5$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$accrualIntensityRelative, accrualTime5$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$maxNumberOfSubjects, accrualTime5$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$remainingTime, accrualTime5$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime5CodeBased$piecewiseAccrualEnabled, accrualTime5$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime5), "character")
- df <- as.data.frame(accrualTime5)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime5)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime6 <- getAccrualTime(list(
- "0 - <6" = 22,
- "6 - <=30" = 33
- ))
-
- ## Comparison of the results of AccrualTime object 'accrualTime6' with expected results
- expect_equal(accrualTime6$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime6$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime6$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime6$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime6$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime6$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime6$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime6$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime6$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime6$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime6$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime6$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime6$remainingTime, 24, label = paste0("c(", paste0(accrualTime6$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime6$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime6), NA)))
- expect_output(print(accrualTime6)$show())
- invisible(capture.output(expect_error(summary(accrualTime6), NA)))
- expect_output(summary(accrualTime6)$show())
- accrualTime6CodeBased <- eval(parse(text = getObjectRCode(accrualTime6, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime6CodeBased$endOfAccrualIsUserDefined, accrualTime6$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$followUpTimeMustBeUserDefined, accrualTime6$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime6$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$absoluteAccrualIntensityEnabled, accrualTime6$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$accrualTime, accrualTime6$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$accrualIntensity, accrualTime6$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$accrualIntensityRelative, accrualTime6$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$maxNumberOfSubjects, accrualTime6$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$remainingTime, accrualTime6$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime6CodeBased$piecewiseAccrualEnabled, accrualTime6$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime6), "character")
- df <- as.data.frame(accrualTime6)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime6)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime7 <- getAccrualTime(accrualTime = c(0, 6, 30), accrualIntensity = c(0.22, 0.33))
-
- ## Comparison of the results of AccrualTime object 'accrualTime7' with expected results
- expect_equal(accrualTime7$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime7$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime7$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime7$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime7$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime7$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime7$maxNumberOfSubjectsCanBeCalculatedDirectly, FALSE, label = paste0("c(", paste0(accrualTime7$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime7$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime7$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime7$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime7$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime7$accrualIntensity, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime7$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime7$accrualIntensityRelative, c(0.22, 0.33), label = paste0("c(", paste0(accrualTime7$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime7$maxNumberOfSubjects, NA_real_, label = paste0("c(", paste0(accrualTime7$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime7$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime7$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime7$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime7$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime7), NA)))
- expect_output(print(accrualTime7)$show())
- invisible(capture.output(expect_error(summary(accrualTime7), NA)))
- expect_output(summary(accrualTime7)$show())
- accrualTime7CodeBased <- eval(parse(text = getObjectRCode(accrualTime7, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime7CodeBased$endOfAccrualIsUserDefined, accrualTime7$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$followUpTimeMustBeUserDefined, accrualTime7$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime7$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime7$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$absoluteAccrualIntensityEnabled, accrualTime7$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$accrualTime, accrualTime7$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$accrualIntensity, accrualTime7$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$accrualIntensityRelative, accrualTime7$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$maxNumberOfSubjects, accrualTime7$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$remainingTime, accrualTime7$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime7CodeBased$piecewiseAccrualEnabled, accrualTime7$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime7), "character")
- df <- as.data.frame(accrualTime7)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime7)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime8 <- getAccrualTime(list(
- "0 - <6" = 0.22,
- "6 - <=30" = 0.33
- ))
-
- ## Comparison of the results of AccrualTime object 'accrualTime8' with expected results
- expect_equal(accrualTime8$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime8$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime8$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime8$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, FALSE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime8$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime8$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime8$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime8$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime8$accrualIntensity, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime8$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime8$accrualIntensityRelative, c(0.22, 0.33), label = paste0("c(", paste0(accrualTime8$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime8$maxNumberOfSubjects, NA_real_, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime8$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime8$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime8$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime8$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime8), NA)))
- expect_output(print(accrualTime8)$show())
- invisible(capture.output(expect_error(summary(accrualTime8), NA)))
- expect_output(summary(accrualTime8)$show())
- accrualTime8CodeBased <- eval(parse(text = getObjectRCode(accrualTime8, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime8CodeBased$endOfAccrualIsUserDefined, accrualTime8$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$followUpTimeMustBeUserDefined, accrualTime8$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime8$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$absoluteAccrualIntensityEnabled, accrualTime8$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$accrualTime, accrualTime8$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$accrualIntensity, accrualTime8$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$accrualIntensityRelative, accrualTime8$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$maxNumberOfSubjects, accrualTime8$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$remainingTime, accrualTime8$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime8CodeBased$piecewiseAccrualEnabled, accrualTime8$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime8), "character")
- df <- as.data.frame(accrualTime8)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime8)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime9 <- getAccrualTime(
- accrualTime = c(0, 6),
- accrualIntensity = c(22, 33), maxNumberOfSubjects = 1000
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime9' with expected results
- expect_equal(accrualTime9$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime9$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime9$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime9$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime9$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime9$accrualTime, c(0, 6, 32.30303), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime9$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime9$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime9$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime9$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime9$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime9$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime9$remainingTime, 26.30303, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime9$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime9$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime9$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime9), NA)))
- expect_output(print(accrualTime9)$show())
- invisible(capture.output(expect_error(summary(accrualTime9), NA)))
- expect_output(summary(accrualTime9)$show())
- accrualTime9CodeBased <- eval(parse(text = getObjectRCode(accrualTime9, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime9CodeBased$endOfAccrualIsUserDefined, accrualTime9$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$followUpTimeMustBeUserDefined, accrualTime9$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime9$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$absoluteAccrualIntensityEnabled, accrualTime9$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$accrualTime, accrualTime9$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$accrualIntensity, accrualTime9$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$accrualIntensityRelative, accrualTime9$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$maxNumberOfSubjects, accrualTime9$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$remainingTime, accrualTime9$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime9CodeBased$piecewiseAccrualEnabled, accrualTime9$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime9), "character")
- df <- as.data.frame(accrualTime9)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime9)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime10 <- getAccrualTime(list(
- "0 - <6" = 22,
- "6" = 33
- ),
- maxNumberOfSubjects = 1000
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime10' with expected results
- expect_equal(accrualTime10$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime10$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime10$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime10$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime10$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime10$accrualTime, c(0, 6, 32.30303), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime10$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime10$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime10$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime10$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime10$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime10$remainingTime, 26.30303, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime10$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime10$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime10), NA)))
- expect_output(print(accrualTime10)$show())
- invisible(capture.output(expect_error(summary(accrualTime10), NA)))
- expect_output(summary(accrualTime10)$show())
- accrualTime10CodeBased <- eval(parse(text = getObjectRCode(accrualTime10, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime10CodeBased$endOfAccrualIsUserDefined, accrualTime10$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$followUpTimeMustBeUserDefined, accrualTime10$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime10$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$absoluteAccrualIntensityEnabled, accrualTime10$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$accrualTime, accrualTime10$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$accrualIntensity, accrualTime10$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$accrualIntensityRelative, accrualTime10$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$maxNumberOfSubjects, accrualTime10$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$remainingTime, accrualTime10$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime10CodeBased$piecewiseAccrualEnabled, accrualTime10$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime10), "character")
- df <- as.data.frame(accrualTime10)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime10)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime12 <- getAccrualTime(list(
- "0 - <6" = 0.22,
- "6 - <=30" = 0.33
- ),
- maxNumberOfSubjects = 1000
- )
-
- ## Comparison of the results of AccrualTime object 'accrualTime12' with expected results
- expect_equal(accrualTime12$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime12$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime12$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime12$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime12$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime12$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime12$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime12$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime12$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime12$accrualIntensity, c(23.809524, 35.714286), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime12$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime12$accrualIntensityRelative, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime12$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime12$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime12$remainingTime, 24, label = paste0("c(", paste0(accrualTime12$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime12$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime12$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime12), NA)))
- expect_output(print(accrualTime12)$show())
- invisible(capture.output(expect_error(summary(accrualTime12), NA)))
- expect_output(summary(accrualTime12)$show())
- accrualTime12CodeBased <- eval(parse(text = getObjectRCode(accrualTime12, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime12CodeBased$endOfAccrualIsUserDefined, accrualTime12$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$followUpTimeMustBeUserDefined, accrualTime12$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime12$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$absoluteAccrualIntensityEnabled, accrualTime12$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$accrualTime, accrualTime12$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$accrualIntensity, accrualTime12$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$accrualIntensityRelative, accrualTime12$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$maxNumberOfSubjects, accrualTime12$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$remainingTime, accrualTime12$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime12CodeBased$piecewiseAccrualEnabled, accrualTime12$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime12), "character")
- df <- as.data.frame(accrualTime12)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime12)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime13 <- getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(22, 33))
-
- ## Comparison of the results of AccrualTime object 'accrualTime13' with expected results
- expect_equal(accrualTime13$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime13$followUpTimeMustBeUserDefined, TRUE, label = paste0("c(", paste0(accrualTime13$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime13$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, FALSE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime13$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime13$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime13$accrualTime, c(0, 6), label = paste0("c(", paste0(accrualTime13$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime13$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime13$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime13$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime13$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime13$maxNumberOfSubjects, NA_real_, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime13$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime13$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime13$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime13$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime13), NA)))
- expect_output(print(accrualTime13)$show())
- invisible(capture.output(expect_error(summary(accrualTime13), NA)))
- expect_output(summary(accrualTime13)$show())
- accrualTime13CodeBased <- eval(parse(text = getObjectRCode(accrualTime13, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime13CodeBased$endOfAccrualIsUserDefined, accrualTime13$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$followUpTimeMustBeUserDefined, accrualTime13$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime13$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$absoluteAccrualIntensityEnabled, accrualTime13$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$accrualTime, accrualTime13$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$accrualIntensity, accrualTime13$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$accrualIntensityRelative, accrualTime13$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$maxNumberOfSubjects, accrualTime13$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$remainingTime, accrualTime13$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime13CodeBased$piecewiseAccrualEnabled, accrualTime13$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime13), "character")
- df <- as.data.frame(accrualTime13)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime13)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- accrualTime14 <- getAccrualTime(list(
- "0 - <6" = 22,
- "6 - <=30" = 33
- ))
-
- ## Comparison of the results of AccrualTime object 'accrualTime14' with expected results
- expect_equal(accrualTime14$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime14$endOfAccrualIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime14$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime14$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime14$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime14$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
- expect_equal(accrualTime14$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime14$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
- expect_equal(accrualTime14$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime14$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
- expect_equal(accrualTime14$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime14$accrualTime, collapse = ", "), ")"))
- expect_equal(accrualTime14$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime14$accrualIntensity, collapse = ", "), ")"))
- expect_equal(accrualTime14$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime14$accrualIntensityRelative, collapse = ", "), ")"))
- expect_equal(accrualTime14$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime14$maxNumberOfSubjects, collapse = ", "), ")"))
- expect_equal(accrualTime14$remainingTime, 24, label = paste0("c(", paste0(accrualTime14$remainingTime, collapse = ", "), ")"))
- expect_equal(accrualTime14$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime14$piecewiseAccrualEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(accrualTime14), NA)))
- expect_output(print(accrualTime14)$show())
- invisible(capture.output(expect_error(summary(accrualTime14), NA)))
- expect_output(summary(accrualTime14)$show())
- accrualTime14CodeBased <- eval(parse(text = getObjectRCode(accrualTime14, stringWrapParagraphWidth = NULL)))
- expect_equal(accrualTime14CodeBased$endOfAccrualIsUserDefined, accrualTime14$endOfAccrualIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$followUpTimeMustBeUserDefined, accrualTime14$followUpTimeMustBeUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime14$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime14$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$absoluteAccrualIntensityEnabled, accrualTime14$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$accrualTime, accrualTime14$accrualTime, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$accrualIntensity, accrualTime14$accrualIntensity, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$accrualIntensityRelative, accrualTime14$accrualIntensityRelative, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$maxNumberOfSubjects, accrualTime14$maxNumberOfSubjects, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$remainingTime, accrualTime14$remainingTime, tolerance = 1e-07)
- expect_equal(accrualTime14CodeBased$piecewiseAccrualEnabled, accrualTime14$piecewiseAccrualEnabled, tolerance = 1e-07)
- expect_type(names(accrualTime14), "character")
- df <- as.data.frame(accrualTime14)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(accrualTime14)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
-})
-
-test_that("Testing 'getAccrualTime': check expected warnings and errors", {
-
- # @refFS[Tab.]{fs:tab:output:getAccrualTime}
- expect_warning(getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(0.22, 0.33)),
- paste0("The specified accrual time and intensity cannot be supplemented ",
- "automatically with the missing information; therefore further calculations are not possible"),
- fixed = TRUE
- )
-
- expect_warning(getAccrualTime(accrualTime = c(0, 24), accrualIntensity = c(30, 45), maxNumberOfSubjects = 720),
- "Last accrual intensity value (45) ignored",
- fixed = TRUE
- )
-
- .skipTestIfDisabled()
-
- suppressWarnings(expect_warning(getAccrualTime(accrualTime = c(0, 24, 30),
- accrualIntensity = c(30, 45, 55), maxNumberOfSubjects = 720),
- "Last 2 accrual intensity values (45, 55) ignored",
- fixed = TRUE
- ))
-
- suppressWarnings(expect_warning(getAccrualTime(accrualTime = c(0, 24, 30, 40),
- accrualIntensity = c(30, 45, 55, 66), maxNumberOfSubjects = 720),
- "Last 2 accrual time values (30, 40) ignored",
- fixed = TRUE
- ))
-
- suppressWarnings(expect_warning(getAccrualTime(accrualTime = c(0, 24, 30, 40),
- accrualIntensity = c(30, 45, 55, 66), maxNumberOfSubjects = 720),
- "Last 3 accrual intensity values (45, 55, 66) ignored",
- fixed = TRUE
- ))
-
- expect_warning(getAccrualTime(accrualTime = c(0, 6, 15, 25), accrualIntensity = c(0, 22, 33)),
- "It makes no sense to start 'accrualIntensity' (0, 22, 33) with 0",
- fixed = TRUE
- )
-
- expect_error(getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(0)),
- "Illegal argument: at least one 'accrualIntensity' value must be > 0",
- fixed = TRUE
- )
-
- expect_error(getAccrualTime(
- accrualTime = c(0, 6, 30), accrualIntensity = c(22, 33),
- maxNumberOfSubjects = 1000
- ),
- paste0(
- "Conflicting arguments: 'maxNumberOfSubjects' (1000) disagrees with the defined ",
- "accrual time (0, 6, 30) and intensity: 6 * 22 + 24 * 33 = 924"
- ),
- fixed = TRUE
- )
-
-})
-
-test_that("Testing 'getAccrualTime': list-wise definition", {
-
- accrualTime1 <- list(
- "0 - <12" = 15,
- "12 - <13" = 21,
- "13 - <14" = 27,
- "14 - <15" = 33,
- "15 - <16" = 39,
- ">=16" = 45
- )
-
- # @refFS[Tab.]{fs:tab:output:getAccrualTime}
- accrualTime4 <- getAccrualTime(accrualTime = accrualTime1, maxNumberOfSubjects = 1405)
- expect_equal(accrualTime4$accrualTime, c(0, 12, 13, 14, 15, 16, 40.55555556))
- expect_equal(accrualTime4$accrualIntensity, c(15, 21, 27, 33, 39, 45))
- expect_equal(accrualTime4$remainingTime, 24.55555556)
-
- .skipTestIfDisabled()
-
- accrualTime2 <- list(
- "0 - <12" = 15,
- "12 - <13" = 21,
- "13 - <14" = 27,
- "14 - <15" = 33,
- "15 - <16" = 39,
- "16 - ?" = 45
- )
- accrualTime5 <- getAccrualTime(accrualTime = accrualTime2, maxNumberOfSubjects = 1405)
- expect_equal(accrualTime5$accrualTime, c(0, 12, 13, 14, 15, 16, 40.55555556))
- expect_equal(accrualTime5$accrualIntensity, c(15, 21, 27, 33, 39, 45))
- expect_equal(accrualTime5$remainingTime, 24.55555556)
-
- accrualTime3 <- list(
- "0 - <11" = 20,
- "11 - <16" = 40,
- ">=16" = 60
- )
- accrualTime6 <- getAccrualTime(accrualTime = accrualTime3, maxNumberOfSubjects = 800)
- expect_equal(accrualTime6$accrualTime, c(0, 11, 16, 22.3333333))
- expect_equal(accrualTime6$accrualIntensity, c(20, 40, 60))
- expect_equal(accrualTime6$remainingTime, 6.33333333)
-
- accrualTime7 <- list(
- "0 - <11" = 20,
- "11 - <16" = 40,
- "16 - ?" = 60
- )
- accrualTime8 <- getAccrualTime(accrualTime = accrualTime7, maxNumberOfSubjects = 800)
- expect_equal(accrualTime8$accrualTime, c(0, 11, 16, 22.3333333))
- expect_equal(accrualTime8$accrualIntensity, c(20, 40, 60))
- expect_equal(accrualTime8$remainingTime, 6.33333333)
-
-})
-
-test_that("Testing 'getPiecewiseSurvivalTime': mixed arguments", {
-
- # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
- pwSurvivalTime1 <- getPiecewiseSurvivalTime(median1 = 37, hazardRatio = 0.8)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime1' with expected results
- expect_equal(pwSurvivalTime1$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$lambda1, 0.018733708, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$lambda2, 0.023417134, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$median1, 37, label = paste0("c(", paste0(pwSurvivalTime1$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$median2, 29.6, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime1$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime1$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime1), NA)))
- expect_output(print(pwSurvivalTime1)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime1), NA)))
- expect_output(summary(pwSurvivalTime1)$show())
- pwSurvivalTime1CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime1, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalTime, pwSurvivalTime1$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$lambda1, pwSurvivalTime1$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$lambda2, pwSurvivalTime1$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$hazardRatio, pwSurvivalTime1$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$pi1, pwSurvivalTime1$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$pi2, pwSurvivalTime1$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$median1, pwSurvivalTime1$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$median2, pwSurvivalTime1$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$eventTime, pwSurvivalTime1$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$kappa, pwSurvivalTime1$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime1$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$delayedResponseAllowed, pwSurvivalTime1$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime1CodeBased$delayedResponseEnabled, pwSurvivalTime1$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime1), "character")
- df <- as.data.frame(pwSurvivalTime1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime2 <- getPiecewiseSurvivalTime(lambda1 = 0.01873371, median2 = 29.6)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
- expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda1, 0.01873371, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$lambda2, 0.023417134, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$hazardRatio, 0.8000001, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median1, 36.999995, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$median2, 29.6, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
- expect_output(print(pwSurvivalTime2)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
- expect_output(summary(pwSurvivalTime2)$show())
- pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime2), "character")
- df <- as.data.frame(pwSurvivalTime2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- pwSurvivalTime3 <- getPiecewiseSurvivalTime(median1 = 37, lambda2 = 0.02341713)
-
- ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime3' with expected results
- expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$lambda1, 0.018733708, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$lambda2, 0.02341713, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$hazardRatio, 0.80000015, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$hazardRatio, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$median1, 37, label = paste0("c(", paste0(pwSurvivalTime3$median1, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$median2, 29.600006, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$median2, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$eventTime, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime3$kappa, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalEnabled, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseAllowed, collapse = ", "), ")"))
- expect_equal(pwSurvivalTime3$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseEnabled, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(pwSurvivalTime3), NA)))
- expect_output(print(pwSurvivalTime3)$show())
- invisible(capture.output(expect_error(summary(pwSurvivalTime3), NA)))
- expect_output(summary(pwSurvivalTime3)$show())
- pwSurvivalTime3CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime3, stringWrapParagraphWidth = NULL)))
- expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalTime, pwSurvivalTime3$piecewiseSurvivalTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$lambda1, pwSurvivalTime3$lambda1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$lambda2, pwSurvivalTime3$lambda2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$hazardRatio, pwSurvivalTime3$hazardRatio, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$pi1, pwSurvivalTime3$pi1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$pi2, pwSurvivalTime3$pi2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$median1, pwSurvivalTime3$median1, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$median2, pwSurvivalTime3$median2, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$eventTime, pwSurvivalTime3$eventTime, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$kappa, pwSurvivalTime3$kappa, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime3$piecewiseSurvivalEnabled, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$delayedResponseAllowed, pwSurvivalTime3$delayedResponseAllowed, tolerance = 1e-07)
- expect_equal(pwSurvivalTime3CodeBased$delayedResponseEnabled, pwSurvivalTime3$delayedResponseEnabled, tolerance = 1e-07)
- expect_type(names(pwSurvivalTime3), "character")
- df <- as.data.frame(pwSurvivalTime3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(pwSurvivalTime3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- expect_warning(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi1 = 0.3),
- "'hazardRatio' (0.6, 0.8) will be ignored because it will be calculated",
- fixed = TRUE
- )
-})
-
+## |
+## | *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-class_time.R
+## | Creation date: 08 November 2023, 08:49:49
+## | File version: $Revision: 7940 $
+## | Last changed: $Date: 2024-05-27 15:47:41 +0200 (Mo, 27 Mai 2024) $
+## | Last changed by: $Author: pahlke $
+## |
+
+test_plan_section("Testing Class 'PiecewiseSurvivalTime'")
+
+
+test_that("Testing 'getPiecewiseSurvivalTime': isPiecewiseSurvivalEnabled()", {
+ # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
+ expect_false(getPiecewiseSurvivalTime()$isPiecewiseSurvivalEnabled())
+ expect_false(getPiecewiseSurvivalTime(piecewiseSurvivalTime = NA)$isPiecewiseSurvivalEnabled())
+})
+
+test_that("Testing 'getPiecewiseSurvivalTime': simple vector based definition", {
+ # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
+ pwSurvivalTime1 <- getPiecewiseSurvivalTime(lambda2 = 0.5, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime1' with expected results
+ expect_equal(pwSurvivalTime1$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$lambda1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$lambda2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$median1, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$median2, 1.3862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime1$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime1), NA)))
+ expect_output(print(pwSurvivalTime1)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime1), NA)))
+ expect_output(summary(pwSurvivalTime1)$show())
+ pwSurvivalTime1CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime1, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalTime, pwSurvivalTime1$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$lambda1, pwSurvivalTime1$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$lambda2, pwSurvivalTime1$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$hazardRatio, pwSurvivalTime1$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$pi1, pwSurvivalTime1$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$pi2, pwSurvivalTime1$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$median1, pwSurvivalTime1$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$median2, pwSurvivalTime1$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$eventTime, pwSurvivalTime1$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$kappa, pwSurvivalTime1$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime1$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$delayedResponseAllowed, pwSurvivalTime1$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$delayedResponseEnabled, pwSurvivalTime1$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime1), "character")
+ df <- as.data.frame(pwSurvivalTime1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime2 <- getPiecewiseSurvivalTime(lambda2 = 0.5, lambda1 = 0.4)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median1, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median2, 1.3862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
+ expect_output(print(pwSurvivalTime2)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
+ expect_output(summary(pwSurvivalTime2)$show())
+ pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime2), "character")
+ df <- as.data.frame(pwSurvivalTime2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ .skipTestIfDisabled()
+
+ pwSurvivalTime2 <- getPiecewiseSurvivalTime(pi2 = 0.5, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda1, 0.046209812, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda2, 0.057762265, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi1, 0.42565082, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median1, 15, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median2, 12, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
+ expect_output(print(pwSurvivalTime2)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
+ expect_output(summary(pwSurvivalTime2)$show())
+ pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime2), "character")
+ df <- as.data.frame(pwSurvivalTime2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime2 <- getPiecewiseSurvivalTime(pi2 = 0.5, pi1 = 0.4)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda1, 0.042568802, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda2, 0.057762265, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$hazardRatio, 0.73696559, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi2, 0.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median1, 16.282985, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median2, 12, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
+ expect_output(print(pwSurvivalTime2)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
+ expect_output(summary(pwSurvivalTime2)$show())
+ pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime2), "character")
+ df <- as.data.frame(pwSurvivalTime2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime3 <- getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime3' with expected results
+ expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$lambda1, c(0.24, 0.32), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$lambda2, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$hazardRatio, c(0.6, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$median1, c(2.8881133, 2.1660849), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$median2, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime3$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime3), NA)))
+ expect_output(print(pwSurvivalTime3)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime3), NA)))
+ expect_output(summary(pwSurvivalTime3)$show())
+ pwSurvivalTime3CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime3, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalTime, pwSurvivalTime3$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$lambda1, pwSurvivalTime3$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$lambda2, pwSurvivalTime3$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$hazardRatio, pwSurvivalTime3$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$pi1, pwSurvivalTime3$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$pi2, pwSurvivalTime3$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$median1, pwSurvivalTime3$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$median2, pwSurvivalTime3$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$eventTime, pwSurvivalTime3$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$kappa, pwSurvivalTime3$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime3$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$delayedResponseAllowed, pwSurvivalTime3$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$delayedResponseEnabled, pwSurvivalTime3$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime3), "character")
+ df <- as.data.frame(pwSurvivalTime3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime8 <- getPiecewiseSurvivalTime(pi2 = 0.4, pi1 = 0.3)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime8' with expected results
+ expect_equal(pwSurvivalTime8$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime8$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$lambda1, 0.029722912, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$lambda2, 0.042568802, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$hazardRatio, 0.69823229, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$pi1, 0.3, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$pi2, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$median1, 23.320299, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$median2, 16.282985, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime8$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime8$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime8$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime8$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime8$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime8$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime8$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime8), NA)))
+ expect_output(print(pwSurvivalTime8)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime8), NA)))
+ expect_output(summary(pwSurvivalTime8)$show())
+ pwSurvivalTime8CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime8, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime8CodeBased$piecewiseSurvivalTime, pwSurvivalTime8$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$lambda1, pwSurvivalTime8$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$lambda2, pwSurvivalTime8$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$hazardRatio, pwSurvivalTime8$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$pi1, pwSurvivalTime8$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$pi2, pwSurvivalTime8$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$median1, pwSurvivalTime8$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$median2, pwSurvivalTime8$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$eventTime, pwSurvivalTime8$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$kappa, pwSurvivalTime8$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime8$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$delayedResponseAllowed, pwSurvivalTime8$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime8CodeBased$delayedResponseEnabled, pwSurvivalTime8$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime8), "character")
+ df <- as.data.frame(pwSurvivalTime8)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime9 <- getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi2 = 0.3)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime9' with expected results
+ expect_equal(pwSurvivalTime9$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime9$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$lambda1, c(0.017833747, 0.02377833), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$lambda2, 0.029722912, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$hazardRatio, c(0.6, 0.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$pi1, c(0.19265562, 0.24824135), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$pi2, 0.3, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$median1, c(38.867164, 29.150373), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$median2, 23.320299, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime9$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime9$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime9$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime9$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime9$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime9$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime9$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime9), NA)))
+ expect_output(print(pwSurvivalTime9)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime9), NA)))
+ expect_output(summary(pwSurvivalTime9)$show())
+ pwSurvivalTime9CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime9, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime9CodeBased$piecewiseSurvivalTime, pwSurvivalTime9$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$lambda1, pwSurvivalTime9$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$lambda2, pwSurvivalTime9$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$hazardRatio, pwSurvivalTime9$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$pi1, pwSurvivalTime9$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$pi2, pwSurvivalTime9$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$median1, pwSurvivalTime9$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$median2, pwSurvivalTime9$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$eventTime, pwSurvivalTime9$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$kappa, pwSurvivalTime9$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime9$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$delayedResponseAllowed, pwSurvivalTime9$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime9CodeBased$delayedResponseEnabled, pwSurvivalTime9$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime9), "character")
+ df <- as.data.frame(pwSurvivalTime9)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime9)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime10 <- getPiecewiseSurvivalTime(median2 = 1.386294, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime10' with expected results
+ expect_equal(pwSurvivalTime10$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$lambda1, 0.4000001, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$lambda2, 0.50000013, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$median1, 1.7328675, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$median2, 1.386294, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime10$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime10), NA)))
+ expect_output(print(pwSurvivalTime10)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime10), NA)))
+ expect_output(summary(pwSurvivalTime10)$show())
+ pwSurvivalTime10CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime10, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalTime, pwSurvivalTime10$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$lambda1, pwSurvivalTime10$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$lambda2, pwSurvivalTime10$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$hazardRatio, pwSurvivalTime10$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$pi1, pwSurvivalTime10$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$pi2, pwSurvivalTime10$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$median1, pwSurvivalTime10$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$median2, pwSurvivalTime10$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$eventTime, pwSurvivalTime10$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$kappa, pwSurvivalTime10$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime10$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$delayedResponseAllowed, pwSurvivalTime10$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$delayedResponseEnabled, pwSurvivalTime10$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime10), "character")
+ df <- as.data.frame(pwSurvivalTime10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime11 <- getPiecewiseSurvivalTime(median2 = 1.386294, lambda1 = 0.4)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime11' with expected results
+ expect_equal(pwSurvivalTime11$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$lambda1, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$lambda2, 0.50000013, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$hazardRatio, 0.79999979, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$median1, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$median2, 1.386294, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime11$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime11), NA)))
+ expect_output(print(pwSurvivalTime11)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime11), NA)))
+ expect_output(summary(pwSurvivalTime11)$show())
+ pwSurvivalTime11CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime11, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalTime, pwSurvivalTime11$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$lambda1, pwSurvivalTime11$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$lambda2, pwSurvivalTime11$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$hazardRatio, pwSurvivalTime11$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$pi1, pwSurvivalTime11$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$pi2, pwSurvivalTime11$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$median1, pwSurvivalTime11$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$median2, pwSurvivalTime11$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$eventTime, pwSurvivalTime11$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$kappa, pwSurvivalTime11$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime11$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$delayedResponseAllowed, pwSurvivalTime11$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$delayedResponseEnabled, pwSurvivalTime11$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime11), "character")
+ df <- as.data.frame(pwSurvivalTime11)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime11)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime12 <- getPiecewiseSurvivalTime(median2 = 5, median1 = 6)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime12' with expected results
+ expect_equal(pwSurvivalTime12$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$lambda1, 0.11552453, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$lambda2, 0.13862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$hazardRatio, 0.83333333, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$median1, 6, label = paste0("c(", paste0(pwSurvivalTime12$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$median2, 5, label = paste0("c(", paste0(pwSurvivalTime12$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime12$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime12), NA)))
+ expect_output(print(pwSurvivalTime12)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime12), NA)))
+ expect_output(summary(pwSurvivalTime12)$show())
+ pwSurvivalTime12CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime12, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalTime, pwSurvivalTime12$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$lambda1, pwSurvivalTime12$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$lambda2, pwSurvivalTime12$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$hazardRatio, pwSurvivalTime12$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$pi1, pwSurvivalTime12$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$pi2, pwSurvivalTime12$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$median1, pwSurvivalTime12$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$median2, pwSurvivalTime12$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$eventTime, pwSurvivalTime12$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$kappa, pwSurvivalTime12$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime12$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$delayedResponseAllowed, pwSurvivalTime12$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$delayedResponseEnabled, pwSurvivalTime12$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime12), "character")
+ df <- as.data.frame(pwSurvivalTime12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime13 <- getPiecewiseSurvivalTime(median2 = 1.386294, lambda1 = c(0.3, 0.4))
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime13' with expected results
+ expect_equal(pwSurvivalTime13$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$lambda1, c(0.3, 0.4), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$lambda2, 0.50000013, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$hazardRatio, c(0.59999984, 0.79999979), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$median1, c(2.3104906, 1.732868), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$median2, 1.386294, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime13$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime13), NA)))
+ expect_output(print(pwSurvivalTime13)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime13), NA)))
+ expect_output(summary(pwSurvivalTime13)$show())
+ pwSurvivalTime13CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime13, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalTime, pwSurvivalTime13$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$lambda1, pwSurvivalTime13$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$lambda2, pwSurvivalTime13$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$hazardRatio, pwSurvivalTime13$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$pi1, pwSurvivalTime13$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$pi2, pwSurvivalTime13$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$median1, pwSurvivalTime13$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$median2, pwSurvivalTime13$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$eventTime, pwSurvivalTime13$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$kappa, pwSurvivalTime13$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime13$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$delayedResponseAllowed, pwSurvivalTime13$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$delayedResponseEnabled, pwSurvivalTime13$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime13), "character")
+ df <- as.data.frame(pwSurvivalTime13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime14 <- getPiecewiseSurvivalTime(median2 = 5, median1 = c(6:8))
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime14' with expected results
+ expect_equal(pwSurvivalTime14$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$lambda1, c(0.11552453, 0.099021026, 0.086643398), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime14$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$lambda2, 0.13862944, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime14$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$hazardRatio, c(0.83333333, 0.71428571, 0.625), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime14$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$median1, c(6, 7, 8), label = paste0("c(", paste0(pwSurvivalTime14$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$median2, 5, label = paste0("c(", paste0(pwSurvivalTime14$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime14$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime14$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime14$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime14$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime14$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime14$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime14), NA)))
+ expect_output(print(pwSurvivalTime14)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime14), NA)))
+ expect_output(summary(pwSurvivalTime14)$show())
+ pwSurvivalTime14CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime14, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime14CodeBased$piecewiseSurvivalTime, pwSurvivalTime14$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$lambda1, pwSurvivalTime14$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$lambda2, pwSurvivalTime14$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$hazardRatio, pwSurvivalTime14$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$pi1, pwSurvivalTime14$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$pi2, pwSurvivalTime14$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$median1, pwSurvivalTime14$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$median2, pwSurvivalTime14$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$eventTime, pwSurvivalTime14$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$kappa, pwSurvivalTime14$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime14$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$delayedResponseAllowed, pwSurvivalTime14$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime14CodeBased$delayedResponseEnabled, pwSurvivalTime14$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime14), "character")
+ df <- as.data.frame(pwSurvivalTime14)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime14)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime15 <- getPiecewiseSurvivalTime(median2 = 2, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime15' with expected results
+ expect_equal(pwSurvivalTime15$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$lambda1, 0.27725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$lambda2, 0.34657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$median1, 2.5, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime15$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$median2, 2, label = paste0("c(", paste0(pwSurvivalTime15$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime15$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime15$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime15$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime15$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime15$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime15$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime15), NA)))
+ expect_output(print(pwSurvivalTime15)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime15), NA)))
+ expect_output(summary(pwSurvivalTime15)$show())
+ pwSurvivalTime15CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime15, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime15CodeBased$piecewiseSurvivalTime, pwSurvivalTime15$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$lambda1, pwSurvivalTime15$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$lambda2, pwSurvivalTime15$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$hazardRatio, pwSurvivalTime15$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$pi1, pwSurvivalTime15$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$pi2, pwSurvivalTime15$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$median1, pwSurvivalTime15$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$median2, pwSurvivalTime15$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$eventTime, pwSurvivalTime15$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$kappa, pwSurvivalTime15$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime15$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$delayedResponseAllowed, pwSurvivalTime15$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime15CodeBased$delayedResponseEnabled, pwSurvivalTime15$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime15), "character")
+ df <- as.data.frame(pwSurvivalTime15)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime15)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime16 <- getPiecewiseSurvivalTime(median1 = c(2, 2), hazardRatio = c(1.4, 1.4))
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime16' with expected results
+ expect_equal(pwSurvivalTime16$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$lambda1, c(0.34657359, 0.34657359), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$lambda2, c(0.24755256, 0.24755256), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$hazardRatio, c(1.4, 1.4), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$median1, c(2, 2), label = paste0("c(", paste0(pwSurvivalTime16$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$median2, c(2.8, 2.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime16$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime16$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime16$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime16$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime16$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime16$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime16$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime16), NA)))
+ expect_output(print(pwSurvivalTime16)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime16), NA)))
+ expect_output(summary(pwSurvivalTime16)$show())
+ pwSurvivalTime16CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime16, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime16CodeBased$piecewiseSurvivalTime, pwSurvivalTime16$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$lambda1, pwSurvivalTime16$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$lambda2, pwSurvivalTime16$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$hazardRatio, pwSurvivalTime16$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$pi1, pwSurvivalTime16$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$pi2, pwSurvivalTime16$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$median1, pwSurvivalTime16$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$median2, pwSurvivalTime16$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$eventTime, pwSurvivalTime16$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$kappa, pwSurvivalTime16$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime16$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$delayedResponseAllowed, pwSurvivalTime16$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime16CodeBased$delayedResponseEnabled, pwSurvivalTime16$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime16), "character")
+ df <- as.data.frame(pwSurvivalTime16)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime16)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime17 <- getPiecewiseSurvivalTime(median1 = c(2, 3), median2 = 4)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime17' with expected results
+ expect_equal(pwSurvivalTime17$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$lambda1, c(0.34657359, 0.23104906), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime17$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$lambda2, 0.1732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime17$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$hazardRatio, c(2, 1.3333333), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime17$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$median1, c(2, 3), label = paste0("c(", paste0(pwSurvivalTime17$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$median2, 4, label = paste0("c(", paste0(pwSurvivalTime17$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime17$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime17$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime17$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime17$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime17$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime17$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime17), NA)))
+ expect_output(print(pwSurvivalTime17)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime17), NA)))
+ expect_output(summary(pwSurvivalTime17)$show())
+ pwSurvivalTime17CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime17, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime17CodeBased$piecewiseSurvivalTime, pwSurvivalTime17$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$lambda1, pwSurvivalTime17$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$lambda2, pwSurvivalTime17$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$hazardRatio, pwSurvivalTime17$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$pi1, pwSurvivalTime17$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$pi2, pwSurvivalTime17$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$median1, pwSurvivalTime17$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$median2, pwSurvivalTime17$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$eventTime, pwSurvivalTime17$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$kappa, pwSurvivalTime17$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime17$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$delayedResponseAllowed, pwSurvivalTime17$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime17CodeBased$delayedResponseEnabled, pwSurvivalTime17$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime17), "character")
+ df <- as.data.frame(pwSurvivalTime17)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime17)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime18 <- getPiecewiseSurvivalTime(median1 = c(2, 3), lambda2 = 0.4)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime18' with expected results
+ expect_equal(pwSurvivalTime18$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime18$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$lambda1, c(0.34657359, 0.23104906), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$lambda2, 0.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$hazardRatio, c(0.86643398, 0.57762265), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime18$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime18$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$median1, c(2, 3), label = paste0("c(", paste0(pwSurvivalTime18$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$median2, 1.732868, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime18$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime18$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime18$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime18$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime18$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime18$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime18$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime18), NA)))
+ expect_output(print(pwSurvivalTime18)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime18), NA)))
+ expect_output(summary(pwSurvivalTime18)$show())
+ pwSurvivalTime18CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime18, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime18CodeBased$piecewiseSurvivalTime, pwSurvivalTime18$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$lambda1, pwSurvivalTime18$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$lambda2, pwSurvivalTime18$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$hazardRatio, pwSurvivalTime18$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$pi1, pwSurvivalTime18$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$pi2, pwSurvivalTime18$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$median1, pwSurvivalTime18$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$median2, pwSurvivalTime18$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$eventTime, pwSurvivalTime18$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$kappa, pwSurvivalTime18$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime18$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$delayedResponseAllowed, pwSurvivalTime18$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime18CodeBased$delayedResponseEnabled, pwSurvivalTime18$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime18), "character")
+ df <- as.data.frame(pwSurvivalTime18)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime18)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime19 <- getPiecewiseSurvivalTime(pi1 = 0.45)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime19' with expected results
+ expect_equal(pwSurvivalTime19$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime19$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$lambda1, 0.04981975, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$lambda2, 0.018595296, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$hazardRatio, 2.6791588, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$pi1, 0.45, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$pi2, 0.2, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$median1, 13.9131, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$median2, 37.275405, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime19$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$eventTime, 12, label = paste0("c(", paste0(pwSurvivalTime19$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime19$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime19$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime19$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime19$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime19$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime19), NA)))
+ expect_output(print(pwSurvivalTime19)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime19), NA)))
+ expect_output(summary(pwSurvivalTime19)$show())
+ pwSurvivalTime19CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime19, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime19CodeBased$piecewiseSurvivalTime, pwSurvivalTime19$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$lambda1, pwSurvivalTime19$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$lambda2, pwSurvivalTime19$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$hazardRatio, pwSurvivalTime19$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$pi1, pwSurvivalTime19$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$pi2, pwSurvivalTime19$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$median1, pwSurvivalTime19$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$median2, pwSurvivalTime19$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$eventTime, pwSurvivalTime19$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$kappa, pwSurvivalTime19$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime19$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$delayedResponseAllowed, pwSurvivalTime19$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime19CodeBased$delayedResponseEnabled, pwSurvivalTime19$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime19), "character")
+ df <- as.data.frame(pwSurvivalTime19)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime19)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime20 <- getPiecewiseSurvivalTime(median1 = c(2, 4), hazardRatio = c(1.4, 0.7))
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime20' with expected results
+ expect_equal(pwSurvivalTime20$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$lambda1, c(0.34657359, 0.1732868), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$lambda2, c(0.24755256, 0.24755256), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$hazardRatio, c(1.4, 0.7), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$median1, c(2, 4), label = paste0("c(", paste0(pwSurvivalTime20$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$median2, c(2.8, 2.8), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime20$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime20$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime20$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime20$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime20$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime20$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime20$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime20), NA)))
+ expect_output(print(pwSurvivalTime20)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime20), NA)))
+ expect_output(summary(pwSurvivalTime20)$show())
+ pwSurvivalTime20CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime20, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime20CodeBased$piecewiseSurvivalTime, pwSurvivalTime20$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$lambda1, pwSurvivalTime20$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$lambda2, pwSurvivalTime20$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$hazardRatio, pwSurvivalTime20$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$pi1, pwSurvivalTime20$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$pi2, pwSurvivalTime20$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$median1, pwSurvivalTime20$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$median2, pwSurvivalTime20$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$eventTime, pwSurvivalTime20$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$kappa, pwSurvivalTime20$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime20$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$delayedResponseAllowed, pwSurvivalTime20$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime20CodeBased$delayedResponseEnabled, pwSurvivalTime20$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime20), "character")
+ df <- as.data.frame(pwSurvivalTime20)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime20)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime21 <- getPiecewiseSurvivalTime(median1 = 3, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime21' with expected results
+ expect_equal(pwSurvivalTime21$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$lambda1, 0.23104906, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$lambda2, 0.28881133, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$median1, 3, label = paste0("c(", paste0(pwSurvivalTime21$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$median2, 2.4, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime21$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime21$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime21$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime21$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime21$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime21$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime21$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime21), NA)))
+ expect_output(print(pwSurvivalTime21)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime21), NA)))
+ expect_output(summary(pwSurvivalTime21)$show())
+ pwSurvivalTime21CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime21, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime21CodeBased$piecewiseSurvivalTime, pwSurvivalTime21$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$lambda1, pwSurvivalTime21$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$lambda2, pwSurvivalTime21$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$hazardRatio, pwSurvivalTime21$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$pi1, pwSurvivalTime21$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$pi2, pwSurvivalTime21$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$median1, pwSurvivalTime21$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$median2, pwSurvivalTime21$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$eventTime, pwSurvivalTime21$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$kappa, pwSurvivalTime21$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime21$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$delayedResponseAllowed, pwSurvivalTime21$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime21CodeBased$delayedResponseEnabled, pwSurvivalTime21$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime21), "character")
+ df <- as.data.frame(pwSurvivalTime21)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime21)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ expect_error(getPiecewiseSurvivalTime(median2 = 1.386294, lambda2 = 0.4, hazardRatio = 0.8))
+ expect_error(getPiecewiseSurvivalTime(median2 = c(1.5, 1.7), lambda1 = c(0.3, 0.4)))
+ expect_error(getPiecewiseSurvivalTime(median1 = c(2, 4), hazardRatio = c(1, 0.7)))
+ expect_error(getPiecewiseSurvivalTime(median1 = c(2, 4), hazardRatio = 0.7))
+})
+
+test_that("Testing 'getPiecewiseSurvivalTime': vector based definition", {
+ # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
+ pwSurvivalTime1 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 6, 9),
+ lambda2 = c(0.025, 0.04, 0.015), hazardRatio = 0.8
+ )
+ expect_equal(pwSurvivalTime1$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime1$lambda1, c(0.025, 0.04, 0.015) * 0.8)
+ expect_false(pwSurvivalTime1$isDelayedResponseEnabled())
+
+ .skipTestIfDisabled()
+
+ pwSurvivalTime2 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 5, 10),
+ lambda2 = c(0.1, 0.2, 0.8), hazardRatio = 0.8
+ )
+ expect_true(pwSurvivalTime2$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime2$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime2$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, c(0, 5, 10))
+ expect_equal(pwSurvivalTime2$lambda2, c(0.1, 0.2, 0.8))
+
+ pwSurvivalTime3 <- getPiecewiseSurvivalTime(c(0, 6), lambda2 = c(0.01, 0.03), hazardRatio = 0.8)
+ expect_true(pwSurvivalTime3$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime3$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime3$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, c(0, 6))
+ expect_equal(pwSurvivalTime3$lambda2, c(0.01, 0.03))
+
+ pwSurvivalTime4 <- getPiecewiseSurvivalTime(0, lambda2 = 0.01, hazardRatio = 0.8)
+ expect_true(pwSurvivalTime4$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime4$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime4$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime4$piecewiseSurvivalTime, 0)
+ expect_equal(pwSurvivalTime4$lambda2, 0.01)
+ expect_equal(pwSurvivalTime4$lambda1, 0.01 * 0.8)
+
+ pwSurvivalTime5 <- getPiecewiseSurvivalTime(NA_real_, lambda2 = 0.01, hazardRatio = 0.8)
+ expect_true(pwSurvivalTime5$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime5$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime5$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime5$piecewiseSurvivalTime, 0)
+ expect_equal(pwSurvivalTime5$lambda2, 0.01)
+ expect_equal(pwSurvivalTime5$lambda1, 0.01 * 0.8)
+
+ pwSurvivalTime6 <- getPiecewiseSurvivalTime(0, lambda2 = 0.01, lambda1 = 0.008)
+ expect_true(pwSurvivalTime6$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime6$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime6$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime6$piecewiseSurvivalTime, 0)
+ expect_equal(pwSurvivalTime6$lambda2, 0.01)
+ expect_equal(pwSurvivalTime6$lambda1, 0.008)
+
+ pwSurvivalTime7 <- getPiecewiseSurvivalTime(NA_real_, lambda2 = 0.01, lambda1 = 0.008)
+ expect_true(pwSurvivalTime7$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime7$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime7$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTime7$piecewiseSurvivalTime, 0)
+ expect_equal(pwSurvivalTime7$lambda2, 0.01)
+ expect_equal(pwSurvivalTime7$lambda1, 0.008)
+
+ # case 2.2
+ pwSurvivalTime9 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 6, 9),
+ lambda2 = c(0.025, 0.04, 0.015),
+ lambda1 = c(0.025, 0.04, 0.015) * 0.8
+ )
+ expect_true(pwSurvivalTime9$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime9$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime9$hazardRatio, 0.8)
+
+ pwSurvivalTime10 <- getPiecewiseSurvivalTime(lambda2 = 0.025, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime10' with expected results
+ expect_equal(pwSurvivalTime10$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime10$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime10$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime10$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime10$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime10$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime10), NA)))
+ expect_output(print(pwSurvivalTime10)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime10), NA)))
+ expect_output(summary(pwSurvivalTime10)$show())
+ pwSurvivalTime10CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime10, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalTime, pwSurvivalTime10$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$lambda1, pwSurvivalTime10$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$lambda2, pwSurvivalTime10$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$hazardRatio, pwSurvivalTime10$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$pi1, pwSurvivalTime10$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$pi2, pwSurvivalTime10$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$median1, pwSurvivalTime10$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$median2, pwSurvivalTime10$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$eventTime, pwSurvivalTime10$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$kappa, pwSurvivalTime10$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime10$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$delayedResponseAllowed, pwSurvivalTime10$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime10CodeBased$delayedResponseEnabled, pwSurvivalTime10$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime10), "character")
+ df <- as.data.frame(pwSurvivalTime10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime11 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = 0, lambda2 = 0.025, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime11' with expected results
+ expect_equal(pwSurvivalTime11$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime11$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime11$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime11$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime11$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime11$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime11), NA)))
+ expect_output(print(pwSurvivalTime11)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime11), NA)))
+ expect_output(summary(pwSurvivalTime11)$show())
+ pwSurvivalTime11CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime11, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalTime, pwSurvivalTime11$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$lambda1, pwSurvivalTime11$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$lambda2, pwSurvivalTime11$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$hazardRatio, pwSurvivalTime11$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$pi1, pwSurvivalTime11$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$pi2, pwSurvivalTime11$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$median1, pwSurvivalTime11$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$median2, pwSurvivalTime11$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$eventTime, pwSurvivalTime11$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$kappa, pwSurvivalTime11$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime11$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$delayedResponseAllowed, pwSurvivalTime11$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime11CodeBased$delayedResponseEnabled, pwSurvivalTime11$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime11), "character")
+ df <- as.data.frame(pwSurvivalTime11)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime11)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime12 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = c(0.025, 0.01), hazardRatio = c(0.8, 0.9))
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime12' with expected results
+ expect_equal(pwSurvivalTime12$piecewiseSurvivalTime, c(0, 6), label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$lambda1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$lambda2, c(0.025, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$hazardRatio, c(0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime12$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$median1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$median2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime12$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime12$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$piecewiseSurvivalEnabled, TRUE, label = paste0("c(", paste0(pwSurvivalTime12$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime12$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime12$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime12), NA)))
+ expect_output(print(pwSurvivalTime12)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime12), NA)))
+ expect_output(summary(pwSurvivalTime12)$show())
+ pwSurvivalTime12CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime12, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalTime, pwSurvivalTime12$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$lambda1, pwSurvivalTime12$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$lambda2, pwSurvivalTime12$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$hazardRatio, pwSurvivalTime12$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$pi1, pwSurvivalTime12$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$pi2, pwSurvivalTime12$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$median1, pwSurvivalTime12$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$median2, pwSurvivalTime12$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$eventTime, pwSurvivalTime12$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$kappa, pwSurvivalTime12$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime12$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$delayedResponseAllowed, pwSurvivalTime12$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime12CodeBased$delayedResponseEnabled, pwSurvivalTime12$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime12), "character")
+ df <- as.data.frame(pwSurvivalTime12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime13 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = c(0.025, 0.01), hazardRatio = c(0.8, 0.9), delayedResponseAllowed = TRUE)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime13' with expected results
+ expect_equal(pwSurvivalTime13$piecewiseSurvivalTime, c(0, 6), label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$lambda1, c(0.02, 0.009), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$lambda2, c(0.025, 0.01), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$hazardRatio, c(0.8, 0.9), tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime13$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$median1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$median2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime13$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime13$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$piecewiseSurvivalEnabled, TRUE, label = paste0("c(", paste0(pwSurvivalTime13$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$delayedResponseAllowed, TRUE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime13$delayedResponseEnabled, TRUE, label = paste0("c(", paste0(pwSurvivalTime13$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime13), NA)))
+ expect_output(print(pwSurvivalTime13)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime13), NA)))
+ expect_output(summary(pwSurvivalTime13)$show())
+ pwSurvivalTime13CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime13, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalTime, pwSurvivalTime13$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$lambda1, pwSurvivalTime13$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$lambda2, pwSurvivalTime13$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$hazardRatio, pwSurvivalTime13$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$pi1, pwSurvivalTime13$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$pi2, pwSurvivalTime13$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$median1, pwSurvivalTime13$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$median2, pwSurvivalTime13$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$eventTime, pwSurvivalTime13$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$kappa, pwSurvivalTime13$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime13$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$delayedResponseAllowed, pwSurvivalTime13$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime13CodeBased$delayedResponseEnabled, pwSurvivalTime13$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime13), "character")
+ df <- as.data.frame(pwSurvivalTime13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ # case 2.2: error expected
+ expect_error(
+ getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 6, 9),
+ lambda2 = c(0.025, 0.04, 0.015),
+ lambda1 = c(0.03, 0.04, 0.025)
+ ),
+ paste0(
+ "Illegal argument: 'hazardRatio' can only be calculated if ",
+ "'unique(lambda1 / lambda2)' result in a single value; ",
+ "current result = c(1.2, 1, 1.667) (e.g., delayed response is not allowed)"
+ ),
+ fixed = TRUE
+ )
+
+ # case 3
+ expect_false(getPiecewiseSurvivalTime(delayedResponseAllowed = TRUE)$isPiecewiseSurvivalEnabled())
+ expect_false(getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = NA,
+ delayedResponseAllowed = TRUE
+ )$isPiecewiseSurvivalEnabled())
+
+ # case 3.1
+ pwSurvivalTimeSim1 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 6, 9),
+ lambda2 = c(0.025, 0.04, 0.015), hazardRatio = 0.8,
+ delayedResponseAllowed = TRUE
+ )
+ expect_equal(pwSurvivalTimeSim1$hazardRatio, 0.8)
+ expect_equal(pwSurvivalTimeSim1$lambda1, c(0.025, 0.04, 0.015) * 0.8)
+ expect_false(pwSurvivalTimeSim1$isDelayedResponseEnabled())
+
+ # case 3.2
+ pwSurvivalTimeSim2 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 6, 9),
+ lambda2 = c(0.025, 0.04, 0.015),
+ lambda1 = c(0.03, 0.04, 0.025), delayedResponseAllowed = TRUE
+ )
+ expect_true(pwSurvivalTimeSim2$isPiecewiseSurvivalEnabled())
+ expect_true(pwSurvivalTimeSim2$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTimeSim2$hazardRatio, c(1.2, 1, 5 / 3))
+
+ pwsTime1 <- getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4)
+ expect_equal(pwsTime1$.isLambdaBased(minNumberOfLambdas = 1), TRUE)
+})
+
+test_that("Testing 'getPiecewiseSurvivalTime': check error and warnings", {
+ # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
+ expect_error(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4, pi2 = 0.4),
+ "Conflicting arguments: it is not allowed to specify 'pi2' (0.4) and 'lambda2' (0.4) concurrently",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4, pi2 = 0.4, pi1 = 0.3),
+ "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda2' (0.4) concurrently",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), lambda2 = 0.4, pi2 = 0.4, pi1 = 0.3),
+ "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda2' (0.4) concurrently",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(lambda2 = 0.4, lambda1 = 0.3, pi2 = 0.4, pi1 = 0.3),
+ "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda1' (0.3) concurrently",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(lambda2 = 0.4, lambda1 = 0.3, pi2 = 0.4, pi1 = 0.3),
+ "Conflicting arguments: it is not allowed to specify 'pi1' (0.3) and 'lambda1' (0.3) concurrently",
+ fixed = TRUE
+ )
+
+ expect_equal(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi2 = 0.4)$.isPiBased(), TRUE)
+
+ expect_warning(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi2 = 0.4, pi1 = 0.3),
+ "'hazardRatio' (0.6, 0.8) will be ignored because it will be calculated",
+ fixed = TRUE
+ )
+
+ expect_warning(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi1 = 0.3),
+ "'hazardRatio' (0.6, 0.8) will be ignored because it will be calculated",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = 0.025, hazardRatio = 0.8, delayedResponseAllowed = TRUE),
+ "Illegal argument: length of 'piecewiseSurvivalTime' (2) and length of 'lambda2' (1) must be equal",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6, 12), lambda2 = 0.025, hazardRatio = 0.8, delayedResponseAllowed = TRUE),
+ "Illegal argument: length of 'piecewiseSurvivalTime' (3) and length of 'lambda2' (1) must be equal",
+ fixed = TRUE
+ )
+
+ expect_error(getPiecewiseSurvivalTime(piecewiseSurvivalTime = c(0, 6), lambda2 = 0.025, hazardRatio = 0.8),
+ "Illegal argument: length of 'piecewiseSurvivalTime' (2) and length of 'lambda2' (1) must be equal",
+ fixed = TRUE
+ )
+})
+
+test_that("Testing 'getPiecewiseSurvivalTime': list-wise definition", {
+ # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
+ pwSurvivalTime8 <- getPiecewiseSurvivalTime(piecewiseSurvivalTime = list(
+ "<6" = 0.025,
+ "6 - <9" = 0.04,
+ "9 - <15" = 0.015,
+ "15 - <21" = 0.01,
+ ">=21" = 0.007
+ ), hazardRatio = 0.6)
+ expect_true(pwSurvivalTime8$isPiecewiseSurvivalEnabled())
+ expect_false(pwSurvivalTime8$isDelayedResponseEnabled())
+ expect_equal(pwSurvivalTime8$hazardRatio, 0.6)
+ expect_equal(pwSurvivalTime8$piecewiseSurvivalTime, c(0, 6, 9, 15, 21))
+ expect_equal(pwSurvivalTime8$lambda2, c(0.025, 0.040, 0.015, 0.010, 0.007))
+ expect_equal(pwSurvivalTime8$lambda1, c(0.0150, 0.0240, 0.0090, 0.0060, 0.0042))
+
+ .skipTestIfDisabled()
+
+ result1 <- getPiecewiseSurvivalTime(list(
+ "<5" = 0.1,
+ "5 - <10" = 0.2,
+ ">=10" = 0.8
+ ), hazardRatio = 0.8)
+ expect_equal(result1$piecewiseSurvivalTime, c(0, 5, 10))
+ expect_equal(result1$lambda2, c(0.1, 0.2, 0.8))
+
+ result2 <- getPiecewiseSurvivalTime(list(
+ "0 - <5" = 0.1,
+ "5 - <10" = 0.2,
+ "10 - Inf" = 0.8
+ ), hazardRatio = 0.8)
+ expect_equal(result2$piecewiseSurvivalTime, c(0, 5, 10))
+ expect_equal(result2$lambda2, c(0.1, 0.2, 0.8))
+
+ pwSurvivalTime2 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = c(0, 5, 10),
+ lambda2 = c(0.1, 0.2, 0.8), hazardRatio = 0.8
+ )
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, c(0, 5, 10))
+ expect_equal(pwSurvivalTime2$lambda2, c(0.1, 0.2, 0.8))
+
+ pwSurvivalTime3 <- getPiecewiseSurvivalTime(c(0, 6), lambda2 = c(0.01, 0.03), hazardRatio = 0.8)
+ expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, c(0, 6))
+ expect_equal(pwSurvivalTime3$lambda2, c(0.01, 0.03))
+
+ pwSurvivalTime4 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = list("0 - ?" = 0.025),
+ hazardRatio = 0.8, delayedResponseAllowed = TRUE
+ )
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime4' with expected results
+ expect_equal(pwSurvivalTime4$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime4$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime4$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime4$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime4$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime4$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime4$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime4$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$delayedResponseAllowed, TRUE, label = paste0("c(", paste0(pwSurvivalTime4$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime4$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime4$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime4), NA)))
+ expect_output(print(pwSurvivalTime4)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime4), NA)))
+ expect_output(summary(pwSurvivalTime4)$show())
+ pwSurvivalTime4CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime4, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime4CodeBased$piecewiseSurvivalTime, pwSurvivalTime4$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$lambda1, pwSurvivalTime4$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$lambda2, pwSurvivalTime4$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$hazardRatio, pwSurvivalTime4$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$pi1, pwSurvivalTime4$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$pi2, pwSurvivalTime4$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$median1, pwSurvivalTime4$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$median2, pwSurvivalTime4$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$eventTime, pwSurvivalTime4$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$kappa, pwSurvivalTime4$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime4$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$delayedResponseAllowed, pwSurvivalTime4$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime4CodeBased$delayedResponseEnabled, pwSurvivalTime4$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime4), "character")
+ df <- as.data.frame(pwSurvivalTime4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime5 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = list("x" = 0.025),
+ hazardRatio = 0.8, delayedResponseAllowed = TRUE
+ )
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime5' with expected results
+ expect_equal(pwSurvivalTime5$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime5$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime5$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime5$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime5$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime5$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime5$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime5$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$delayedResponseAllowed, TRUE, label = paste0("c(", paste0(pwSurvivalTime5$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime5$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime5$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime5), NA)))
+ expect_output(print(pwSurvivalTime5)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime5), NA)))
+ expect_output(summary(pwSurvivalTime5)$show())
+ pwSurvivalTime5CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime5, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime5CodeBased$piecewiseSurvivalTime, pwSurvivalTime5$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$lambda1, pwSurvivalTime5$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$lambda2, pwSurvivalTime5$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$hazardRatio, pwSurvivalTime5$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$pi1, pwSurvivalTime5$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$pi2, pwSurvivalTime5$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$median1, pwSurvivalTime5$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$median2, pwSurvivalTime5$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$eventTime, pwSurvivalTime5$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$kappa, pwSurvivalTime5$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime5$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$delayedResponseAllowed, pwSurvivalTime5$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime5CodeBased$delayedResponseEnabled, pwSurvivalTime5$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime5), "character")
+ df <- as.data.frame(pwSurvivalTime5)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime5)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime6 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = list("0 - 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime6)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime7 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = list("x" = 0.025),
+ hazardRatio = 0.8, delayedResponseAllowed = FALSE
+ )
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime7' with expected results
+ expect_equal(pwSurvivalTime7$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime7$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$lambda1, 0.02, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$lambda2, 0.025, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime7$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime7$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$median1, 34.657359, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$median2, 27.725887, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime7$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime7$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime7$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime7$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime7$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime7$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime7$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime7), NA)))
+ expect_output(print(pwSurvivalTime7)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime7), NA)))
+ expect_output(summary(pwSurvivalTime7)$show())
+ pwSurvivalTime7CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime7, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime7CodeBased$piecewiseSurvivalTime, pwSurvivalTime7$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$lambda1, pwSurvivalTime7$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$lambda2, pwSurvivalTime7$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$hazardRatio, pwSurvivalTime7$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$pi1, pwSurvivalTime7$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$pi2, pwSurvivalTime7$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$median1, pwSurvivalTime7$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$median2, pwSurvivalTime7$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$eventTime, pwSurvivalTime7$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$kappa, pwSurvivalTime7$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime7$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$delayedResponseAllowed, pwSurvivalTime7$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime7CodeBased$delayedResponseEnabled, pwSurvivalTime7$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime7), "character")
+ df <- as.data.frame(pwSurvivalTime7)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime7)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime8 <- getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = list("0 - 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ expect_warning(getPiecewiseSurvivalTime(piecewiseSurvivalTime = list("<6" = 0.025), hazardRatio = 0.8),
+ "Defined time period \"0 - <6\" will be ignored because 'piecewiseSurvivalTime' list has only 1 entry",
+ fixed = TRUE
+ )
+})
+
+test_plan_section("Testing Class 'AccrualTime'")
+
+
+test_that("Testing 'getAccrualTime': isAccrualTimeEnabled()", {
+ expect_true(getAccrualTime()$isAccrualTimeEnabled())
+ expect_true(getAccrualTime(maxNumberOfSubjects = 100)$isAccrualTimeEnabled())
+})
+
+test_that("Testing 'getAccrualTime': vector based definition", {
+ accrualTime1 <- getAccrualTime(
+ accrualTime = c(0, 6, 9, 15),
+ accrualIntensity = c(15, 21, 27), maxNumberOfSubjects = 315
+ )
+ expect_equal(accrualTime1$accrualTime, c(0, 6, 9, 15))
+ expect_equal(accrualTime1$accrualIntensity, c(15, 21, 27))
+ expect_equal(accrualTime1$remainingTime, NA_real_)
+
+ accrualTime2 <- getAccrualTime(
+ accrualTime = c(0, 6, 9),
+ accrualIntensity = c(15, 21, 27), maxNumberOfSubjects = 1000
+ )
+ expect_equal(accrualTime2$accrualTime, c(0, 6, 9, 40.37037))
+ expect_equal(accrualTime2$accrualIntensity, c(15, 21, 27))
+ expect_equal(accrualTime2$remainingTime, 31.37037)
+
+ .skipTestIfDisabled()
+
+ accrualTime3 <- getAccrualTime(
+ accrualTime = c(0, 12, 13, 14, 15, 16),
+ accrualIntensity = c(15, 21, 27, 33, 39, 45), maxNumberOfSubjects = 1405
+ )
+ expect_equal(accrualTime3$accrualTime, c(0, 12, 13, 14, 15, 16, 40.55555556))
+ expect_equal(accrualTime3$accrualIntensity, c(15, 21, 27, 33, 39, 45))
+ expect_equal(accrualTime3$remainingTime, 24.55555556)
+
+ accrualTime4 <- getAccrualTime(
+ accrualTime = c(0, 24),
+ accrualIntensity = c(30), maxNumberOfSubjects = 720
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime4' with expected results
+ expect_equal(accrualTime4$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime4$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime4$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime4$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime4$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime4$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime4$accrualTime, c(0, 24), label = paste0("c(", paste0(accrualTime4$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime4$accrualIntensity, 30, label = paste0("c(", paste0(accrualTime4$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime4$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime4$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime4$maxNumberOfSubjects, 720, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime4$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime4$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime4$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime4$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime4), NA)))
+ expect_output(print(accrualTime4)$show())
+ invisible(capture.output(expect_error(summary(accrualTime4), NA)))
+ expect_output(summary(accrualTime4)$show())
+ accrualTime4CodeBased <- eval(parse(text = getObjectRCode(accrualTime4, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime4CodeBased$endOfAccrualIsUserDefined, accrualTime4$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$followUpTimeMustBeUserDefined, accrualTime4$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime4$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$absoluteAccrualIntensityEnabled, accrualTime4$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$accrualTime, accrualTime4$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$accrualIntensity, accrualTime4$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$accrualIntensityRelative, accrualTime4$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$maxNumberOfSubjects, accrualTime4$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$remainingTime, accrualTime4$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$piecewiseAccrualEnabled, accrualTime4$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime4), "character")
+ df <- as.data.frame(accrualTime4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime5 <- getAccrualTime(
+ accrualTime = c(0, 24, 30),
+ accrualIntensity = c(30, 45)
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime5' with expected results
+ expect_equal(accrualTime5$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime5$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime5$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime5$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime5$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime5$accrualTime, c(0, 24, 30), label = paste0("c(", paste0(accrualTime5$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime5$accrualIntensity, c(30, 45), label = paste0("c(", paste0(accrualTime5$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime5$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime5$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime5$maxNumberOfSubjects, 990, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime5$remainingTime, 6, label = paste0("c(", paste0(accrualTime5$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime5$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime5), NA)))
+ expect_output(print(accrualTime5)$show())
+ invisible(capture.output(expect_error(summary(accrualTime5), NA)))
+ expect_output(summary(accrualTime5)$show())
+ accrualTime5CodeBased <- eval(parse(text = getObjectRCode(accrualTime5, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime5CodeBased$endOfAccrualIsUserDefined, accrualTime5$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$followUpTimeMustBeUserDefined, accrualTime5$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime5$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$absoluteAccrualIntensityEnabled, accrualTime5$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$accrualTime, accrualTime5$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$accrualIntensity, accrualTime5$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$accrualIntensityRelative, accrualTime5$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$maxNumberOfSubjects, accrualTime5$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$remainingTime, accrualTime5$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$piecewiseAccrualEnabled, accrualTime5$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime5), "character")
+ df <- as.data.frame(accrualTime5)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime5)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime6 <- getAccrualTime(
+ accrualTime = c(0, 24, 30),
+ accrualIntensity = c(20, 25, 45), maxNumberOfSubjects = 720
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime6' with expected results
+ expect_equal(accrualTime6$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime6$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime6$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime6$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime6$accrualTime, c(0, 24, 30, 32), label = paste0("c(", paste0(accrualTime6$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime6$accrualIntensity, c(20, 25, 45), label = paste0("c(", paste0(accrualTime6$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime6$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime6$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime6$maxNumberOfSubjects, 720, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime6$remainingTime, 2, label = paste0("c(", paste0(accrualTime6$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime6$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime6), NA)))
+ expect_output(print(accrualTime6)$show())
+ invisible(capture.output(expect_error(summary(accrualTime6), NA)))
+ expect_output(summary(accrualTime6)$show())
+ accrualTime6CodeBased <- eval(parse(text = getObjectRCode(accrualTime6, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime6CodeBased$endOfAccrualIsUserDefined, accrualTime6$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$followUpTimeMustBeUserDefined, accrualTime6$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime6$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$absoluteAccrualIntensityEnabled, accrualTime6$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$accrualTime, accrualTime6$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$accrualIntensity, accrualTime6$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$accrualIntensityRelative, accrualTime6$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$maxNumberOfSubjects, accrualTime6$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$remainingTime, accrualTime6$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$piecewiseAccrualEnabled, accrualTime6$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime6), "character")
+ df <- as.data.frame(accrualTime6)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime6)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime8 <- getAccrualTime(accrualTime = 0, accrualIntensity = 15, maxNumberOfSubjects = 1000)
+
+ ## Comparison of the results of AccrualTime object 'accrualTime8' with expected results
+ expect_equal(accrualTime8$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime8$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime8$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime8$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime8$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime8$accrualTime, c(0, 66.666667), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime8$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime8$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime8$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime8$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime8$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime8$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime8$remainingTime, 66.666667, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime8$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime8$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime8$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime8), NA)))
+ expect_output(print(accrualTime8)$show())
+ invisible(capture.output(expect_error(summary(accrualTime8), NA)))
+ expect_output(summary(accrualTime8)$show())
+ accrualTime8CodeBased <- eval(parse(text = getObjectRCode(accrualTime8, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime8CodeBased$endOfAccrualIsUserDefined, accrualTime8$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$followUpTimeMustBeUserDefined, accrualTime8$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime8$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$absoluteAccrualIntensityEnabled, accrualTime8$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$accrualTime, accrualTime8$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$accrualIntensity, accrualTime8$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$accrualIntensityRelative, accrualTime8$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$maxNumberOfSubjects, accrualTime8$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$remainingTime, accrualTime8$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$piecewiseAccrualEnabled, accrualTime8$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime8), "character")
+ df <- as.data.frame(accrualTime8)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime9 <- getAccrualTime(accrualTime = c(0, 5), accrualIntensity = 15)
+
+ ## Comparison of the results of AccrualTime object 'accrualTime9' with expected results
+ expect_equal(accrualTime9$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime9$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime9$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime9$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime9$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime9$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime9$accrualTime, c(0, 5), label = paste0("c(", paste0(accrualTime9$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime9$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime9$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime9$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime9$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime9$maxNumberOfSubjects, 75, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime9$remainingTime, 5, label = paste0("c(", paste0(accrualTime9$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime9$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime9$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime9), NA)))
+ expect_output(print(accrualTime9)$show())
+ invisible(capture.output(expect_error(summary(accrualTime9), NA)))
+ expect_output(summary(accrualTime9)$show())
+ accrualTime9CodeBased <- eval(parse(text = getObjectRCode(accrualTime9, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime9CodeBased$endOfAccrualIsUserDefined, accrualTime9$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$followUpTimeMustBeUserDefined, accrualTime9$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime9$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$absoluteAccrualIntensityEnabled, accrualTime9$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$accrualTime, accrualTime9$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$accrualIntensity, accrualTime9$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$accrualIntensityRelative, accrualTime9$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$maxNumberOfSubjects, accrualTime9$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$remainingTime, accrualTime9$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$piecewiseAccrualEnabled, accrualTime9$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime9), "character")
+ df <- as.data.frame(accrualTime9)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime9)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime10 <- getAccrualTime(accrualTime = 0, accrualIntensity = 15, maxNumberOfSubjects = 10)
+
+ ## Comparison of the results of AccrualTime object 'accrualTime10' with expected results
+ expect_equal(accrualTime10$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime10$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime10$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime10$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime10$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime10$accrualTime, c(0, 0.66666667), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime10$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime10$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime10$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime10$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime10$maxNumberOfSubjects, 10, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime10$remainingTime, 0.66666667, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime10$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime10$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime10), NA)))
+ expect_output(print(accrualTime10)$show())
+ invisible(capture.output(expect_error(summary(accrualTime10), NA)))
+ expect_output(summary(accrualTime10)$show())
+ accrualTime10CodeBased <- eval(parse(text = getObjectRCode(accrualTime10, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime10CodeBased$endOfAccrualIsUserDefined, accrualTime10$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$followUpTimeMustBeUserDefined, accrualTime10$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime10$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$absoluteAccrualIntensityEnabled, accrualTime10$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$accrualTime, accrualTime10$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$accrualIntensity, accrualTime10$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$accrualIntensityRelative, accrualTime10$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$maxNumberOfSubjects, accrualTime10$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$remainingTime, accrualTime10$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$piecewiseAccrualEnabled, accrualTime10$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime10), "character")
+ df <- as.data.frame(accrualTime10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime11 <- getAccrualTime(accrualTime = c(0, 5), accrualIntensity = 15, maxNumberOfSubjects = 75)
+
+ ## Comparison of the results of AccrualTime object 'accrualTime11' with expected results
+ expect_equal(accrualTime11$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime11$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime11$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime11$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime11$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime11$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime11$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime11$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime11$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime11$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime11$accrualTime, c(0, 5), label = paste0("c(", paste0(accrualTime11$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime11$accrualIntensity, 15, label = paste0("c(", paste0(accrualTime11$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime11$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime11$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime11$maxNumberOfSubjects, 75, label = paste0("c(", paste0(accrualTime11$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime11$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime11$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime11$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime11$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime11), NA)))
+ expect_output(print(accrualTime11)$show())
+ invisible(capture.output(expect_error(summary(accrualTime11), NA)))
+ expect_output(summary(accrualTime11)$show())
+ accrualTime11CodeBased <- eval(parse(text = getObjectRCode(accrualTime11, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime11CodeBased$endOfAccrualIsUserDefined, accrualTime11$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$followUpTimeMustBeUserDefined, accrualTime11$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime11$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime11$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$absoluteAccrualIntensityEnabled, accrualTime11$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$accrualTime, accrualTime11$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$accrualIntensity, accrualTime11$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$accrualIntensityRelative, accrualTime11$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$maxNumberOfSubjects, accrualTime11$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$remainingTime, accrualTime11$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime11CodeBased$piecewiseAccrualEnabled, accrualTime11$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime11), "character")
+ df <- as.data.frame(accrualTime11)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime11)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime12 <- getAccrualTime(accrualTime = c(0, 6, 15, 25), accrualIntensity = c(22, 0, 33))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime12' with expected results
+ expect_equal(accrualTime12$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime12$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime12$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime12$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime12$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime12$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime12$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime12$accrualTime, c(0, 6, 15, 25), label = paste0("c(", paste0(accrualTime12$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime12$accrualIntensity, c(22, 0, 33), label = paste0("c(", paste0(accrualTime12$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime12$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime12$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime12$maxNumberOfSubjects, 462, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime12$remainingTime, 10, label = paste0("c(", paste0(accrualTime12$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime12$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime12$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime12), NA)))
+ expect_output(print(accrualTime12)$show())
+ invisible(capture.output(expect_error(summary(accrualTime12), NA)))
+ expect_output(summary(accrualTime12)$show())
+ accrualTime12CodeBased <- eval(parse(text = getObjectRCode(accrualTime12, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime12CodeBased$endOfAccrualIsUserDefined, accrualTime12$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$followUpTimeMustBeUserDefined, accrualTime12$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime12$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$absoluteAccrualIntensityEnabled, accrualTime12$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$accrualTime, accrualTime12$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$accrualIntensity, accrualTime12$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$accrualIntensityRelative, accrualTime12$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$maxNumberOfSubjects, accrualTime12$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$remainingTime, accrualTime12$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$piecewiseAccrualEnabled, accrualTime12$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime12), "character")
+ df <- as.data.frame(accrualTime12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime13 <- getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(22, 33), maxNumberOfSubjects = 1000)
+
+ ## Comparison of the results of AccrualTime object 'accrualTime13' with expected results
+ expect_equal(accrualTime13$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime13$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime13$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime13$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime13$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime13$accrualTime, c(0, 6, 32.30303), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime13$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime13$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime13$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime13$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime13$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime13$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime13$remainingTime, 26.30303, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime13$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime13$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime13$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime13), NA)))
+ expect_output(print(accrualTime13)$show())
+ invisible(capture.output(expect_error(summary(accrualTime13), NA)))
+ expect_output(summary(accrualTime13)$show())
+ accrualTime13CodeBased <- eval(parse(text = getObjectRCode(accrualTime13, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime13CodeBased$endOfAccrualIsUserDefined, accrualTime13$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$followUpTimeMustBeUserDefined, accrualTime13$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime13$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$absoluteAccrualIntensityEnabled, accrualTime13$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$accrualTime, accrualTime13$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$accrualIntensity, accrualTime13$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$accrualIntensityRelative, accrualTime13$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$maxNumberOfSubjects, accrualTime13$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$remainingTime, accrualTime13$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$piecewiseAccrualEnabled, accrualTime13$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime13), "character")
+ df <- as.data.frame(accrualTime13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+})
+
+test_that("Testing 'getAccrualTime': test absolute and relative definition", {
+ # @refFS[Tab.]{fs:tab:output:getAccrualTime}
+ accrualTime1 <- getAccrualTime(
+ accrualTime = c(0, 6, 30),
+ accrualIntensity = c(22, 33), maxNumberOfSubjects = 924
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime1' with expected results
+ expect_equal(accrualTime1$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime1$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime1$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime1$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime1$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime1$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime1$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime1$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime1$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime1$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime1$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime1$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime1$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime1$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime1$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime1$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime1$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime1$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime1$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime1$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime1$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime1$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime1), NA)))
+ expect_output(print(accrualTime1)$show())
+ invisible(capture.output(expect_error(summary(accrualTime1), NA)))
+ expect_output(summary(accrualTime1)$show())
+ accrualTime1CodeBased <- eval(parse(text = getObjectRCode(accrualTime1, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime1CodeBased$endOfAccrualIsUserDefined, accrualTime1$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$followUpTimeMustBeUserDefined, accrualTime1$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime1$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime1$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$absoluteAccrualIntensityEnabled, accrualTime1$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$accrualTime, accrualTime1$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$accrualIntensity, accrualTime1$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$accrualIntensityRelative, accrualTime1$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$maxNumberOfSubjects, accrualTime1$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$remainingTime, accrualTime1$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime1CodeBased$piecewiseAccrualEnabled, accrualTime1$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime1), "character")
+ df <- as.data.frame(accrualTime1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime2 <- getAccrualTime(
+ list(
+ "0 - <6" = 22,
+ "6 - <=30" = 33
+ ),
+ maxNumberOfSubjects = 924
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime2' with expected results
+ expect_equal(accrualTime2$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime2$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime2$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime2$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime2$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime2$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime2$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime2$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime2$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime2$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime2$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime2$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime2$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime2$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime2$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime2$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime2$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime2$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime2$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime2$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime2$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime2$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime2), NA)))
+ expect_output(print(accrualTime2)$show())
+ invisible(capture.output(expect_error(summary(accrualTime2), NA)))
+ expect_output(summary(accrualTime2)$show())
+ accrualTime2CodeBased <- eval(parse(text = getObjectRCode(accrualTime2, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime2CodeBased$endOfAccrualIsUserDefined, accrualTime2$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$followUpTimeMustBeUserDefined, accrualTime2$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime2$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime2$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$absoluteAccrualIntensityEnabled, accrualTime2$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$accrualTime, accrualTime2$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$accrualIntensity, accrualTime2$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$accrualIntensityRelative, accrualTime2$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$maxNumberOfSubjects, accrualTime2$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$remainingTime, accrualTime2$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime2CodeBased$piecewiseAccrualEnabled, accrualTime2$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime2), "character")
+ df <- as.data.frame(accrualTime2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ .skipTestIfDisabled()
+
+ accrualTime3 <- getAccrualTime(
+ accrualTime = c(0, 6, 30),
+ accrualIntensity = c(0.22, 0.33), maxNumberOfSubjects = 1000
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime3' with expected results
+ expect_equal(accrualTime3$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime3$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime3$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime3$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime3$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime3$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime3$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime3$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime3$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime3$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime3$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime3$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime3$accrualIntensity, c(23.809524, 35.714286), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime3$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime3$accrualIntensityRelative, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime3$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime3$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime3$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime3$remainingTime, 24, label = paste0("c(", paste0(accrualTime3$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime3$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime3$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime3), NA)))
+ expect_output(print(accrualTime3)$show())
+ invisible(capture.output(expect_error(summary(accrualTime3), NA)))
+ expect_output(summary(accrualTime3)$show())
+ accrualTime3CodeBased <- eval(parse(text = getObjectRCode(accrualTime3, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime3CodeBased$endOfAccrualIsUserDefined, accrualTime3$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$followUpTimeMustBeUserDefined, accrualTime3$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime3$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime3$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$absoluteAccrualIntensityEnabled, accrualTime3$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$accrualTime, accrualTime3$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$accrualIntensity, accrualTime3$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$accrualIntensityRelative, accrualTime3$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$maxNumberOfSubjects, accrualTime3$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$remainingTime, accrualTime3$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime3CodeBased$piecewiseAccrualEnabled, accrualTime3$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime3), "character")
+ df <- as.data.frame(accrualTime3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime4 <- getAccrualTime(
+ list(
+ "0 - <6" = 0.22,
+ "6 - <=30" = 0.33
+ ),
+ maxNumberOfSubjects = 1000
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime4' with expected results
+ expect_equal(accrualTime4$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime4$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime4$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime4$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime4$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime4$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime4$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime4$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime4$accrualIntensity, c(23.809524, 35.714286), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime4$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime4$accrualIntensityRelative, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime4$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime4$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime4$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime4$remainingTime, 24, label = paste0("c(", paste0(accrualTime4$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime4$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime4$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime4), NA)))
+ expect_output(print(accrualTime4)$show())
+ invisible(capture.output(expect_error(summary(accrualTime4), NA)))
+ expect_output(summary(accrualTime4)$show())
+ accrualTime4CodeBased <- eval(parse(text = getObjectRCode(accrualTime4, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime4CodeBased$endOfAccrualIsUserDefined, accrualTime4$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$followUpTimeMustBeUserDefined, accrualTime4$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime4$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime4$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$absoluteAccrualIntensityEnabled, accrualTime4$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$accrualTime, accrualTime4$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$accrualIntensity, accrualTime4$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$accrualIntensityRelative, accrualTime4$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$maxNumberOfSubjects, accrualTime4$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$remainingTime, accrualTime4$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime4CodeBased$piecewiseAccrualEnabled, accrualTime4$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime4), "character")
+ df <- as.data.frame(accrualTime4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime5 <- getAccrualTime(accrualTime = c(0, 6, 30), accrualIntensity = c(22, 33))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime5' with expected results
+ expect_equal(accrualTime5$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime5$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime5$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime5$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime5$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime5$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime5$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime5$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime5$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime5$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime5$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime5$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime5$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime5$remainingTime, 24, label = paste0("c(", paste0(accrualTime5$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime5$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime5$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime5), NA)))
+ expect_output(print(accrualTime5)$show())
+ invisible(capture.output(expect_error(summary(accrualTime5), NA)))
+ expect_output(summary(accrualTime5)$show())
+ accrualTime5CodeBased <- eval(parse(text = getObjectRCode(accrualTime5, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime5CodeBased$endOfAccrualIsUserDefined, accrualTime5$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$followUpTimeMustBeUserDefined, accrualTime5$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime5$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime5$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$absoluteAccrualIntensityEnabled, accrualTime5$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$accrualTime, accrualTime5$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$accrualIntensity, accrualTime5$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$accrualIntensityRelative, accrualTime5$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$maxNumberOfSubjects, accrualTime5$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$remainingTime, accrualTime5$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime5CodeBased$piecewiseAccrualEnabled, accrualTime5$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime5), "character")
+ df <- as.data.frame(accrualTime5)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime5)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime6 <- getAccrualTime(list(
+ "0 - <6" = 22,
+ "6 - <=30" = 33
+ ))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime6' with expected results
+ expect_equal(accrualTime6$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime6$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime6$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime6$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime6$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime6$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime6$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime6$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime6$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime6$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime6$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime6$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime6$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime6$remainingTime, 24, label = paste0("c(", paste0(accrualTime6$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime6$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime6$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime6), NA)))
+ expect_output(print(accrualTime6)$show())
+ invisible(capture.output(expect_error(summary(accrualTime6), NA)))
+ expect_output(summary(accrualTime6)$show())
+ accrualTime6CodeBased <- eval(parse(text = getObjectRCode(accrualTime6, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime6CodeBased$endOfAccrualIsUserDefined, accrualTime6$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$followUpTimeMustBeUserDefined, accrualTime6$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime6$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime6$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$absoluteAccrualIntensityEnabled, accrualTime6$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$accrualTime, accrualTime6$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$accrualIntensity, accrualTime6$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$accrualIntensityRelative, accrualTime6$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$maxNumberOfSubjects, accrualTime6$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$remainingTime, accrualTime6$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime6CodeBased$piecewiseAccrualEnabled, accrualTime6$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime6), "character")
+ df <- as.data.frame(accrualTime6)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime6)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime7 <- getAccrualTime(accrualTime = c(0, 6, 30), accrualIntensity = c(0.22, 0.33))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime7' with expected results
+ expect_equal(accrualTime7$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime7$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime7$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime7$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime7$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime7$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime7$maxNumberOfSubjectsCanBeCalculatedDirectly, FALSE, label = paste0("c(", paste0(accrualTime7$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime7$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime7$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime7$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime7$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime7$accrualIntensity, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime7$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime7$accrualIntensityRelative, c(0.22, 0.33), label = paste0("c(", paste0(accrualTime7$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime7$maxNumberOfSubjects, NA_real_, label = paste0("c(", paste0(accrualTime7$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime7$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime7$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime7$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime7$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime7), NA)))
+ expect_output(print(accrualTime7)$show())
+ invisible(capture.output(expect_error(summary(accrualTime7), NA)))
+ expect_output(summary(accrualTime7)$show())
+ accrualTime7CodeBased <- eval(parse(text = getObjectRCode(accrualTime7, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime7CodeBased$endOfAccrualIsUserDefined, accrualTime7$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$followUpTimeMustBeUserDefined, accrualTime7$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime7$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime7$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$absoluteAccrualIntensityEnabled, accrualTime7$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$accrualTime, accrualTime7$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$accrualIntensity, accrualTime7$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$accrualIntensityRelative, accrualTime7$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$maxNumberOfSubjects, accrualTime7$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$remainingTime, accrualTime7$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime7CodeBased$piecewiseAccrualEnabled, accrualTime7$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime7), "character")
+ df <- as.data.frame(accrualTime7)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime7)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime8 <- getAccrualTime(list(
+ "0 - <6" = 0.22,
+ "6 - <=30" = 0.33
+ ))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime8' with expected results
+ expect_equal(accrualTime8$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime8$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime8$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime8$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, FALSE, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime8$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime8$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime8$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime8$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime8$accrualIntensity, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime8$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime8$accrualIntensityRelative, c(0.22, 0.33), label = paste0("c(", paste0(accrualTime8$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime8$maxNumberOfSubjects, NA_real_, label = paste0("c(", paste0(accrualTime8$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime8$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime8$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime8$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime8$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime8), NA)))
+ expect_output(print(accrualTime8)$show())
+ invisible(capture.output(expect_error(summary(accrualTime8), NA)))
+ expect_output(summary(accrualTime8)$show())
+ accrualTime8CodeBased <- eval(parse(text = getObjectRCode(accrualTime8, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime8CodeBased$endOfAccrualIsUserDefined, accrualTime8$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$followUpTimeMustBeUserDefined, accrualTime8$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime8$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime8$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$absoluteAccrualIntensityEnabled, accrualTime8$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$accrualTime, accrualTime8$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$accrualIntensity, accrualTime8$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$accrualIntensityRelative, accrualTime8$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$maxNumberOfSubjects, accrualTime8$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$remainingTime, accrualTime8$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime8CodeBased$piecewiseAccrualEnabled, accrualTime8$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime8), "character")
+ df <- as.data.frame(accrualTime8)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime8)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime9 <- getAccrualTime(
+ accrualTime = c(0, 6),
+ accrualIntensity = c(22, 33), maxNumberOfSubjects = 1000
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime9' with expected results
+ expect_equal(accrualTime9$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime9$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime9$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime9$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime9$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime9$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime9$accrualTime, c(0, 6, 32.30303), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime9$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime9$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime9$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime9$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime9$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime9$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime9$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime9$remainingTime, 26.30303, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime9$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime9$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime9$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime9), NA)))
+ expect_output(print(accrualTime9)$show())
+ invisible(capture.output(expect_error(summary(accrualTime9), NA)))
+ expect_output(summary(accrualTime9)$show())
+ accrualTime9CodeBased <- eval(parse(text = getObjectRCode(accrualTime9, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime9CodeBased$endOfAccrualIsUserDefined, accrualTime9$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$followUpTimeMustBeUserDefined, accrualTime9$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime9$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime9$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$absoluteAccrualIntensityEnabled, accrualTime9$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$accrualTime, accrualTime9$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$accrualIntensity, accrualTime9$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$accrualIntensityRelative, accrualTime9$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$maxNumberOfSubjects, accrualTime9$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$remainingTime, accrualTime9$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime9CodeBased$piecewiseAccrualEnabled, accrualTime9$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime9), "character")
+ df <- as.data.frame(accrualTime9)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime9)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime10 <- getAccrualTime(
+ list(
+ "0 - <6" = 22,
+ "6" = 33
+ ),
+ maxNumberOfSubjects = 1000
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime10' with expected results
+ expect_equal(accrualTime10$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime10$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime10$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime10$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime10$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime10$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime10$accrualTime, c(0, 6, 32.30303), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime10$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime10$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime10$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime10$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime10$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime10$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime10$remainingTime, 26.30303, tolerance = 1e-07, label = paste0("c(", paste0(accrualTime10$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime10$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime10$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime10), NA)))
+ expect_output(print(accrualTime10)$show())
+ invisible(capture.output(expect_error(summary(accrualTime10), NA)))
+ expect_output(summary(accrualTime10)$show())
+ accrualTime10CodeBased <- eval(parse(text = getObjectRCode(accrualTime10, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime10CodeBased$endOfAccrualIsUserDefined, accrualTime10$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$followUpTimeMustBeUserDefined, accrualTime10$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime10$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime10$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$absoluteAccrualIntensityEnabled, accrualTime10$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$accrualTime, accrualTime10$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$accrualIntensity, accrualTime10$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$accrualIntensityRelative, accrualTime10$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$maxNumberOfSubjects, accrualTime10$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$remainingTime, accrualTime10$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime10CodeBased$piecewiseAccrualEnabled, accrualTime10$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime10), "character")
+ df <- as.data.frame(accrualTime10)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime10)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime12 <- getAccrualTime(
+ list(
+ "0 - <6" = 0.22,
+ "6 - <=30" = 0.33
+ ),
+ maxNumberOfSubjects = 1000
+ )
+
+ ## Comparison of the results of AccrualTime object 'accrualTime12' with expected results
+ expect_equal(accrualTime12$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime12$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime12$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime12$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime12$maxNumberOfSubjectsIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime12$absoluteAccrualIntensityEnabled, FALSE, label = paste0("c(", paste0(accrualTime12$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime12$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime12$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime12$accrualIntensity, c(23.809524, 35.714286), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime12$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime12$accrualIntensityRelative, c(0.22, 0.33), tolerance = 1e-07, label = paste0("c(", paste0(accrualTime12$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime12$maxNumberOfSubjects, 1000, label = paste0("c(", paste0(accrualTime12$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime12$remainingTime, 24, label = paste0("c(", paste0(accrualTime12$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime12$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime12$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime12), NA)))
+ expect_output(print(accrualTime12)$show())
+ invisible(capture.output(expect_error(summary(accrualTime12), NA)))
+ expect_output(summary(accrualTime12)$show())
+ accrualTime12CodeBased <- eval(parse(text = getObjectRCode(accrualTime12, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime12CodeBased$endOfAccrualIsUserDefined, accrualTime12$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$followUpTimeMustBeUserDefined, accrualTime12$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime12$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime12$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$absoluteAccrualIntensityEnabled, accrualTime12$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$accrualTime, accrualTime12$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$accrualIntensity, accrualTime12$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$accrualIntensityRelative, accrualTime12$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$maxNumberOfSubjects, accrualTime12$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$remainingTime, accrualTime12$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime12CodeBased$piecewiseAccrualEnabled, accrualTime12$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime12), "character")
+ df <- as.data.frame(accrualTime12)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime12)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime13 <- getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(22, 33))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime13' with expected results
+ expect_equal(accrualTime13$endOfAccrualIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime13$followUpTimeMustBeUserDefined, TRUE, label = paste0("c(", paste0(accrualTime13$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime13$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, FALSE, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime13$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime13$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime13$accrualTime, c(0, 6), label = paste0("c(", paste0(accrualTime13$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime13$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime13$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime13$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime13$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime13$maxNumberOfSubjects, NA_real_, label = paste0("c(", paste0(accrualTime13$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime13$remainingTime, NA_real_, label = paste0("c(", paste0(accrualTime13$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime13$piecewiseAccrualEnabled, FALSE, label = paste0("c(", paste0(accrualTime13$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime13), NA)))
+ expect_output(print(accrualTime13)$show())
+ invisible(capture.output(expect_error(summary(accrualTime13), NA)))
+ expect_output(summary(accrualTime13)$show())
+ accrualTime13CodeBased <- eval(parse(text = getObjectRCode(accrualTime13, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime13CodeBased$endOfAccrualIsUserDefined, accrualTime13$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$followUpTimeMustBeUserDefined, accrualTime13$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime13$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime13$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$absoluteAccrualIntensityEnabled, accrualTime13$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$accrualTime, accrualTime13$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$accrualIntensity, accrualTime13$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$accrualIntensityRelative, accrualTime13$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$maxNumberOfSubjects, accrualTime13$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$remainingTime, accrualTime13$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime13CodeBased$piecewiseAccrualEnabled, accrualTime13$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime13), "character")
+ df <- as.data.frame(accrualTime13)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime13)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ accrualTime14 <- getAccrualTime(list(
+ "0 - <6" = 22,
+ "6 - <=30" = 33
+ ))
+
+ ## Comparison of the results of AccrualTime object 'accrualTime14' with expected results
+ expect_equal(accrualTime14$endOfAccrualIsUserDefined, TRUE, label = paste0("c(", paste0(accrualTime14$endOfAccrualIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime14$followUpTimeMustBeUserDefined, FALSE, label = paste0("c(", paste0(accrualTime14$followUpTimeMustBeUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime14$maxNumberOfSubjectsIsUserDefined, FALSE, label = paste0("c(", paste0(accrualTime14$maxNumberOfSubjectsIsUserDefined, collapse = ", "), ")"))
+ expect_equal(accrualTime14$maxNumberOfSubjectsCanBeCalculatedDirectly, TRUE, label = paste0("c(", paste0(accrualTime14$maxNumberOfSubjectsCanBeCalculatedDirectly, collapse = ", "), ")"))
+ expect_equal(accrualTime14$absoluteAccrualIntensityEnabled, TRUE, label = paste0("c(", paste0(accrualTime14$absoluteAccrualIntensityEnabled, collapse = ", "), ")"))
+ expect_equal(accrualTime14$accrualTime, c(0, 6, 30), label = paste0("c(", paste0(accrualTime14$accrualTime, collapse = ", "), ")"))
+ expect_equal(accrualTime14$accrualIntensity, c(22, 33), label = paste0("c(", paste0(accrualTime14$accrualIntensity, collapse = ", "), ")"))
+ expect_equal(accrualTime14$accrualIntensityRelative, NA_real_, label = paste0("c(", paste0(accrualTime14$accrualIntensityRelative, collapse = ", "), ")"))
+ expect_equal(accrualTime14$maxNumberOfSubjects, 924, label = paste0("c(", paste0(accrualTime14$maxNumberOfSubjects, collapse = ", "), ")"))
+ expect_equal(accrualTime14$remainingTime, 24, label = paste0("c(", paste0(accrualTime14$remainingTime, collapse = ", "), ")"))
+ expect_equal(accrualTime14$piecewiseAccrualEnabled, TRUE, label = paste0("c(", paste0(accrualTime14$piecewiseAccrualEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(accrualTime14), NA)))
+ expect_output(print(accrualTime14)$show())
+ invisible(capture.output(expect_error(summary(accrualTime14), NA)))
+ expect_output(summary(accrualTime14)$show())
+ accrualTime14CodeBased <- eval(parse(text = getObjectRCode(accrualTime14, stringWrapParagraphWidth = NULL)))
+ expect_equal(accrualTime14CodeBased$endOfAccrualIsUserDefined, accrualTime14$endOfAccrualIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$followUpTimeMustBeUserDefined, accrualTime14$followUpTimeMustBeUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$maxNumberOfSubjectsIsUserDefined, accrualTime14$maxNumberOfSubjectsIsUserDefined, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$maxNumberOfSubjectsCanBeCalculatedDirectly, accrualTime14$maxNumberOfSubjectsCanBeCalculatedDirectly, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$absoluteAccrualIntensityEnabled, accrualTime14$absoluteAccrualIntensityEnabled, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$accrualTime, accrualTime14$accrualTime, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$accrualIntensity, accrualTime14$accrualIntensity, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$accrualIntensityRelative, accrualTime14$accrualIntensityRelative, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$maxNumberOfSubjects, accrualTime14$maxNumberOfSubjects, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$remainingTime, accrualTime14$remainingTime, tolerance = 1e-07)
+ expect_equal(accrualTime14CodeBased$piecewiseAccrualEnabled, accrualTime14$piecewiseAccrualEnabled, tolerance = 1e-07)
+ expect_type(names(accrualTime14), "character")
+ df <- as.data.frame(accrualTime14)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(accrualTime14)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+})
+
+test_that("Testing 'getAccrualTime': check expected warnings and errors", {
+ # @refFS[Tab.]{fs:tab:output:getAccrualTime}
+ expect_warning(getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(0.22, 0.33)),
+ paste0(
+ "The specified accrual time and intensity cannot be supplemented ",
+ "automatically with the missing information; therefore further calculations are not possible"
+ ),
+ fixed = TRUE
+ )
+
+ expect_warning(getAccrualTime(accrualTime = c(0, 24), accrualIntensity = c(30, 45), maxNumberOfSubjects = 720),
+ "Last accrual intensity value (45) ignored",
+ fixed = TRUE
+ )
+
+ .skipTestIfDisabled()
+
+ suppressWarnings(expect_warning(
+ getAccrualTime(
+ accrualTime = c(0, 24, 30),
+ accrualIntensity = c(30, 45, 55), maxNumberOfSubjects = 720
+ ),
+ "Last 2 accrual intensity values (45, 55) ignored",
+ fixed = TRUE
+ ))
+
+ suppressWarnings(expect_warning(
+ getAccrualTime(
+ accrualTime = c(0, 24, 30, 40),
+ accrualIntensity = c(30, 45, 55, 66), maxNumberOfSubjects = 720
+ ),
+ "Last 2 accrual time values (30, 40) ignored",
+ fixed = TRUE
+ ))
+
+ suppressWarnings(expect_warning(
+ getAccrualTime(
+ accrualTime = c(0, 24, 30, 40),
+ accrualIntensity = c(30, 45, 55, 66), maxNumberOfSubjects = 720
+ ),
+ "Last 3 accrual intensity values (45, 55, 66) ignored",
+ fixed = TRUE
+ ))
+
+ expect_warning(getAccrualTime(accrualTime = c(0, 6, 15, 25), accrualIntensity = c(0, 22, 33)),
+ "It makes no sense to start 'accrualIntensity' (0, 22, 33) with 0",
+ fixed = TRUE
+ )
+
+ expect_error(getAccrualTime(accrualTime = c(0, 6), accrualIntensity = c(0)),
+ "Illegal argument: at least one 'accrualIntensity' value must be > 0",
+ fixed = TRUE
+ )
+
+ expect_error(
+ getAccrualTime(
+ accrualTime = c(0, 6, 30), accrualIntensity = c(22, 33),
+ maxNumberOfSubjects = 1000
+ ),
+ paste0(
+ "Conflicting arguments: 'maxNumberOfSubjects' (1000) disagrees with the defined ",
+ "accrual time (0, 6, 30) and intensity: 6 * 22 + 24 * 33 = 924"
+ ),
+ fixed = TRUE
+ )
+})
+
+test_that("Testing 'getAccrualTime': list-wise definition", {
+ accrualTime1 <- list(
+ "0 - <12" = 15,
+ "12 - <13" = 21,
+ "13 - <14" = 27,
+ "14 - <15" = 33,
+ "15 - <16" = 39,
+ ">=16" = 45
+ )
+
+ # @refFS[Tab.]{fs:tab:output:getAccrualTime}
+ accrualTime4 <- getAccrualTime(accrualTime = accrualTime1, maxNumberOfSubjects = 1405)
+ expect_equal(accrualTime4$accrualTime, c(0, 12, 13, 14, 15, 16, 40.55555556))
+ expect_equal(accrualTime4$accrualIntensity, c(15, 21, 27, 33, 39, 45))
+ expect_equal(accrualTime4$remainingTime, 24.55555556)
+
+ .skipTestIfDisabled()
+
+ accrualTime2 <- list(
+ "0 - <12" = 15,
+ "12 - <13" = 21,
+ "13 - <14" = 27,
+ "14 - <15" = 33,
+ "15 - <16" = 39,
+ "16 - ?" = 45
+ )
+ accrualTime5 <- getAccrualTime(accrualTime = accrualTime2, maxNumberOfSubjects = 1405)
+ expect_equal(accrualTime5$accrualTime, c(0, 12, 13, 14, 15, 16, 40.55555556))
+ expect_equal(accrualTime5$accrualIntensity, c(15, 21, 27, 33, 39, 45))
+ expect_equal(accrualTime5$remainingTime, 24.55555556)
+
+ accrualTime3 <- list(
+ "0 - <11" = 20,
+ "11 - <16" = 40,
+ ">=16" = 60
+ )
+ accrualTime6 <- getAccrualTime(accrualTime = accrualTime3, maxNumberOfSubjects = 800)
+ expect_equal(accrualTime6$accrualTime, c(0, 11, 16, 22.3333333))
+ expect_equal(accrualTime6$accrualIntensity, c(20, 40, 60))
+ expect_equal(accrualTime6$remainingTime, 6.33333333)
+
+ accrualTime7 <- list(
+ "0 - <11" = 20,
+ "11 - <16" = 40,
+ "16 - ?" = 60
+ )
+ accrualTime8 <- getAccrualTime(accrualTime = accrualTime7, maxNumberOfSubjects = 800)
+ expect_equal(accrualTime8$accrualTime, c(0, 11, 16, 22.3333333))
+ expect_equal(accrualTime8$accrualIntensity, c(20, 40, 60))
+ expect_equal(accrualTime8$remainingTime, 6.33333333)
+})
+
+test_that("Testing 'getPiecewiseSurvivalTime': mixed arguments", {
+ # @refFS[Tab.]{fs:tab:output:getPiecewiseSurvivalTime}
+ pwSurvivalTime1 <- getPiecewiseSurvivalTime(median1 = 37, hazardRatio = 0.8)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime1' with expected results
+ expect_equal(pwSurvivalTime1$piecewiseSurvivalTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$lambda1, 0.018733708, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$lambda2, 0.023417134, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$hazardRatio, 0.8, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$median1, 37, label = paste0("c(", paste0(pwSurvivalTime1$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$median2, 29.6, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime1$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime1$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime1$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime1$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime1$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime1), NA)))
+ expect_output(print(pwSurvivalTime1)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime1), NA)))
+ expect_output(summary(pwSurvivalTime1)$show())
+ pwSurvivalTime1CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime1, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalTime, pwSurvivalTime1$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$lambda1, pwSurvivalTime1$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$lambda2, pwSurvivalTime1$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$hazardRatio, pwSurvivalTime1$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$pi1, pwSurvivalTime1$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$pi2, pwSurvivalTime1$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$median1, pwSurvivalTime1$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$median2, pwSurvivalTime1$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$eventTime, pwSurvivalTime1$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$kappa, pwSurvivalTime1$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime1$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$delayedResponseAllowed, pwSurvivalTime1$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime1CodeBased$delayedResponseEnabled, pwSurvivalTime1$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime1), "character")
+ df <- as.data.frame(pwSurvivalTime1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime2 <- getPiecewiseSurvivalTime(lambda1 = 0.01873371, median2 = 29.6)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime2' with expected results
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda1, 0.01873371, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$lambda2, 0.023417134, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$hazardRatio, 0.8000001, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median1, 36.999995, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$median2, 29.6, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime2$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime2$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime2$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime2$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime2$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime2), NA)))
+ expect_output(print(pwSurvivalTime2)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime2), NA)))
+ expect_output(summary(pwSurvivalTime2)$show())
+ pwSurvivalTime2CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime2, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalTime, pwSurvivalTime2$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda1, pwSurvivalTime2$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$lambda2, pwSurvivalTime2$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$hazardRatio, pwSurvivalTime2$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi1, pwSurvivalTime2$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$pi2, pwSurvivalTime2$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median1, pwSurvivalTime2$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$median2, pwSurvivalTime2$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$eventTime, pwSurvivalTime2$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$kappa, pwSurvivalTime2$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime2$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseAllowed, pwSurvivalTime2$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime2CodeBased$delayedResponseEnabled, pwSurvivalTime2$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime2), "character")
+ df <- as.data.frame(pwSurvivalTime2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ pwSurvivalTime3 <- getPiecewiseSurvivalTime(median1 = 37, lambda2 = 0.02341713)
+
+ ## Comparison of the results of PiecewiseSurvivalTime object 'pwSurvivalTime3' with expected results
+ expect_equal(pwSurvivalTime3$piecewiseSurvivalTime, 0, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$lambda1, 0.018733708, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$lambda2, 0.02341713, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$lambda2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$hazardRatio, 0.80000015, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$hazardRatio, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$pi1, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$pi2, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$pi2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$median1, 37, label = paste0("c(", paste0(pwSurvivalTime3$median1, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$median2, 29.600006, tolerance = 1e-07, label = paste0("c(", paste0(pwSurvivalTime3$median2, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$eventTime, NA_real_, label = paste0("c(", paste0(pwSurvivalTime3$eventTime, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$kappa, 1, label = paste0("c(", paste0(pwSurvivalTime3$kappa, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$piecewiseSurvivalEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$piecewiseSurvivalEnabled, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$delayedResponseAllowed, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseAllowed, collapse = ", "), ")"))
+ expect_equal(pwSurvivalTime3$delayedResponseEnabled, FALSE, label = paste0("c(", paste0(pwSurvivalTime3$delayedResponseEnabled, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(pwSurvivalTime3), NA)))
+ expect_output(print(pwSurvivalTime3)$show())
+ invisible(capture.output(expect_error(summary(pwSurvivalTime3), NA)))
+ expect_output(summary(pwSurvivalTime3)$show())
+ pwSurvivalTime3CodeBased <- eval(parse(text = getObjectRCode(pwSurvivalTime3, stringWrapParagraphWidth = NULL)))
+ expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalTime, pwSurvivalTime3$piecewiseSurvivalTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$lambda1, pwSurvivalTime3$lambda1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$lambda2, pwSurvivalTime3$lambda2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$hazardRatio, pwSurvivalTime3$hazardRatio, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$pi1, pwSurvivalTime3$pi1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$pi2, pwSurvivalTime3$pi2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$median1, pwSurvivalTime3$median1, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$median2, pwSurvivalTime3$median2, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$eventTime, pwSurvivalTime3$eventTime, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$kappa, pwSurvivalTime3$kappa, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$piecewiseSurvivalEnabled, pwSurvivalTime3$piecewiseSurvivalEnabled, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$delayedResponseAllowed, pwSurvivalTime3$delayedResponseAllowed, tolerance = 1e-07)
+ expect_equal(pwSurvivalTime3CodeBased$delayedResponseEnabled, pwSurvivalTime3$delayedResponseEnabled, tolerance = 1e-07)
+ expect_type(names(pwSurvivalTime3), "character")
+ df <- as.data.frame(pwSurvivalTime3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(pwSurvivalTime3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ expect_warning(getPiecewiseSurvivalTime(hazardRatio = c(0.6, 0.8), pi1 = 0.3),
+ "'hazardRatio' (0.6, 0.8) will be ignored because it will be calculated",
+ fixed = TRUE
+ )
+})
+
+test_that("Testing 'getAccrualTime' and 'getPiecewiseSurvivalTime': illegal user arguments", {
+ expect_error(getAccrualTime(accrualTime = c(0, 12), accrualIntensity = 0.1, accrualIntensityType = "absolute"))
+
+ expect_error(getAccrualTime(
+ list(
+ "0 - <6" = 22,
+ "6 - 30" = 33
+ ),
+ maxNumberOfSubjects = 924
+ ))
+
+ expect_error(getAccrualTime(
+ list(
+ "0 < 6" = 22,
+ "6 - 30" = 33
+ ),
+ maxNumberOfSubjects = 924
+ ))
+
+ expect_error(getAccrualTime(
+ list(
+ "0 - <6" = 22,
+ "0 < 12" = 22,
+ "12 - 30" = 33
+ ),
+ maxNumberOfSubjects = 924
+ ))
+
+ expect_error(getPiecewiseSurvivalTime(
+ piecewiseSurvivalTime = list(
+ "0 - 6" = 0.025,
+ "7 - 12" = 0.035
+ ),
+ hazardRatio = 0.8, delayedResponseAllowed = FALSE
+ ))
+})
diff --git a/tests/testthat/test-f_analysis_enrichment_means.R b/tests/testthat/test-f_analysis_enrichment_means.R
index 709af679..9bced585 100644
--- a/tests/testthat/test-f_analysis_enrichment_means.R
+++ b/tests/testthat/test-f_analysis_enrichment_means.R
@@ -1,1441 +1,1490 @@
-## |
+## |
## | *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_analysis_enrichment_means.R
-## | Creation date: 08 November 2023, 08:53:05
-## | File version: $Revision$
-## | Last changed: $Date$
-## | Last changed by: $Author$
-## |
+## | Creation date: 27 May 2024, 13:07:08
+## | File version: $Revision: 7940 $
+## | Last changed: $Date: 2024-05-27 15:47:41 +0200 (Mo, 27 Mai 2024) $
+## | Last changed by: $Author: pahlke $
+## |
test_plan_section("Testing Analysis Enrichment Means Function (one sub-population)")
test_that("'getAnalysisResults': select S1 at first IA, gMax = 2, inverse normal design", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- S1 <- getDataset(
- sampleSize1 = c(12, 21),
- sampleSize2 = c(18, 21),
- mean1 = c(107.7, 84.9),
- mean2 = c(165.6, 195.9),
- stDev1 = c(128.5, 139.5),
- stDev2 = c(120.1, 185.0)
- )
-
- F <- getDataset(
- sampleSize1 = c(26, NA),
- sampleSize2 = c(29, NA),
- mean1 = c(86.48462, NA),
- mean2 = c(148.34138, NA),
- stDev1 = c(129.1485, NA),
- stDev2 = c(122.888, NA)
- )
-
- dataInput1 <- getDataset(S1 = S1, F = F)
-
- ## Comparison of the results of DatasetMeans object 'dataInput1' with expected results
- expect_equal(dataInput1$overallSampleSizes, c(12, 26, 18, 29, 33, NA_real_, 39, NA_real_), label = paste0("c(", paste0(dataInput1$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput1$overallMeans, c(107.7, 86.48462, 165.6, 148.34138, 93.190909, NA_real_, 181.91538, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput1$overallStDevs, c(128.5, 129.1485, 120.1, 122.888, 134.02535, NA_real_, 157.16289, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput1), NA)))
- expect_output(print(dataInput1)$show())
- invisible(capture.output(expect_error(summary(dataInput1), NA)))
- expect_output(summary(dataInput1)$show())
- dataInput1CodeBased <- eval(parse(text = getObjectRCode(dataInput1, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput1CodeBased$overallSampleSizes, dataInput1$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput1CodeBased$overallMeans, dataInput1$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput1CodeBased$overallStDevs, dataInput1$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput1), "character")
- df <- as.data.frame(dataInput1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
- bindingFutility = FALSE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
- )
-
- x1 <- getAnalysisResults(
- design = design1, dataInput = dataInput1,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "pooledFromFull",
- intersectionTest = "Bonferroni",
- stratifiedAnalysis = FALSE,
- stage = 2,
- thetaH1 = c(-30, NA),
- assumedStDevs = c(88, NA),
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
- expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.040655272, 0.29596348, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.065736952, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, 0.6346437), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(-215.41406, -176.0794, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(-176.00816, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(99.614058, 24.117528, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(52.294639, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[1, ], c(0.25380947, 0.041128123, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[2, ], c(0.19818652, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], 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$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ S1 <- getDataset(
+ sampleSize1 = c(12, 21),
+ sampleSize2 = c(18, 21),
+ mean1 = c(107.7, 84.9),
+ mean2 = c(165.6, 195.9),
+ stDev1 = c(128.5, 139.5),
+ stDev2 = c(120.1, 185.0)
+ )
+
+ F <- getDataset(
+ sampleSize1 = c(26, NA),
+ sampleSize2 = c(29, NA),
+ mean1 = c(86.48462, NA),
+ mean2 = c(148.34138, NA),
+ stDev1 = c(129.1485, NA),
+ stDev2 = c(122.888, NA)
+ )
+
+ dataInput1 <- getDataset(S1 = S1, F = F)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput1' with expected results
+ expect_equal(dataInput1$overallSampleSizes, c(12, 26, 18, 29, 33, NA_real_, 39, NA_real_), label = paste0(dataInput1$overallSampleSizes))
+ expect_equal(dataInput1$overallMeans, c(107.7, 86.48462, 165.6, 148.34138, 93.190909, NA_real_, 181.91538, NA_real_), tolerance = 1e-07, label = paste0(dataInput1$overallMeans))
+ expect_equal(dataInput1$overallStDevs, c(128.5, 129.1485, 120.1, 122.888, 134.02535, NA_real_, 157.16289, NA_real_), tolerance = 1e-07, label = paste0(dataInput1$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput1), NA)))
+ expect_output(print(dataInput1)$show())
+ invisible(capture.output(expect_error(summary(dataInput1), NA)))
+ expect_output(summary(dataInput1)$show())
+ dataInput1CodeBased <- eval(parse(text = getObjectRCode(dataInput1, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput1CodeBased$overallSampleSizes, dataInput1$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput1CodeBased$overallMeans, dataInput1$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput1CodeBased$overallStDevs, dataInput1$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput1), "character")
+ df <- as.data.frame(dataInput1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
+ bindingFutility = FALSE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
+ )
+
+ repeatedConfidenceIntervals <- getRepeatedConfidenceIntervals(design1, dataInput1)
+
+ ## Comparison of the results of array object 'repeatedConfidenceIntervals' with expected results
+ expect_equal(unlist(as.list(repeatedConfidenceIntervals)), c(-220.29061, -176.00816, 104.49061, 52.294639, -176.90621, NA_real_, 23.990701, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(unlist(as.list(repeatedConfidenceIntervals))))
+
+ stageResults <- getStageResults(design1, dataInput1)
+
+ ## Comparison of the results of StageResultsEnrichmentMeans object 'stageResults' with expected results
+ expect_equal(stageResults$overallTestStatistics[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(stageResults$overallTestStatistics[1, ]))
+ expect_equal(stageResults$overallTestStatistics[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(stageResults$overallTestStatistics[2, ]))
+ expect_equal(stageResults$overallStDevs[1, ], c(123.46817, 147.03819, NA_real_), tolerance = 1e-07, label = paste0(stageResults$overallStDevs[1, ]))
+ expect_equal(stageResults$overallStDevs[2, ], c(125.87987, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(stageResults$overallStDevs[2, ]))
+ expect_equal(stageResults$testStatistics[1, ], c("stage 1" = -1.2583162, "stage 2" = -2.1953569, "stage 3" = NA_real_), tolerance = 1e-07, label = paste0(stageResults$testStatistics[1, ]))
+ expect_equal(stageResults$testStatistics[2, ], c("stage 1" = -1.8194295, "stage 2" = NA_real_, "stage 3" = NA_real_), tolerance = 1e-07, label = paste0(stageResults$testStatistics[2, ]))
+ expect_equal(stageResults$separatePValues[1, ], c("stage 1" = 0.89066535, "stage 2" = 0.98299949, "stage 3" = NA_real_), tolerance = 1e-07, label = paste0(stageResults$separatePValues[1, ]))
+ expect_equal(stageResults$separatePValues[2, ], c("stage 1" = 0.96275182, "stage 2" = NA_real_, "stage 3" = NA_real_), tolerance = 1e-07, label = paste0(stageResults$separatePValues[2, ]))
+ expect_equal(stageResults$effectSizes[1, ], c(-57.9, -88.724476, NA_real_), tolerance = 1e-07, label = paste0(stageResults$effectSizes[1, ]))
+ expect_equal(stageResults$effectSizes[2, ], c(-61.85676, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(stageResults$effectSizes[2, ]))
+ expect_equal(stageResults$weightsInverseNormal, c(0.70710678, 0.4472136, 0.54772256), tolerance = 1e-07, label = paste0(stageResults$weightsInverseNormal))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(stageResults), NA)))
+ expect_output(print(stageResults)$show())
+ invisible(capture.output(expect_error(summary(stageResults), NA)))
+ expect_output(summary(stageResults)$show())
+ stageResultsCodeBased <- eval(parse(text = getObjectRCode(stageResults, stringWrapParagraphWidth = NULL)))
+ expect_equal(stageResultsCodeBased$overallTestStatistics, stageResults$overallTestStatistics, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$overallPValues, stageResults$overallPValues, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$overallStDevs, stageResults$overallStDevs, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$overallPooledStDevs, stageResults$overallPooledStDevs, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$testStatistics, stageResults$testStatistics, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$separatePValues, stageResults$separatePValues, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$effectSizes, stageResults$effectSizes, tolerance = 1e-07)
+ expect_equal(stageResultsCodeBased$weightsInverseNormal, stageResults$weightsInverseNormal, tolerance = 1e-07)
+ expect_type(names(stageResults), "character")
+ df <- as.data.frame(stageResults)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(stageResults)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ conditionalPower <- getConditionalPower(stageResults, nPlanned = 50)
+
+ ## Comparison of the results of ConditionalPowerResultsEnrichmentMeans object 'conditionalPower' with expected results
+ expect_equal(conditionalPower$conditionalPower[1, ], c(NA_real_, NA_real_, 6.6613381e-16), tolerance = 1e-07, label = paste0(conditionalPower$conditionalPower[1, ]))
+ expect_equal(conditionalPower$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(conditionalPower$conditionalPower[2, ]))
+
+ conditionalPowerPlot <- .getConditionalPowerPlot(
+ stageResults = stageResults,
+ thetaRange = seq(-0.8, 0.5, 0.1), nPlanned = 60, assumedStDev = 2, allocationRatioPlanned = 3
+ )
+
+ ## Comparison of the results of list object 'conditionalPowerPlot' with expected results
+ expect_equal(conditionalPowerPlot$populations, c(1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2), label = paste0(conditionalPowerPlot$populations))
+ expect_equal(conditionalPowerPlot$xValues, c(-0.8, -0.8, -0.7, -0.7, -0.6, -0.6, -0.5, -0.5, -0.4, -0.4, -0.3, -0.3, -0.2, -0.2, -0.1, -0.1, 0, 0, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5), tolerance = 1e-07, label = paste0(conditionalPowerPlot$xValues))
+ expect_equal(conditionalPowerPlot$condPowerValues, c(1.4432899e-15, NA_real_, 1.4432899e-15, NA_real_, 1.5543122e-15, NA_real_, 1.5543122e-15, NA_real_, 1.5543122e-15, NA_real_, 1.5543122e-15, NA_real_, 1.6653345e-15, NA_real_, 1.6653345e-15, NA_real_, 1.6653345e-15, NA_real_, 1.7763568e-15, NA_real_, 1.7763568e-15, NA_real_, 1.7763568e-15, NA_real_, 1.7763568e-15, NA_real_, 1.8873791e-15, NA_real_), tolerance = 1e-07, label = paste0(conditionalPowerPlot$condPowerValues))
+ expect_equal(conditionalPowerPlot$likelihoodValues, c(0.012773695, NA_real_, 0.012647555, NA_real_, 0.012522519, NA_real_, 0.012398579, NA_real_, 0.012275728, NA_real_, 0.012153957, NA_real_, 0.012033258, NA_real_, 0.011913623, NA_real_, 0.011795044, NA_real_, 0.011677515, NA_real_, 0.011561025, NA_real_, 0.011445569, NA_real_, 0.011331138, NA_real_, 0.011217724, NA_real_), tolerance = 1e-07, label = paste0(conditionalPowerPlot$likelihoodValues))
+ expect_equal(conditionalPowerPlot$main, "Conditional Power with Likelihood", label = paste0(conditionalPowerPlot$main))
+ expect_equal(conditionalPowerPlot$xlab, "Effect size", label = paste0(conditionalPowerPlot$xlab))
+ expect_equal(conditionalPowerPlot$ylab, "Conditional power / Likelihood", label = paste0(conditionalPowerPlot$ylab))
+ expect_equal(conditionalPowerPlot$sub, "Intersection test = Simes, stage = 2, # of remaining subjects = 60, sd = (147, NA), allocation ratio = 3", label = paste0(conditionalPowerPlot$sub))
+
+ x1 <- getAnalysisResults(
+ design = design1, dataInput = dataInput1,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "pooledFromFull",
+ intersectionTest = "Bonferroni",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ thetaH1 = c(-30, NA),
+ assumedStDevs = c(88, NA),
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
+ expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.040655272, 0.29596348, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.065736952, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, 0.6346437), tolerance = 1e-07, label = paste0(x1$conditionalPower[1, ]))
+ expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[2, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(-215.41406, -176.0794, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(-176.00816, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(99.614058, 24.117528, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(52.294639, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x1$repeatedPValues[1, ], c(0.25380947, 0.041128123, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[1, ]))
+ expect_equal(x1$repeatedPValues[2, ], c(0.19818652, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[2, ]))
+ 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$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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)
+ }
})
test_that("'getAnalysisResults': stratified analysis, select S1 at first IA, gMax = 2, Fisher design", {
-
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- S1 <- getDataset(
- sampleSize1 = c(12, 21),
- sampleSize2 = c(18, 21),
- mean1 = c(107.7, 84.9),
- mean2 = c(165.6, 195.9),
- stDev1 = c(128.5, 139.5),
- stDev2 = c(120.1, 185.0)
- )
-
- R <- getDataset(
- sampleSize1 = c(14, NA),
- sampleSize2 = c(11, NA),
- mean1 = c(68.3, NA),
- mean2 = c(120.1, NA),
- stDev1 = c(124.0, NA),
- stDev2 = c(116.8, NA)
- )
-
- dataInput2 <- getDataset(S1 = S1, R = R)
-
- ## Comparison of the results of DatasetMeans object 'dataInput2' with expected results
- expect_equal(dataInput2$overallSampleSizes, c(12, 14, 18, 11, 33, NA_real_, 39, NA_real_), label = paste0("c(", paste0(dataInput2$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput2$overallMeans, c(107.7, 68.3, 165.6, 120.1, 93.190909, NA_real_, 181.91538, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput2$overallStDevs, c(128.5, 124, 120.1, 116.8, 134.02535, NA_real_, 157.16289, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput2), NA)))
- expect_output(print(dataInput2)$show())
- invisible(capture.output(expect_error(summary(dataInput2), NA)))
- expect_output(summary(dataInput2)$show())
- dataInput2CodeBased <- eval(parse(text = getObjectRCode(dataInput2, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput2CodeBased$overallSampleSizes, dataInput2$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$overallMeans, dataInput2$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$overallStDevs, dataInput2$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput2), "character")
- df <- as.data.frame(dataInput2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design2 <- getDesignFisher(
- kMax = 3, alpha = 0.02, alpha0Vec = c(0.7, 0.5), method = "fullAlpha",
- bindingFutility = TRUE, informationRates = c(0.3, 0.7, 1)
- )
-
- x2 <- getAnalysisResults(
- design = design2, dataInput = dataInput2,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "pooledFromFull",
- intersectionTest = "Bonferroni",
- stratifiedAnalysis = FALSE,
- stage = 2,
- thetaH1 = c(-30, NA),
- assumedStDevs = c(88, NA),
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x2' with expected results
- expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.030372979, 0.38266716, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.042518986, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, 0.71962915), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(-187.96966, -183.80634, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(-156.27269, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(72.16966, 16.133901, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(32.559163, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[1, ], c(0.19557155, 0.034517266, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[2, ], c(0.13877083, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], 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$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
- bindingFutility = FALSE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
- )
-
- x3 <- getAnalysisResults(
- design = design1, dataInput = dataInput2,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- intersectionTest = "Sidak",
- stratifiedAnalysis = TRUE,
- stage = 2,
- thetaH1 = c(-30, NA),
- assumedStDevs = c(88, NA),
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x3' with expected results
- expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.041603465, 0.30059767, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.044887021, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, 0.63965664), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(-220.28415, -176.85912, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(-167.67059, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(104.48415, 23.636689, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(57.495741, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[1, ], c(0.25104477, 0.040430988, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[2, ], c(0.24199442, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[2, ], 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$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ S1 <- getDataset(
+ sampleSize1 = c(12, 21),
+ sampleSize2 = c(18, 21),
+ mean1 = c(107.7, 84.9),
+ mean2 = c(165.6, 195.9),
+ stDev1 = c(128.5, 139.5),
+ stDev2 = c(120.1, 185.0)
+ )
+
+ R <- getDataset(
+ sampleSize1 = c(14, NA),
+ sampleSize2 = c(11, NA),
+ mean1 = c(68.3, NA),
+ mean2 = c(120.1, NA),
+ stDev1 = c(124.0, NA),
+ stDev2 = c(116.8, NA)
+ )
+
+ dataInput2 <- getDataset(S1 = S1, R = R)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput2' with expected results
+ expect_equal(dataInput2$overallSampleSizes, c(12, 14, 18, 11, 33, NA_real_, 39, NA_real_), label = paste0(dataInput2$overallSampleSizes))
+ expect_equal(dataInput2$overallMeans, c(107.7, 68.3, 165.6, 120.1, 93.190909, NA_real_, 181.91538, NA_real_), tolerance = 1e-07, label = paste0(dataInput2$overallMeans))
+ expect_equal(dataInput2$overallStDevs, c(128.5, 124, 120.1, 116.8, 134.02535, NA_real_, 157.16289, NA_real_), tolerance = 1e-07, label = paste0(dataInput2$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput2), NA)))
+ expect_output(print(dataInput2)$show())
+ invisible(capture.output(expect_error(summary(dataInput2), NA)))
+ expect_output(summary(dataInput2)$show())
+ dataInput2CodeBased <- eval(parse(text = getObjectRCode(dataInput2, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput2CodeBased$overallSampleSizes, dataInput2$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$overallMeans, dataInput2$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$overallStDevs, dataInput2$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput2), "character")
+ df <- as.data.frame(dataInput2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design2 <- getDesignFisher(
+ kMax = 3, alpha = 0.02, alpha0Vec = c(0.7, 0.5), method = "fullAlpha",
+ bindingFutility = TRUE, informationRates = c(0.3, 0.7, 1)
+ )
+
+ x2 <- getAnalysisResults(
+ design = design2, dataInput = dataInput2,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "pooledFromFull",
+ intersectionTest = "Bonferroni",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ thetaH1 = c(-30, NA),
+ assumedStDevs = c(88, NA),
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x2' with expected results
+ expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.030372979, 0.38266716, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.042518986, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, 0.71962915), tolerance = 1e-07, label = paste0(x2$conditionalPower[1, ]))
+ expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[2, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(-187.96966, -183.80634, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(-156.27269, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(72.16966, 16.133901, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(32.559163, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x2$repeatedPValues[1, ], c(0.19557155, 0.034517266, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[1, ]))
+ expect_equal(x2$repeatedPValues[2, ], c(0.13877083, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[2, ]))
+ 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$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
+ bindingFutility = FALSE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
+ )
+
+ x3 <- getAnalysisResults(
+ design = design1, dataInput = dataInput2,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ intersectionTest = "Sidak",
+ stratifiedAnalysis = TRUE,
+ stage = 2,
+ thetaH1 = c(-30, NA),
+ assumedStDevs = c(88, NA),
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x3' with expected results
+ expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.041603465, 0.30059767, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.044887021, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, 0.63965664), tolerance = 1e-07, label = paste0(x3$conditionalPower[1, ]))
+ expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPower[2, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(-220.28415, -176.85912, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(-167.67059, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(104.48415, 23.636689, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(57.495741, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x3$repeatedPValues[1, ], c(0.25104477, 0.040430988, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedPValues[1, ]))
+ expect_equal(x3$repeatedPValues[2, ], c(0.24199442, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedPValues[2, ]))
+ 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$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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)
+ }
})
test_that("'getAnalysisResults': select S1 at first IA, gMax = 2, inverse normal design, Sidak and Spiessens & Debois", {
-
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- design1 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
- bindingFutility = FALSE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
- )
-
- S1 <- getDataset(
- sampleSize1 = c(12, 21),
- sampleSize2 = c(18, 21),
- mean1 = c(107.7, 84.9),
- mean2 = c(165.6, 195.9),
- stDev1 = c(128.5, 139.5),
- stDev2 = c(120.1, 185.0)
- )
-
- F <- getDataset(
- sampleSize1 = c(26, NA),
- sampleSize2 = c(29, NA),
- mean1 = c(86.48462, NA),
- mean2 = c(148.34138, NA),
- stDev1 = c(129.1485, NA),
- stDev2 = c(122.888, NA)
- )
-
- dataInput1 <- getDataset(S1 = S1, F = F)
-
- x4 <- getAnalysisResults(
- design = design1, dataInput = dataInput1,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Sidak",
- stratifiedAnalysis = FALSE,
- stage = 2,
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x4' with expected results
- expect_equal(x4$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0("c(", paste0(x4$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x4$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x4$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x4$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0("c(", paste0(x4$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x4$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x4$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalRejectionProbabilities[1, ], c(0.039522227, 0.28885292, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalRejectionProbabilities[2, ], c(0.066220149, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[1, ], c(NA_real_, NA_real_, 0.84164989), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[1, ], c(-226.91549, -179.08628, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[2, ], c(-176.48166, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[1, ], c(111.11549, 25.050962, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[2, ], c(52.768138, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[1, ], c(0.25721122, 0.042227707, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[2, ], c(0.1973759, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[2, ], 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$thetaH1, x4$thetaH1, tolerance = 1e-07)
- expect_equal(x4CodeBased$assumedStDevs, x4$assumedStDevs, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalRejectionProbabilities, x4$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalPower, x4$conditionalPower, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedConfidenceIntervalLowerBounds, x4$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedConfidenceIntervalUpperBounds, x4$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedPValues, x4$repeatedPValues, 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 <- getAnalysisResults(
- design = design1, dataInput = dataInput1,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "pooledFromFull",
- intersectionTest = "SpiessensDebois",
- stratifiedAnalysis = TRUE,
- stage = 2,
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x5' with expected results
- expect_equal(x5$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0("c(", paste0(x5$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x5$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x5$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x5$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0("c(", paste0(x5$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x5$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x5$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalRejectionProbabilities[1, ], c(0.039526191, 0.29036799, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalRejectionProbabilities[2, ], c(0.083357636, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPower[1, ], c(NA_real_, NA_real_, 0.84271782), tolerance = 1e-07, label = paste0("c(", paste0(x5$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x5$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x5$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x5$repeatedConfidenceIntervalLowerBounds[1, ], c(-213.99088, -174.2069, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x5$repeatedConfidenceIntervalLowerBounds[2, ], c(-174.97677, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x5$repeatedConfidenceIntervalUpperBounds[1, ], c(98.190881, 20.342564, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x5$repeatedConfidenceIntervalUpperBounds[2, ], c(51.263255, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x5$repeatedPValues[1, ], c(0.25719977, 0.041990242, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x5$repeatedPValues[2, ], c(0.17255372, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x5$repeatedPValues[2, ], 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$thetaH1, x5$thetaH1, tolerance = 1e-07)
- expect_equal(x5CodeBased$assumedStDevs, x5$assumedStDevs, tolerance = 1e-07)
- expect_equal(x5CodeBased$conditionalRejectionProbabilities, x5$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x5CodeBased$conditionalPower, x5$conditionalPower, tolerance = 1e-07)
- expect_equal(x5CodeBased$repeatedConfidenceIntervalLowerBounds, x5$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x5CodeBased$repeatedConfidenceIntervalUpperBounds, x5$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x5CodeBased$repeatedPValues, x5$repeatedPValues, 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 <- getAnalysisResults(
- design = design1, dataInput = dataInput1,
- directionUpper = FALSE,
- normalApproximation = TRUE,
- varianceOption = "notPooled",
- intersectionTest = "SpiessensDebois",
- stratifiedAnalysis = FALSE,
- stage = 2,
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x6' with expected results
- expect_equal(x6$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0("c(", paste0(x6$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x6$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x6$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x6$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0("c(", paste0(x6$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x6$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x6$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalRejectionProbabilities[1, ], c(0.042609088, 0.32732548, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalRejectionProbabilities[2, ], c(0.088609159, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPower[1, ], c(NA_real_, NA_real_, 0.86664918), tolerance = 1e-07, label = paste0("c(", paste0(x6$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x6$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x6$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x6$repeatedConfidenceIntervalLowerBounds[1, ], c(-205.06578, -171.09275, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x6$repeatedConfidenceIntervalLowerBounds[2, ], c(-169.37758, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x6$repeatedConfidenceIntervalUpperBounds[1, ], c(89.26578, 17.032517, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x6$repeatedConfidenceIntervalUpperBounds[2, ], c(45.664059, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x6$repeatedPValues[1, ], c(0.24818852, 0.036684963, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x6$repeatedPValues[2, ], c(0.16618986, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x6$repeatedPValues[2, ], 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$thetaH1, x6$thetaH1, tolerance = 1e-07)
- expect_equal(x6CodeBased$assumedStDevs, x6$assumedStDevs, tolerance = 1e-07)
- expect_equal(x6CodeBased$conditionalRejectionProbabilities, x6$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x6CodeBased$conditionalPower, x6$conditionalPower, tolerance = 1e-07)
- expect_equal(x6CodeBased$repeatedConfidenceIntervalLowerBounds, x6$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x6CodeBased$repeatedConfidenceIntervalUpperBounds, x6$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x6CodeBased$repeatedPValues, x6$repeatedPValues, 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)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ design1 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
+ bindingFutility = FALSE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
+ )
+
+ S1 <- getDataset(
+ sampleSize1 = c(12, 21),
+ sampleSize2 = c(18, 21),
+ mean1 = c(107.7, 84.9),
+ mean2 = c(165.6, 195.9),
+ stDev1 = c(128.5, 139.5),
+ stDev2 = c(120.1, 185.0)
+ )
+
+ F <- getDataset(
+ sampleSize1 = c(26, NA),
+ sampleSize2 = c(29, NA),
+ mean1 = c(86.48462, NA),
+ mean2 = c(148.34138, NA),
+ stDev1 = c(129.1485, NA),
+ stDev2 = c(122.888, NA)
+ )
+
+ dataInput1 <- getDataset(S1 = S1, F = F)
+
+ x4 <- getAnalysisResults(
+ design = design1, dataInput = dataInput1,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Sidak",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x4' with expected results
+ expect_equal(x4$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0(x4$thetaH1[1, ]))
+ expect_equal(x4$thetaH1[2, ], NA_real_, label = paste0(x4$thetaH1[2, ]))
+ expect_equal(x4$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0(x4$assumedStDevs[1, ]))
+ expect_equal(x4$assumedStDevs[2, ], NA_real_, label = paste0(x4$assumedStDevs[2, ]))
+ expect_equal(x4$conditionalRejectionProbabilities[1, ], c(0.039522227, 0.28885292, NA_real_), tolerance = 1e-07, label = paste0(x4$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x4$conditionalRejectionProbabilities[2, ], c(0.066220149, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x4$conditionalPower[1, ], c(NA_real_, NA_real_, 0.84164989), tolerance = 1e-07, label = paste0(x4$conditionalPower[1, ]))
+ expect_equal(x4$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x4$conditionalPower[2, ]))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[1, ], c(-226.91549, -179.08628, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[2, ], c(-176.48166, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[1, ], c(111.11549, 25.050962, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[2, ], c(52.768138, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x4$repeatedPValues[1, ], c(0.25721122, 0.042227707, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedPValues[1, ]))
+ expect_equal(x4$repeatedPValues[2, ], c(0.1973759, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedPValues[2, ]))
+ 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$thetaH1, x4$thetaH1, tolerance = 1e-07)
+ expect_equal(x4CodeBased$assumedStDevs, x4$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalRejectionProbabilities, x4$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalPower, x4$conditionalPower, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedConfidenceIntervalLowerBounds, x4$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedConfidenceIntervalUpperBounds, x4$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedPValues, x4$repeatedPValues, 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 <- getAnalysisResults(
+ design = design1, dataInput = dataInput1,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "pooledFromFull",
+ intersectionTest = "SpiessensDebois",
+ stratifiedAnalysis = TRUE,
+ stage = 2,
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x5' with expected results
+ expect_equal(x5$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0(x5$thetaH1[1, ]))
+ expect_equal(x5$thetaH1[2, ], NA_real_, label = paste0(x5$thetaH1[2, ]))
+ expect_equal(x5$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0(x5$assumedStDevs[1, ]))
+ expect_equal(x5$assumedStDevs[2, ], NA_real_, label = paste0(x5$assumedStDevs[2, ]))
+ expect_equal(x5$conditionalRejectionProbabilities[1, ], c(0.039526191, 0.29036799, NA_real_), tolerance = 1e-07, label = paste0(x5$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x5$conditionalRejectionProbabilities[2, ], c(0.083357636, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x5$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x5$conditionalPower[1, ], c(NA_real_, NA_real_, 0.84271782), tolerance = 1e-07, label = paste0(x5$conditionalPower[1, ]))
+ expect_equal(x5$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x5$conditionalPower[2, ]))
+ expect_equal(x5$repeatedConfidenceIntervalLowerBounds[1, ], c(-213.99088, -174.2069, NA_real_), tolerance = 1e-07, label = paste0(x5$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x5$repeatedConfidenceIntervalLowerBounds[2, ], c(-174.97677, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x5$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x5$repeatedConfidenceIntervalUpperBounds[1, ], c(98.190881, 20.342564, NA_real_), tolerance = 1e-07, label = paste0(x5$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x5$repeatedConfidenceIntervalUpperBounds[2, ], c(51.263255, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x5$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x5$repeatedPValues[1, ], c(0.25719977, 0.041990242, NA_real_), tolerance = 1e-07, label = paste0(x5$repeatedPValues[1, ]))
+ expect_equal(x5$repeatedPValues[2, ], c(0.17255372, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x5$repeatedPValues[2, ]))
+ 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$thetaH1, x5$thetaH1, tolerance = 1e-07)
+ expect_equal(x5CodeBased$assumedStDevs, x5$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x5CodeBased$conditionalRejectionProbabilities, x5$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x5CodeBased$conditionalPower, x5$conditionalPower, tolerance = 1e-07)
+ expect_equal(x5CodeBased$repeatedConfidenceIntervalLowerBounds, x5$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x5CodeBased$repeatedConfidenceIntervalUpperBounds, x5$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x5CodeBased$repeatedPValues, x5$repeatedPValues, 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 <- getAnalysisResults(
+ design = design1, dataInput = dataInput1,
+ directionUpper = FALSE,
+ normalApproximation = TRUE,
+ varianceOption = "notPooled",
+ intersectionTest = "SpiessensDebois",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x6' with expected results
+ expect_equal(x6$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0(x6$thetaH1[1, ]))
+ expect_equal(x6$thetaH1[2, ], NA_real_, label = paste0(x6$thetaH1[2, ]))
+ expect_equal(x6$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0(x6$assumedStDevs[1, ]))
+ expect_equal(x6$assumedStDevs[2, ], NA_real_, label = paste0(x6$assumedStDevs[2, ]))
+ expect_equal(x6$conditionalRejectionProbabilities[1, ], c(0.042609088, 0.32732548, NA_real_), tolerance = 1e-07, label = paste0(x6$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x6$conditionalRejectionProbabilities[2, ], c(0.088609159, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x6$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x6$conditionalPower[1, ], c(NA_real_, NA_real_, 0.86664918), tolerance = 1e-07, label = paste0(x6$conditionalPower[1, ]))
+ expect_equal(x6$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x6$conditionalPower[2, ]))
+ expect_equal(x6$repeatedConfidenceIntervalLowerBounds[1, ], c(-205.06578, -171.09275, NA_real_), tolerance = 1e-07, label = paste0(x6$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x6$repeatedConfidenceIntervalLowerBounds[2, ], c(-169.37758, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x6$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x6$repeatedConfidenceIntervalUpperBounds[1, ], c(89.26578, 17.032517, NA_real_), tolerance = 1e-07, label = paste0(x6$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x6$repeatedConfidenceIntervalUpperBounds[2, ], c(45.664059, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x6$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x6$repeatedPValues[1, ], c(0.24818852, 0.036684963, NA_real_), tolerance = 1e-07, label = paste0(x6$repeatedPValues[1, ]))
+ expect_equal(x6$repeatedPValues[2, ], c(0.16618986, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x6$repeatedPValues[2, ]))
+ 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$thetaH1, x6$thetaH1, tolerance = 1e-07)
+ expect_equal(x6CodeBased$assumedStDevs, x6$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x6CodeBased$conditionalRejectionProbabilities, x6$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x6CodeBased$conditionalPower, x6$conditionalPower, tolerance = 1e-07)
+ expect_equal(x6CodeBased$repeatedConfidenceIntervalLowerBounds, x6$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x6CodeBased$repeatedConfidenceIntervalUpperBounds, x6$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x6CodeBased$repeatedPValues, x6$repeatedPValues, 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)
+ }
})
test_that("'getAnalysisResults': select S1 at first IA, gMax = 2, Fisher design, Sidak and Bonferroni", {
-
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- design2 <- getDesignFisher(
- kMax = 3, alpha = 0.02, alpha0Vec = c(0.7, 0.5), method = "fullAlpha",
- bindingFutility = TRUE, informationRates = c(0.3, 0.7, 1)
- )
-
- S1 <- getDataset(
- sampleSize1 = c(12, 21),
- sampleSize2 = c(18, 21),
- mean1 = c(107.7, 84.9),
- mean2 = c(165.6, 195.9),
- stDev1 = c(128.5, 139.5),
- stDev2 = c(120.1, 185.0)
- )
-
- F <- getDataset(
- sampleSize1 = c(26, NA),
- sampleSize2 = c(29, NA),
- mean1 = c(86.48462, NA),
- mean2 = c(148.34138, NA),
- stDev1 = c(129.1485, NA),
- stDev2 = c(122.888, NA)
- )
-
- dataInput1 <- getDataset(S1 = S1, F = F)
-
- x7 <- getAnalysisResults(
- design = design2, dataInput = dataInput1,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "pooled",
- intersectionTest = "Sidak",
- stratifiedAnalysis = FALSE,
- stage = 2,
- thetaH1 = c(-30, NA),
- assumedStDevs = c(88, NA),
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x7' with expected results
- expect_equal(x7$conditionalRejectionProbabilities[1, ], c(0.029419226, 0.36686704, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalRejectionProbabilities[2, ], c(0.039811318, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPower[1, ], c(NA_real_, NA_real_, 0.70542247), tolerance = 1e-07, label = paste0("c(", paste0(x7$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x7$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x7$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x7$repeatedConfidenceIntervalLowerBounds[1, ], c(-194.17913, -187.01693, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x7$repeatedConfidenceIntervalLowerBounds[2, ], c(-158.83149, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x7$repeatedConfidenceIntervalUpperBounds[1, ], c(78.379133, 16.599438, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x7$repeatedConfidenceIntervalUpperBounds[2, ], c(35.117971, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x7$repeatedPValues[1, ], c(0.20187628, 0.035489058, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x7$repeatedPValues[2, ], c(0.14858412, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x7$repeatedPValues[2, ], 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$conditionalRejectionProbabilities, x7$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x7CodeBased$conditionalPower, x7$conditionalPower, tolerance = 1e-07)
- expect_equal(x7CodeBased$repeatedConfidenceIntervalLowerBounds, x7$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x7CodeBased$repeatedConfidenceIntervalUpperBounds, x7$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x7CodeBased$repeatedPValues, x7$repeatedPValues, 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 <- getAnalysisResults(
- design = design2, dataInput = dataInput1,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Bonferroni",
- stratifiedAnalysis = FALSE,
- stage = 2,
- nPlanned = c(30),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x8' with expected results
- expect_equal(x8$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0("c(", paste0(x8$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x8$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x8$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x8$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0("c(", paste0(x8$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x8$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x8$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalRejectionProbabilities[1, ], c(0.028559196, 0.34741778, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalRejectionProbabilities[2, ], c(0.038896649, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPower[1, ], c(NA_real_, NA_real_, 0.878132), tolerance = 1e-07, label = paste0("c(", paste0(x8$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x8$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x8$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x8$repeatedConfidenceIntervalLowerBounds[1, ], c(-198.85804, -189.35465, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x8$repeatedConfidenceIntervalLowerBounds[2, ], c(-159.22325, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x8$repeatedConfidenceIntervalUpperBounds[1, ], c(83.058044, 17.838621, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x8$repeatedConfidenceIntervalUpperBounds[2, ], c(35.509728, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x8$repeatedPValues[1, ], c(0.20789586, 0.036783191, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x8$repeatedPValues[2, ], c(0.15219281, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x8$repeatedPValues[2, ], 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$thetaH1, x8$thetaH1, tolerance = 1e-07)
- expect_equal(x8CodeBased$assumedStDevs, x8$assumedStDevs, tolerance = 1e-07)
- expect_equal(x8CodeBased$conditionalRejectionProbabilities, x8$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x8CodeBased$conditionalPower, x8$conditionalPower, tolerance = 1e-07)
- expect_equal(x8CodeBased$repeatedConfidenceIntervalLowerBounds, x8$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x8CodeBased$repeatedConfidenceIntervalUpperBounds, x8$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x8CodeBased$repeatedPValues, x8$repeatedPValues, 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)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ design2 <- getDesignFisher(
+ kMax = 3, alpha = 0.02, alpha0Vec = c(0.7, 0.5), method = "fullAlpha",
+ bindingFutility = TRUE, informationRates = c(0.3, 0.7, 1)
+ )
+
+ S1 <- getDataset(
+ sampleSize1 = c(12, 21),
+ sampleSize2 = c(18, 21),
+ mean1 = c(107.7, 84.9),
+ mean2 = c(165.6, 195.9),
+ stDev1 = c(128.5, 139.5),
+ stDev2 = c(120.1, 185.0)
+ )
+
+ F <- getDataset(
+ sampleSize1 = c(26, NA),
+ sampleSize2 = c(29, NA),
+ mean1 = c(86.48462, NA),
+ mean2 = c(148.34138, NA),
+ stDev1 = c(129.1485, NA),
+ stDev2 = c(122.888, NA)
+ )
+
+ dataInput1 <- getDataset(S1 = S1, F = F)
+
+ x7 <- getAnalysisResults(
+ design = design2, dataInput = dataInput1,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "pooled",
+ intersectionTest = "Sidak",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ thetaH1 = c(-30, NA),
+ assumedStDevs = c(88, NA),
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x7' with expected results
+ expect_equal(x7$conditionalRejectionProbabilities[1, ], c(0.029419226, 0.36686704, NA_real_), tolerance = 1e-07, label = paste0(x7$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x7$conditionalRejectionProbabilities[2, ], c(0.039811318, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x7$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x7$conditionalPower[1, ], c(NA_real_, NA_real_, 0.70542247), tolerance = 1e-07, label = paste0(x7$conditionalPower[1, ]))
+ expect_equal(x7$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x7$conditionalPower[2, ]))
+ expect_equal(x7$repeatedConfidenceIntervalLowerBounds[1, ], c(-194.17913, -187.01693, NA_real_), tolerance = 1e-07, label = paste0(x7$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x7$repeatedConfidenceIntervalLowerBounds[2, ], c(-158.83149, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x7$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x7$repeatedConfidenceIntervalUpperBounds[1, ], c(78.379133, 16.599438, NA_real_), tolerance = 1e-07, label = paste0(x7$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x7$repeatedConfidenceIntervalUpperBounds[2, ], c(35.117971, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x7$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x7$repeatedPValues[1, ], c(0.20187628, 0.035489058, NA_real_), tolerance = 1e-07, label = paste0(x7$repeatedPValues[1, ]))
+ expect_equal(x7$repeatedPValues[2, ], c(0.14858412, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x7$repeatedPValues[2, ]))
+ 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$conditionalRejectionProbabilities, x7$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x7CodeBased$conditionalPower, x7$conditionalPower, tolerance = 1e-07)
+ expect_equal(x7CodeBased$repeatedConfidenceIntervalLowerBounds, x7$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x7CodeBased$repeatedConfidenceIntervalUpperBounds, x7$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x7CodeBased$repeatedPValues, x7$repeatedPValues, 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 <- getAnalysisResults(
+ design = design2, dataInput = dataInput1,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Bonferroni",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ nPlanned = c(30),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x8' with expected results
+ expect_equal(x8$thetaH1[1, ], -88.724476, tolerance = 1e-07, label = paste0(x8$thetaH1[1, ]))
+ expect_equal(x8$thetaH1[2, ], NA_real_, label = paste0(x8$thetaH1[2, ]))
+ expect_equal(x8$assumedStDevs[1, ], 147.03819, tolerance = 1e-07, label = paste0(x8$assumedStDevs[1, ]))
+ expect_equal(x8$assumedStDevs[2, ], NA_real_, label = paste0(x8$assumedStDevs[2, ]))
+ expect_equal(x8$conditionalRejectionProbabilities[1, ], c(0.028559196, 0.34741778, NA_real_), tolerance = 1e-07, label = paste0(x8$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x8$conditionalRejectionProbabilities[2, ], c(0.038896649, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x8$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x8$conditionalPower[1, ], c(NA_real_, NA_real_, 0.878132), tolerance = 1e-07, label = paste0(x8$conditionalPower[1, ]))
+ expect_equal(x8$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x8$conditionalPower[2, ]))
+ expect_equal(x8$repeatedConfidenceIntervalLowerBounds[1, ], c(-198.85804, -189.35465, NA_real_), tolerance = 1e-07, label = paste0(x8$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x8$repeatedConfidenceIntervalLowerBounds[2, ], c(-159.22325, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x8$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x8$repeatedConfidenceIntervalUpperBounds[1, ], c(83.058044, 17.838621, NA_real_), tolerance = 1e-07, label = paste0(x8$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x8$repeatedConfidenceIntervalUpperBounds[2, ], c(35.509728, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x8$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x8$repeatedPValues[1, ], c(0.20789586, 0.036783191, NA_real_), tolerance = 1e-07, label = paste0(x8$repeatedPValues[1, ]))
+ expect_equal(x8$repeatedPValues[2, ], c(0.15219281, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x8$repeatedPValues[2, ]))
+ 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$thetaH1, x8$thetaH1, tolerance = 1e-07)
+ expect_equal(x8CodeBased$assumedStDevs, x8$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x8CodeBased$conditionalRejectionProbabilities, x8$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x8CodeBased$conditionalPower, x8$conditionalPower, tolerance = 1e-07)
+ expect_equal(x8CodeBased$repeatedConfidenceIntervalLowerBounds, x8$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x8CodeBased$repeatedConfidenceIntervalUpperBounds, x8$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x8CodeBased$repeatedPValues, x8$repeatedPValues, 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)
+ }
})
test_plan_section("Testing Analysis Enrichment Means Function (two sub-populations)")
test_that("'getAnalysisResults': stratified analysis, select S1 at first IA, gMax = 3", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- S1 <- getDataset(
- sampleSize2 = c(12, 33, 21),
- sampleSize1 = c(18, 17, 23),
- mean2 = c(107.7, 77.7, 84.9),
- mean1 = c(125.6, 111.1, 99.9),
- stDev2 = c(128.5, 133.3, 84.9),
- stDev1 = c(120.1, 145.6, 74.3)
- )
-
- S2 <- getDataset(
- sampleSize2 = c(14, NA, NA),
- sampleSize1 = c(11, NA, NA),
- mean2 = c(68.3, NA, NA),
- mean1 = c(100.1, NA, NA),
- stDev2 = c(124.0, NA, NA),
- stDev1 = c(116.8, NA, NA)
- )
-
- S12 <- getDataset(
- sampleSize2 = c(21, 12, 33),
- sampleSize1 = c(21, 17, 31),
- mean2 = c(84.9, 107.7, 77.7),
- mean1 = c(135.9, 117.7, 97.7),
- stDev2 = c(139.5, 107.7, 77.7),
- stDev1 = c(185.0, 92.3, 87.3)
- )
-
- R <- getDataset(
- sampleSize2 = c(33, NA, NA),
- sampleSize1 = c(19, NA, NA),
- mean2 = c(77.1, NA, NA),
- mean1 = c(142.4, NA, NA),
- stDev2 = c(163.5, NA, NA),
- stDev1 = c(120.6, NA, NA)
- )
-
- dataInput1 <- getDataset(S1 = S1, S2 = S2, S12 = S12, R = R)
-
- ## Comparison of the results of DatasetMeans object 'dataInput1' with expected results
- expect_equal(dataInput1$overallSampleSizes, c(18, 11, 21, 19, 12, 14, 21, 33, 35, NA_real_, 38, NA_real_, 45, NA_real_, 33, NA_real_, 58, NA_real_, 69, NA_real_, 66, NA_real_, 66, NA_real_), label = paste0("c(", paste0(dataInput1$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput1$overallMeans, c(125.6, 100.1, 135.9, 142.4, 107.7, 68.3, 84.9, 77.1, 118.55714, NA_real_, 127.75789, NA_real_, 85.7, NA_real_, 93.190909, NA_real_, 111.15862, NA_real_, 114.25362, NA_real_, 85.445455, NA_real_, 85.445455, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput1$overallStDevs, c(120.1, 116.8, 185, 120.6, 128.5, 124, 139.5, 163.5, 131.30971, NA_real_, 149.22508, NA_real_, 131.26649, NA_real_, 127.56945, NA_real_, 111.80482, NA_real_, 125.32216, NA_real_, 117.82181, NA_real_, 105.0948, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput1), NA)))
- expect_output(print(dataInput1)$show())
- invisible(capture.output(expect_error(summary(dataInput1), NA)))
- expect_output(summary(dataInput1)$show())
- dataInput1CodeBased <- eval(parse(text = getObjectRCode(dataInput1, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput1CodeBased$overallSampleSizes, dataInput1$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput1CodeBased$overallMeans, dataInput1$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput1CodeBased$overallStDevs, dataInput1$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput1), "character")
- df <- as.data.frame(dataInput1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ S1 <- getDataset(
+ sampleSize2 = c(12, 33, 21),
+ sampleSize1 = c(18, 17, 23),
+ mean2 = c(107.7, 77.7, 84.9),
+ mean1 = c(125.6, 111.1, 99.9),
+ stDev2 = c(128.5, 133.3, 84.9),
+ stDev1 = c(120.1, 145.6, 74.3)
+ )
+
+ S2 <- getDataset(
+ sampleSize2 = c(14, NA, NA),
+ sampleSize1 = c(11, NA, NA),
+ mean2 = c(68.3, NA, NA),
+ mean1 = c(100.1, NA, NA),
+ stDev2 = c(124.0, NA, NA),
+ stDev1 = c(116.8, NA, NA)
+ )
+
+ S12 <- getDataset(
+ sampleSize2 = c(21, 12, 33),
+ sampleSize1 = c(21, 17, 31),
+ mean2 = c(84.9, 107.7, 77.7),
+ mean1 = c(135.9, 117.7, 97.7),
+ stDev2 = c(139.5, 107.7, 77.7),
+ stDev1 = c(185.0, 92.3, 87.3)
+ )
+
+ R <- getDataset(
+ sampleSize2 = c(33, NA, NA),
+ sampleSize1 = c(19, NA, NA),
+ mean2 = c(77.1, NA, NA),
+ mean1 = c(142.4, NA, NA),
+ stDev2 = c(163.5, NA, NA),
+ stDev1 = c(120.6, NA, NA)
+ )
+
+ dataInput1 <- getDataset(S1 = S1, S2 = S2, S12 = S12, R = R)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput1' with expected results
+ expect_equal(dataInput1$overallSampleSizes, c(18, 11, 21, 19, 12, 14, 21, 33, 35, NA_real_, 38, NA_real_, 45, NA_real_, 33, NA_real_, 58, NA_real_, 69, NA_real_, 66, NA_real_, 66, NA_real_), label = paste0(dataInput1$overallSampleSizes))
+ expect_equal(dataInput1$overallMeans, c(125.6, 100.1, 135.9, 142.4, 107.7, 68.3, 84.9, 77.1, 118.55714, NA_real_, 127.75789, NA_real_, 85.7, NA_real_, 93.190909, NA_real_, 111.15862, NA_real_, 114.25362, NA_real_, 85.445455, NA_real_, 85.445455, NA_real_), tolerance = 1e-07, label = paste0(dataInput1$overallMeans))
+ expect_equal(dataInput1$overallStDevs, c(120.1, 116.8, 185, 120.6, 128.5, 124, 139.5, 163.5, 131.30971, NA_real_, 149.22508, NA_real_, 131.26649, NA_real_, 127.56945, NA_real_, 111.80482, NA_real_, 125.32216, NA_real_, 117.82181, NA_real_, 105.0948, NA_real_), tolerance = 1e-07, label = paste0(dataInput1$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput1), NA)))
+ expect_output(print(dataInput1)$show())
+ invisible(capture.output(expect_error(summary(dataInput1), NA)))
+ expect_output(summary(dataInput1)$show())
+ dataInput1CodeBased <- eval(parse(text = getObjectRCode(dataInput1, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput1CodeBased$overallSampleSizes, dataInput1$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput1CodeBased$overallMeans, dataInput1$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput1CodeBased$overallStDevs, dataInput1$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput1), "character")
+ df <- as.data.frame(dataInput1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
})
test_that("'getAnalysisResults': select S1 and S2 at first IA, select S1 at second, gMax = 3", {
-
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- design1 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
- bindingFutility = TRUE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
- )
-
- S1N <- getDataset(
- sampleSize1 = c(39, 34, NA),
- sampleSize2 = c(33, 45, NA),
- stDev1 = c(156.5026, 120.084, NA),
- stDev2 = c(134.0254, 126.502, NA),
- mean1 = c(131.146, 114.4, NA),
- mean2 = c(93.191, 85.7, NA)
- )
-
- S2N <- getDataset(
- sampleSize1 = c(32, NA, NA),
- sampleSize2 = c(35, NA, NA),
- stDev1 = c(163.645, NA, NA),
- stDev2 = c(131.888, NA, NA),
- mean1 = c(123.594, NA, NA),
- mean2 = c(78.26, NA, NA)
- )
-
- F <- getDataset(
- sampleSize1 = c(69, NA, NA),
- sampleSize2 = c(80, NA, NA),
- stDev1 = c(165.4682, NA, NA),
- stDev2 = c(143.9796, NA, NA),
- mean1 = c(129.2957, NA, NA),
- mean2 = c(82.1875, NA, NA)
- )
-
- dataInput2 <- getDataset(S1 = S1N, S2 = S2N, F = F)
-
- ## Comparison of the results of DatasetMeans object 'dataInput2' with expected results
- expect_equal(dataInput2$overallSampleSizes, c(39, 32, 69, 33, 35, 80, 73, NA_real_, NA_real_, 78, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput2$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput2$overallMeans, c(131.146, 123.594, 129.2957, 93.191, 78.26, 82.1875, 123.34649, NA_real_, NA_real_, 88.869269, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput2$overallStDevs, c(156.5026, 163.645, 165.4682, 134.0254, 131.888, 143.9796, 140.02459, NA_real_, NA_real_, 128.93165, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput2), NA)))
- expect_output(print(dataInput2)$show())
- invisible(capture.output(expect_error(summary(dataInput2), NA)))
- expect_output(summary(dataInput2)$show())
- dataInput2CodeBased <- eval(parse(text = getObjectRCode(dataInput2, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput2CodeBased$overallSampleSizes, dataInput2$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$overallMeans, dataInput2$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$overallStDevs, dataInput2$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput2), "character")
- df <- as.data.frame(dataInput2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x1 <- getAnalysisResults(
- design = design1, dataInput = dataInput2,
- directionUpper = TRUE,
- normalApproximation = FALSE,
- varianceOption = "pooled",
- intersectionTest = "Sidak",
- stratifiedAnalysis = FALSE,
- stage = 2,
- nPlanned = c(80),
- allocationRatioPlanned = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
- expect_equal(x1$thetaH1[1, ], 34.477224, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[3, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[3, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[1, ], 134.40636, tolerance = 1e-07, label = paste0("c(", paste0(x1$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x1$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[3, ], NA_real_, label = paste0("c(", paste0(x1$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.016142454, 0.02613542, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.016142454, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[3, ], c(0.050007377, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, 0.19507788), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(-81.45856, -34.885408, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(-79.606691, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[3, ], c(-38.192738, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(157.36856, 103.57092, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(170.27469, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[3, ], c(132.40914, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[1, ], c(0.34605439, 0.18712011, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[2, ], c(0.34605439, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[3, ], c(0.22233542, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[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$thetaH1, x1$thetaH1, tolerance = 1e-07)
- expect_equal(x1CodeBased$assumedStDevs, x1$assumedStDevs, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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)
- }
-
- design3 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
- bindingFutility = TRUE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
- )
-
- design2 <- getDesignFisher(
- kMax = 3, alpha = 0.02, alpha0Vec = c(0.7, 0.5), method = "equalAlpha",
- bindingFutility = TRUE, informationRates = c(0.3, 0.7, 1)
- )
-
- x2 <- getAnalysisResults(
- design = design3, dataInput = dataInput2,
- directionUpper = TRUE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Simes",
- stratifiedAnalysis = FALSE,
- stage = 2,
- thetaH1 = c(50, 30, NA),
- assumedStDevs = c(122, 88, NA),
- nPlanned = 80,
- allocationRatioPlanned = 0.5
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
- expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.03098783, 0.056162964, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.03098783, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[3, ], c(0.045486533, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, 0.55574729), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(-79.922689, -34.33441, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(-81.369964, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[3, ], c(-39.221831, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(155.83269, 103.18642, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(172.03796, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[3, ], c(133.43823, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[1, ], c(0.27466247, 0.13478543, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[2, ], c(0.27466247, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[3, ], c(0.23257404, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[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$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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 <- getAnalysisResults(
- design = design2, dataInput = dataInput2,
- directionUpper = TRUE,
- normalApproximation = FALSE,
- varianceOption = "pooled",
- intersectionTest = "Sidak",
- stratifiedAnalysis = FALSE,
- stage = 2,
- nPlanned = 80,
- allocationRatioPlanned = 0.5
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x3' with expected results
- expect_equal(x3$thetaH1[1, ], 34.477224, tolerance = 1e-07, label = paste0("c(", paste0(x3$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x3$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x3$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x3$thetaH1[3, ], NA_real_, label = paste0("c(", paste0(x3$thetaH1[3, ], collapse = ", "), ")"))
- expect_equal(x3$assumedStDevs[1, ], 134.40636, tolerance = 1e-07, label = paste0("c(", paste0(x3$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x3$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x3$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x3$assumedStDevs[3, ], NA_real_, label = paste0("c(", paste0(x3$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.01300837, 0.0063168592, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.01300837, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[3, ], c(0.024114983, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, 0.078920631), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(-58.494162, -30.46834, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(-55.474155, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[3, ], c(-22.271868, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(134.40416, 94.713072, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(146.14216, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[3, ], c(116.48827, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[1, ], c(0.29239601, 0.21229229, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[2, ], c(0.29239601, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[3, ], c(0.15217469, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[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$thetaH1, x3$thetaH1, tolerance = 1e-07)
- expect_equal(x3CodeBased$assumedStDevs, x3$assumedStDevs, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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 <- getAnalysisResults(
- design = design2, dataInput = dataInput2,
- directionUpper = TRUE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Simes",
- stratifiedAnalysis = FALSE,
- stage = 2,
- thetaH1 = c(50, NA, NA),
- assumedStDevs = c(122, NA, NA),
- nPlanned = 80,
- allocationRatioPlanned = 0.5
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x4' with expected results
- expect_equal(x4$conditionalRejectionProbabilities[1, ], c(0.018024059, 0.0095704388, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalRejectionProbabilities[2, ], c(0.018024059, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalRejectionProbabilities[3, ], c(0.022674244, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[1, ], c(NA_real_, NA_real_, 0.26935817), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[1, ], c(-57.292213, -30.050759, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[2, ], c(-56.802775, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[3, ], c(-23.100932, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[1, ], c(133.20221, 94.521132, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[2, ], c(147.47078, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[3, ], c(117.31733, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[1, ], c(0.20840036, 0.16345568, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[2, ], c(0.20840036, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[3, ], c(0.16277762, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[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$conditionalRejectionProbabilities, x4$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalPower, x4$conditionalPower, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedConfidenceIntervalLowerBounds, x4$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedConfidenceIntervalUpperBounds, x4$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedPValues, x4$repeatedPValues, 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)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ design1 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
+ bindingFutility = TRUE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
+ )
+
+ S1N <- getDataset(
+ sampleSize1 = c(39, 34, NA),
+ sampleSize2 = c(33, 45, NA),
+ stDev1 = c(156.5026, 120.084, NA),
+ stDev2 = c(134.0254, 126.502, NA),
+ mean1 = c(131.146, 114.4, NA),
+ mean2 = c(93.191, 85.7, NA)
+ )
+
+ S2N <- getDataset(
+ sampleSize1 = c(32, NA, NA),
+ sampleSize2 = c(35, NA, NA),
+ stDev1 = c(163.645, NA, NA),
+ stDev2 = c(131.888, NA, NA),
+ mean1 = c(123.594, NA, NA),
+ mean2 = c(78.26, NA, NA)
+ )
+
+ F <- getDataset(
+ sampleSize1 = c(69, NA, NA),
+ sampleSize2 = c(80, NA, NA),
+ stDev1 = c(165.4682, NA, NA),
+ stDev2 = c(143.9796, NA, NA),
+ mean1 = c(129.2957, NA, NA),
+ mean2 = c(82.1875, NA, NA)
+ )
+
+ dataInput2 <- getDataset(S1 = S1N, S2 = S2N, F = F)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput2' with expected results
+ expect_equal(dataInput2$overallSampleSizes, c(39, 32, 69, 33, 35, 80, 73, NA_real_, NA_real_, 78, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0(dataInput2$overallSampleSizes))
+ expect_equal(dataInput2$overallMeans, c(131.146, 123.594, 129.2957, 93.191, 78.26, 82.1875, 123.34649, NA_real_, NA_real_, 88.869269, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(dataInput2$overallMeans))
+ expect_equal(dataInput2$overallStDevs, c(156.5026, 163.645, 165.4682, 134.0254, 131.888, 143.9796, 140.02459, NA_real_, NA_real_, 128.93165, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(dataInput2$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput2), NA)))
+ expect_output(print(dataInput2)$show())
+ invisible(capture.output(expect_error(summary(dataInput2), NA)))
+ expect_output(summary(dataInput2)$show())
+ dataInput2CodeBased <- eval(parse(text = getObjectRCode(dataInput2, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput2CodeBased$overallSampleSizes, dataInput2$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$overallMeans, dataInput2$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$overallStDevs, dataInput2$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput2), "character")
+ df <- as.data.frame(dataInput2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x1 <- getAnalysisResults(
+ design = design1, dataInput = dataInput2,
+ directionUpper = TRUE,
+ normalApproximation = FALSE,
+ varianceOption = "pooled",
+ intersectionTest = "Sidak",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ nPlanned = c(80),
+ allocationRatioPlanned = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
+ expect_equal(x1$thetaH1[1, ], 34.477224, tolerance = 1e-07, label = paste0(x1$thetaH1[1, ]))
+ expect_equal(x1$thetaH1[2, ], NA_real_, label = paste0(x1$thetaH1[2, ]))
+ expect_equal(x1$thetaH1[3, ], NA_real_, label = paste0(x1$thetaH1[3, ]))
+ expect_equal(x1$assumedStDevs[1, ], 134.40636, tolerance = 1e-07, label = paste0(x1$assumedStDevs[1, ]))
+ expect_equal(x1$assumedStDevs[2, ], NA_real_, label = paste0(x1$assumedStDevs[2, ]))
+ expect_equal(x1$assumedStDevs[3, ], NA_real_, label = paste0(x1$assumedStDevs[3, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.016142454, 0.02613542, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.016142454, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[3, ], c(0.050007377, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, 0.19507788), tolerance = 1e-07, label = paste0(x1$conditionalPower[1, ]))
+ expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[2, ]))
+ expect_equal(x1$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[3, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(-81.45856, -34.885408, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(-79.606691, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[3, ], c(-38.192738, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(157.36856, 103.57092, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(170.27469, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[3, ], c(132.40914, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x1$repeatedPValues[1, ], c(0.34605439, 0.18712011, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[1, ]))
+ expect_equal(x1$repeatedPValues[2, ], c(0.34605439, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[2, ]))
+ expect_equal(x1$repeatedPValues[3, ], c(0.22233542, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[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$thetaH1, x1$thetaH1, tolerance = 1e-07)
+ expect_equal(x1CodeBased$assumedStDevs, x1$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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)
+ }
+
+ design3 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.02, futilityBounds = c(-0.5, 0),
+ bindingFutility = TRUE, typeOfDesign = "OF", informationRates = c(0.5, 0.7, 1)
+ )
+
+ design2 <- getDesignFisher(
+ kMax = 3, alpha = 0.02, alpha0Vec = c(0.7, 0.5), method = "equalAlpha",
+ bindingFutility = TRUE, informationRates = c(0.3, 0.7, 1)
+ )
+
+ x2 <- getAnalysisResults(
+ design = design3, dataInput = dataInput2,
+ directionUpper = TRUE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Simes",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ thetaH1 = c(50, 30, NA),
+ assumedStDevs = c(122, 88, NA),
+ nPlanned = 80,
+ allocationRatioPlanned = 0.5
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
+ expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.03098783, 0.056162964, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.03098783, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[3, ], c(0.045486533, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, 0.55574729), tolerance = 1e-07, label = paste0(x2$conditionalPower[1, ]))
+ expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[2, ]))
+ expect_equal(x2$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[3, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(-79.922689, -34.33441, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(-81.369964, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[3, ], c(-39.221831, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(155.83269, 103.18642, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(172.03796, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[3, ], c(133.43823, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x2$repeatedPValues[1, ], c(0.27466247, 0.13478543, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[1, ]))
+ expect_equal(x2$repeatedPValues[2, ], c(0.27466247, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[2, ]))
+ expect_equal(x2$repeatedPValues[3, ], c(0.23257404, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[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$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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 <- getAnalysisResults(
+ design = design2, dataInput = dataInput2,
+ directionUpper = TRUE,
+ normalApproximation = FALSE,
+ varianceOption = "pooled",
+ intersectionTest = "Sidak",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ nPlanned = 80,
+ allocationRatioPlanned = 0.5
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x3' with expected results
+ expect_equal(x3$thetaH1[1, ], 34.477224, tolerance = 1e-07, label = paste0(x3$thetaH1[1, ]))
+ expect_equal(x3$thetaH1[2, ], NA_real_, label = paste0(x3$thetaH1[2, ]))
+ expect_equal(x3$thetaH1[3, ], NA_real_, label = paste0(x3$thetaH1[3, ]))
+ expect_equal(x3$assumedStDevs[1, ], 134.40636, tolerance = 1e-07, label = paste0(x3$assumedStDevs[1, ]))
+ expect_equal(x3$assumedStDevs[2, ], NA_real_, label = paste0(x3$assumedStDevs[2, ]))
+ expect_equal(x3$assumedStDevs[3, ], NA_real_, label = paste0(x3$assumedStDevs[3, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.01300837, 0.0063168592, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.01300837, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[3, ], c(0.024114983, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, 0.078920631), tolerance = 1e-07, label = paste0(x3$conditionalPower[1, ]))
+ expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPower[2, ]))
+ expect_equal(x3$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPower[3, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(-58.494162, -30.46834, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(-55.474155, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[3, ], c(-22.271868, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(134.40416, 94.713072, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(146.14216, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[3, ], c(116.48827, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x3$repeatedPValues[1, ], c(0.29239601, 0.21229229, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedPValues[1, ]))
+ expect_equal(x3$repeatedPValues[2, ], c(0.29239601, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedPValues[2, ]))
+ expect_equal(x3$repeatedPValues[3, ], c(0.15217469, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$repeatedPValues[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$thetaH1, x3$thetaH1, tolerance = 1e-07)
+ expect_equal(x3CodeBased$assumedStDevs, x3$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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 <- getAnalysisResults(
+ design = design2, dataInput = dataInput2,
+ directionUpper = TRUE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Simes",
+ stratifiedAnalysis = FALSE,
+ stage = 2,
+ thetaH1 = c(50, NA, NA),
+ assumedStDevs = c(122, NA, NA),
+ nPlanned = 80,
+ allocationRatioPlanned = 0.5
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x4' with expected results
+ expect_equal(x4$conditionalRejectionProbabilities[1, ], c(0.018024059, 0.0095704388, NA_real_), tolerance = 1e-07, label = paste0(x4$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x4$conditionalRejectionProbabilities[2, ], c(0.018024059, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x4$conditionalRejectionProbabilities[3, ], c(0.022674244, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x4$conditionalPower[1, ], c(NA_real_, NA_real_, 0.26935817), tolerance = 1e-07, label = paste0(x4$conditionalPower[1, ]))
+ expect_equal(x4$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x4$conditionalPower[2, ]))
+ expect_equal(x4$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x4$conditionalPower[3, ]))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[1, ], c(-57.292213, -30.050759, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[2, ], c(-56.802775, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[3, ], c(-23.100932, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[1, ], c(133.20221, 94.521132, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[2, ], c(147.47078, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[3, ], c(117.31733, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x4$repeatedPValues[1, ], c(0.20840036, 0.16345568, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedPValues[1, ]))
+ expect_equal(x4$repeatedPValues[2, ], c(0.20840036, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedPValues[2, ]))
+ expect_equal(x4$repeatedPValues[3, ], c(0.16277762, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x4$repeatedPValues[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$conditionalRejectionProbabilities, x4$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalPower, x4$conditionalPower, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedConfidenceIntervalLowerBounds, x4$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedConfidenceIntervalUpperBounds, x4$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedPValues, x4$repeatedPValues, 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)
+ }
})
test_plan_section("Testing Analysis Enrichment Means Function (more sub-populations)")
test_that("'getAnalysisResults': select S1 and S3 at first IA, select S1 at second, gMax = 4", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- S1 <- getDataset(
- sampleSize1 = c(14, 22, 24),
- sampleSize2 = c(11, 18, 21),
- mean1 = c(68.3, 107.4, 101.2),
- mean2 = c(100.1, 140.9, 133.8),
- stDev1 = c(124.0, 134.7, 124.2),
- stDev2 = c(116.8, 133.7, 131.2)
- )
-
- S2 <- getDataset(
- sampleSize1 = c(12, NA, NA),
- sampleSize2 = c(18, NA, NA),
- mean1 = c(107.7, NA, NA),
- mean2 = c(125.6, NA, NA),
- stDev1 = c(128.5, NA, NA),
- stDev2 = c(120.1, NA, NA)
- )
-
- S3 <- getDataset(
- sampleSize1 = c(17, 24, NA),
- sampleSize2 = c(14, 19, NA),
- mean1 = c(64.3, 101.4, NA),
- mean2 = c(103.1, 170.4, NA),
- stDev1 = c(128.0, 125.3, NA),
- stDev2 = c(111.8, 143.6, NA)
- )
-
- F <- getDataset(
- sampleSize1 = c(83, NA, NA),
- sampleSize2 = c(79, NA, NA),
- mean1 = c(77.1, NA, NA),
- mean2 = c(142.4, NA, NA),
- stDev1 = c(163.5, NA, NA),
- stDev2 = c(120.6, NA, NA)
- )
-
- dataInput3 <- getDataset(S1 = S1, S2 = S2, S3 = S3, F = F)
-
- ## Comparison of the results of DatasetMeans object 'dataInput3' with expected results
- expect_equal(dataInput3$overallSampleSizes, c(14, 12, 17, 83, 11, 18, 14, 79, 36, NA_real_, 41, NA_real_, 29, NA_real_, 33, NA_real_, 60, NA_real_, NA_real_, NA_real_, 50, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput3$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput3$overallMeans, c(68.3, 107.7, 64.3, 77.1, 100.1, 125.6, 103.1, 142.4, 92.194444, NA_real_, 86.017073, NA_real_, 125.42414, NA_real_, 141.84848, NA_real_, 95.796667, NA_real_, NA_real_, NA_real_, 128.942, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput3$overallStDevs, c(124, 128.5, 128, 163.5, 116.8, 120.1, 111.8, 120.6, 130.27375, NA_real_, 126.18865, NA_real_, 127.0088, NA_real_, 133.48411, NA_real_, 126.8892, NA_real_, NA_real_, NA_real_, 127.51934, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput3), NA)))
- expect_output(print(dataInput3)$show())
- invisible(capture.output(expect_error(summary(dataInput3), NA)))
- expect_output(summary(dataInput3)$show())
- dataInput3CodeBased <- eval(parse(text = getObjectRCode(dataInput3, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput3CodeBased$overallSampleSizes, dataInput3$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput3CodeBased$overallMeans, dataInput3$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput3CodeBased$overallStDevs, dataInput3$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput3), "character")
- df <- as.data.frame(dataInput3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.025, typeOfDesign = "WT",
- deltaWT = 0.28, informationRates = c(0.5, 0.7, 1)
- )
-
- x1 <- getAnalysisResults(
- design = design1, dataInput = dataInput3,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Simes",
- stratifiedAnalysis = FALSE
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
- expect_equal(x1$thetaH1[1, ], -33.145333, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[3, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[3, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[4, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[4, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[1, ], 127.17548, tolerance = 1e-07, label = paste0("c(", paste0(x1$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x1$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[3, ], NA_real_, label = paste0("c(", paste0(x1$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(x1$assumedStDevs[4, ], NA_real_, label = paste0("c(", paste0(x1$assumedStDevs[4, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.0046188669, 0.003141658, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.0046188669, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[3, ], c(0.0046188669, 0.0093523023, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[4, ], c(0.41158519, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[4, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[4, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[4, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(-189.95235, -137.25075, -108.04127), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(-170.18127, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[3, ], c(-175.96326, -146.15913, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[4, ], c(-132.10549, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[4, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(126.35235, 72.344345, 43.127962), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(134.38127, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[3, ], c(98.363257, 46.507217, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[4, ], c(1.5054896, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[4, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[1, ], c(0.5, 0.35403281, 0.20618784), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[2, ], c(0.5, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[3, ], c(0.5, 0.26324129, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[4, ], c(0.029329288, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[4, ], 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$thetaH1, x1$thetaH1, tolerance = 1e-07)
- expect_equal(x1CodeBased$assumedStDevs, x1$assumedStDevs, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ S1 <- getDataset(
+ sampleSize1 = c(14, 22, 24),
+ sampleSize2 = c(11, 18, 21),
+ mean1 = c(68.3, 107.4, 101.2),
+ mean2 = c(100.1, 140.9, 133.8),
+ stDev1 = c(124.0, 134.7, 124.2),
+ stDev2 = c(116.8, 133.7, 131.2)
+ )
+
+ S2 <- getDataset(
+ sampleSize1 = c(12, NA, NA),
+ sampleSize2 = c(18, NA, NA),
+ mean1 = c(107.7, NA, NA),
+ mean2 = c(125.6, NA, NA),
+ stDev1 = c(128.5, NA, NA),
+ stDev2 = c(120.1, NA, NA)
+ )
+
+ S3 <- getDataset(
+ sampleSize1 = c(17, 24, NA),
+ sampleSize2 = c(14, 19, NA),
+ mean1 = c(64.3, 101.4, NA),
+ mean2 = c(103.1, 170.4, NA),
+ stDev1 = c(128.0, 125.3, NA),
+ stDev2 = c(111.8, 143.6, NA)
+ )
+
+ F <- getDataset(
+ sampleSize1 = c(83, NA, NA),
+ sampleSize2 = c(79, NA, NA),
+ mean1 = c(77.1, NA, NA),
+ mean2 = c(142.4, NA, NA),
+ stDev1 = c(163.5, NA, NA),
+ stDev2 = c(120.6, NA, NA)
+ )
+
+ dataInput3 <- getDataset(S1 = S1, S2 = S2, S3 = S3, F = F)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput3' with expected results
+ expect_equal(dataInput3$overallSampleSizes, c(14, 12, 17, 83, 11, 18, 14, 79, 36, NA_real_, 41, NA_real_, 29, NA_real_, 33, NA_real_, 60, NA_real_, NA_real_, NA_real_, 50, NA_real_, NA_real_, NA_real_), label = paste0(dataInput3$overallSampleSizes))
+ expect_equal(dataInput3$overallMeans, c(68.3, 107.7, 64.3, 77.1, 100.1, 125.6, 103.1, 142.4, 92.194444, NA_real_, 86.017073, NA_real_, 125.42414, NA_real_, 141.84848, NA_real_, 95.796667, NA_real_, NA_real_, NA_real_, 128.942, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(dataInput3$overallMeans))
+ expect_equal(dataInput3$overallStDevs, c(124, 128.5, 128, 163.5, 116.8, 120.1, 111.8, 120.6, 130.27375, NA_real_, 126.18865, NA_real_, 127.0088, NA_real_, 133.48411, NA_real_, 126.8892, NA_real_, NA_real_, NA_real_, 127.51934, NA_real_, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(dataInput3$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput3), NA)))
+ expect_output(print(dataInput3)$show())
+ invisible(capture.output(expect_error(summary(dataInput3), NA)))
+ expect_output(summary(dataInput3)$show())
+ dataInput3CodeBased <- eval(parse(text = getObjectRCode(dataInput3, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput3CodeBased$overallSampleSizes, dataInput3$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput3CodeBased$overallMeans, dataInput3$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput3CodeBased$overallStDevs, dataInput3$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput3), "character")
+ df <- as.data.frame(dataInput3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.025, typeOfDesign = "WT",
+ deltaWT = 0.28, informationRates = c(0.5, 0.7, 1)
+ )
+
+ x1 <- getAnalysisResults(
+ design = design1, dataInput = dataInput3,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Simes",
+ stratifiedAnalysis = FALSE
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
+ expect_equal(x1$thetaH1[1, ], -33.145333, tolerance = 1e-07, label = paste0(x1$thetaH1[1, ]))
+ expect_equal(x1$thetaH1[2, ], NA_real_, label = paste0(x1$thetaH1[2, ]))
+ expect_equal(x1$thetaH1[3, ], NA_real_, label = paste0(x1$thetaH1[3, ]))
+ expect_equal(x1$thetaH1[4, ], NA_real_, label = paste0(x1$thetaH1[4, ]))
+ expect_equal(x1$assumedStDevs[1, ], 127.17548, tolerance = 1e-07, label = paste0(x1$assumedStDevs[1, ]))
+ expect_equal(x1$assumedStDevs[2, ], NA_real_, label = paste0(x1$assumedStDevs[2, ]))
+ expect_equal(x1$assumedStDevs[3, ], NA_real_, label = paste0(x1$assumedStDevs[3, ]))
+ expect_equal(x1$assumedStDevs[4, ], NA_real_, label = paste0(x1$assumedStDevs[4, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.0046188669, 0.003141658, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.0046188669, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[3, ], c(0.0046188669, 0.0093523023, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x1$conditionalRejectionProbabilities[4, ], c(0.41158519, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$conditionalRejectionProbabilities[4, ]))
+ expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[1, ]))
+ expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[2, ]))
+ expect_equal(x1$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[3, ]))
+ expect_equal(x1$conditionalPower[4, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x1$conditionalPower[4, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(-189.95235, -137.25075, -108.04127), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(-170.18127, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[3, ], c(-175.96326, -146.15913, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[4, ], c(-132.10549, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalLowerBounds[4, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(126.35235, 72.344345, 43.127962), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(134.38127, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[3, ], c(98.363257, 46.507217, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[4, ], c(1.5054896, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedConfidenceIntervalUpperBounds[4, ]))
+ expect_equal(x1$repeatedPValues[1, ], c(0.5, 0.35403281, 0.20618784), tolerance = 1e-07, label = paste0(x1$repeatedPValues[1, ]))
+ expect_equal(x1$repeatedPValues[2, ], c(0.5, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[2, ]))
+ expect_equal(x1$repeatedPValues[3, ], c(0.5, 0.26324129, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[3, ]))
+ expect_equal(x1$repeatedPValues[4, ], c(0.029329288, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x1$repeatedPValues[4, ]))
+ 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$thetaH1, x1$thetaH1, tolerance = 1e-07)
+ expect_equal(x1CodeBased$assumedStDevs, x1$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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)
+ }
})
test_that("'getAnalysisResults': stratified analysis, gMax = 4", {
-
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- S1 <- getDataset(
- sampleSize1 = c(14, 22, NA),
- sampleSize2 = c(11, 18, NA),
- mean1 = c(68.3, 107.4, NA),
- mean2 = c(100.1, 140.9, NA),
- stDev1 = c(124.0, 134.7, NA),
- stDev2 = c(116.8, 133.7, NA)
- )
-
- S2 <- getDataset(
- sampleSize1 = c(12, NA, NA),
- sampleSize2 = c(18, NA, NA),
- mean1 = c(107.7, NA, NA),
- mean2 = c(125.6, NA, NA),
- stDev1 = c(128.5, NA, NA),
- stDev2 = c(120.1, NA, NA)
- )
-
- S3 <- getDataset(
- sampleSize1 = c(17, 24, NA),
- sampleSize2 = c(14, 19, NA),
- mean1 = c(64.3, 101.4, NA),
- mean2 = c(103.1, 170.4, NA),
- stDev1 = c(128.0, 125.3, NA),
- stDev2 = c(111.8, 143.6, NA)
- )
-
- S12 <- getDataset(
- sampleSize1 = c(21, 12, 33),
- sampleSize2 = c(21, 17, 31),
- mean1 = c(84.9, 107.7, 77.7),
- mean2 = c(135.9, 117.7, 97.7),
- stDev1 = c(139.5, 107.7, 77.7),
- stDev2 = c(185.0, 92.3, 87.3)
- )
-
- S13 <- getDataset(
- sampleSize1 = c(21, 12, 33),
- sampleSize2 = c(21, 17, 31),
- mean1 = c(84.9, 107.7, 77.7),
- mean2 = c(135.9, 117.7, 97.7),
- stDev1 = c(139.5, 107.7, 77.7),
- stDev2 = c(185.0, 92.3, 87.3)
- )
-
- S23 <- getDataset(
- sampleSize1 = c(21, 12, 33),
- sampleSize2 = c(21, 17, 31),
- mean1 = c(84.9, 107.7, 77.7),
- mean2 = c(135.9, 117.7, 97.7),
- stDev1 = c(139.5, 107.7, 77.7),
- stDev2 = c(185.0, 92.3, 87.3)
- )
-
- S123 <- getDataset(
- sampleSize1 = c(21, 12, 33),
- sampleSize2 = c(21, 17, 31),
- mean1 = c(84.9, 107.7, 77.7),
- mean2 = c(135.9, 117.7, 97.7),
- stDev1 = c(139.5, 107.7, 77.7),
- stDev2 = c(185.0, 92.3, 87.3)
- )
-
- R <- getDataset(
- sampleSize1 = c(33, NA, NA),
- sampleSize2 = c(19, NA, NA),
- mean1 = c(77.1, NA, NA),
- mean2 = c(142.4, NA, NA),
- stDev1 = c(163.5, NA, NA),
- stDev2 = c(120.6, NA, NA)
- )
-
- dataInput4 <- getDataset(S1 = S1, S2 = S2, S3 = S3, S12 = S12, S23 = S23, S13 = S13, S123 = S123, R = R)
-
- ## Comparison of the results of DatasetMeans object 'dataInput4' with expected results
- expect_equal(dataInput4$overallSampleSizes, c(14, 12, 17, 21, 21, 21, 21, 33, 11, 18, 14, 21, 21, 21, 21, 19, 36, NA_real_, 41, 33, 33, 33, 33, NA_real_, 29, NA_real_, 33, 38, 38, 38, 38, NA_real_, NA_real_, NA_real_, NA_real_, 66, 66, 66, 66, NA_real_, NA_real_, NA_real_, NA_real_, 69, 69, 69, 69, NA_real_), label = paste0("c(", paste0(dataInput4$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput4$overallMeans, c(68.3, 107.7, 64.3, 84.9, 84.9, 84.9, 84.9, 77.1, 100.1, 125.6, 103.1, 135.9, 135.9, 135.9, 135.9, 142.4, 92.194444, NA_real_, 86.017073, 93.190909, 93.190909, 93.190909, 93.190909, NA_real_, 125.42414, NA_real_, 141.84848, 127.75789, 127.75789, 127.75789, 127.75789, NA_real_, NA_real_, NA_real_, NA_real_, 85.445455, 85.445455, 85.445455, 85.445455, NA_real_, NA_real_, NA_real_, NA_real_, 114.25362, 114.25362, 114.25362, 114.25362, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput4$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput4$overallStDevs, c(124, 128.5, 128, 139.5, 139.5, 139.5, 139.5, 163.5, 116.8, 120.1, 111.8, 185, 185, 185, 185, 120.6, 130.27375, NA_real_, 126.18865, 127.56945, 127.56945, 127.56945, 127.56945, NA_real_, 127.0088, NA_real_, 133.48411, 149.22508, 149.22508, 149.22508, 149.22508, NA_real_, NA_real_, NA_real_, NA_real_, 105.0948, 105.0948, 105.0948, 105.0948, NA_real_, NA_real_, NA_real_, NA_real_, 125.32216, 125.32216, 125.32216, 125.32216, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput4$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput4), NA)))
- expect_output(print(dataInput4)$show())
- invisible(capture.output(expect_error(summary(dataInput4), NA)))
- expect_output(summary(dataInput4)$show())
- dataInput4CodeBased <- eval(parse(text = getObjectRCode(dataInput4, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput4CodeBased$overallSampleSizes, dataInput4$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput4CodeBased$overallMeans, dataInput4$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput4CodeBased$overallStDevs, dataInput4$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput4), "character")
- df <- as.data.frame(dataInput4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.025, typeOfDesign = "WT",
- deltaWT = 0.28, informationRates = c(0.5, 0.7, 1)
- )
-
- x2 <- getAnalysisResults(
- design = design1, dataInput = dataInput4,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Simes",
- stratifiedAnalysis = TRUE,
- stage = 2
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
- expect_equal(x2$thetaH1[1, ], -34.35943, tolerance = 1e-07, label = paste0("c(", paste0(x2$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x2$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x2$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x2$thetaH1[3, ], -39.831088, tolerance = 1e-07, label = paste0("c(", paste0(x2$thetaH1[3, ], collapse = ", "), ")"))
- expect_equal(x2$thetaH1[4, ], NA_real_, label = paste0("c(", paste0(x2$thetaH1[4, ], collapse = ", "), ")"))
- expect_equal(x2$assumedStDevs[1, ], 135.6664, tolerance = 1e-07, label = paste0("c(", paste0(x2$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x2$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x2$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x2$assumedStDevs[3, ], 135.69515, tolerance = 1e-07, label = paste0("c(", paste0(x2$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(x2$assumedStDevs[4, ], NA_real_, label = paste0("c(", paste0(x2$assumedStDevs[4, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.14436944, 0.18888867, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.14436944, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[3, ], c(0.14436944, 0.23567728, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[4, ], c(0.33356756, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[4, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[4, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[4, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(-124.13667, -87.790806, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(-119.97906, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[3, ], c(-122.68924, -91.731817, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[4, ], c(-97.969856, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[4, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(28.41771, 15.834301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(30.295343, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[3, ], c(25.470801, 9.1408918, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[4, ], c(3.369313, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[4, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[1, ], c(0.096549841, 0.052699984, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[2, ], c(0.096549841, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[3, ], c(0.096549841, 0.042135201, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[4, ], c(0.039953198, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[4, ], 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$thetaH1, x2$thetaH1, tolerance = 1e-07)
- expect_equal(x2CodeBased$assumedStDevs, x2$assumedStDevs, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
- }
-
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ S1 <- getDataset(
+ sampleSize1 = c(14, 22, NA),
+ sampleSize2 = c(11, 18, NA),
+ mean1 = c(68.3, 107.4, NA),
+ mean2 = c(100.1, 140.9, NA),
+ stDev1 = c(124.0, 134.7, NA),
+ stDev2 = c(116.8, 133.7, NA)
+ )
+
+ S2 <- getDataset(
+ sampleSize1 = c(12, NA, NA),
+ sampleSize2 = c(18, NA, NA),
+ mean1 = c(107.7, NA, NA),
+ mean2 = c(125.6, NA, NA),
+ stDev1 = c(128.5, NA, NA),
+ stDev2 = c(120.1, NA, NA)
+ )
+
+ S3 <- getDataset(
+ sampleSize1 = c(17, 24, NA),
+ sampleSize2 = c(14, 19, NA),
+ mean1 = c(64.3, 101.4, NA),
+ mean2 = c(103.1, 170.4, NA),
+ stDev1 = c(128.0, 125.3, NA),
+ stDev2 = c(111.8, 143.6, NA)
+ )
+
+ S12 <- getDataset(
+ sampleSize1 = c(21, 12, 33),
+ sampleSize2 = c(21, 17, 31),
+ mean1 = c(84.9, 107.7, 77.7),
+ mean2 = c(135.9, 117.7, 97.7),
+ stDev1 = c(139.5, 107.7, 77.7),
+ stDev2 = c(185.0, 92.3, 87.3)
+ )
+
+ S13 <- getDataset(
+ sampleSize1 = c(21, 12, 33),
+ sampleSize2 = c(21, 17, 31),
+ mean1 = c(84.9, 107.7, 77.7),
+ mean2 = c(135.9, 117.7, 97.7),
+ stDev1 = c(139.5, 107.7, 77.7),
+ stDev2 = c(185.0, 92.3, 87.3)
+ )
+
+ S23 <- getDataset(
+ sampleSize1 = c(21, 12, 33),
+ sampleSize2 = c(21, 17, 31),
+ mean1 = c(84.9, 107.7, 77.7),
+ mean2 = c(135.9, 117.7, 97.7),
+ stDev1 = c(139.5, 107.7, 77.7),
+ stDev2 = c(185.0, 92.3, 87.3)
+ )
+
+ S123 <- getDataset(
+ sampleSize1 = c(21, 12, 33),
+ sampleSize2 = c(21, 17, 31),
+ mean1 = c(84.9, 107.7, 77.7),
+ mean2 = c(135.9, 117.7, 97.7),
+ stDev1 = c(139.5, 107.7, 77.7),
+ stDev2 = c(185.0, 92.3, 87.3)
+ )
+
+ R <- getDataset(
+ sampleSize1 = c(33, NA, NA),
+ sampleSize2 = c(19, NA, NA),
+ mean1 = c(77.1, NA, NA),
+ mean2 = c(142.4, NA, NA),
+ stDev1 = c(163.5, NA, NA),
+ stDev2 = c(120.6, NA, NA)
+ )
+
+ dataInput4 <- getDataset(S1 = S1, S2 = S2, S3 = S3, S12 = S12, S23 = S23, S13 = S13, S123 = S123, R = R)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput4' with expected results
+ expect_equal(dataInput4$overallSampleSizes, c(14, 12, 17, 21, 21, 21, 21, 33, 11, 18, 14, 21, 21, 21, 21, 19, 36, NA_real_, 41, 33, 33, 33, 33, NA_real_, 29, NA_real_, 33, 38, 38, 38, 38, NA_real_, NA_real_, NA_real_, NA_real_, 66, 66, 66, 66, NA_real_, NA_real_, NA_real_, NA_real_, 69, 69, 69, 69, NA_real_), label = paste0(dataInput4$overallSampleSizes))
+ expect_equal(dataInput4$overallMeans, c(68.3, 107.7, 64.3, 84.9, 84.9, 84.9, 84.9, 77.1, 100.1, 125.6, 103.1, 135.9, 135.9, 135.9, 135.9, 142.4, 92.194444, NA_real_, 86.017073, 93.190909, 93.190909, 93.190909, 93.190909, NA_real_, 125.42414, NA_real_, 141.84848, 127.75789, 127.75789, 127.75789, 127.75789, NA_real_, NA_real_, NA_real_, NA_real_, 85.445455, 85.445455, 85.445455, 85.445455, NA_real_, NA_real_, NA_real_, NA_real_, 114.25362, 114.25362, 114.25362, 114.25362, NA_real_), tolerance = 1e-07, label = paste0(dataInput4$overallMeans))
+ expect_equal(dataInput4$overallStDevs, c(124, 128.5, 128, 139.5, 139.5, 139.5, 139.5, 163.5, 116.8, 120.1, 111.8, 185, 185, 185, 185, 120.6, 130.27375, NA_real_, 126.18865, 127.56945, 127.56945, 127.56945, 127.56945, NA_real_, 127.0088, NA_real_, 133.48411, 149.22508, 149.22508, 149.22508, 149.22508, NA_real_, NA_real_, NA_real_, NA_real_, 105.0948, 105.0948, 105.0948, 105.0948, NA_real_, NA_real_, NA_real_, NA_real_, 125.32216, 125.32216, 125.32216, 125.32216, NA_real_), tolerance = 1e-07, label = paste0(dataInput4$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput4), NA)))
+ expect_output(print(dataInput4)$show())
+ invisible(capture.output(expect_error(summary(dataInput4), NA)))
+ expect_output(summary(dataInput4)$show())
+ dataInput4CodeBased <- eval(parse(text = getObjectRCode(dataInput4, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput4CodeBased$overallSampleSizes, dataInput4$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput4CodeBased$overallMeans, dataInput4$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput4CodeBased$overallStDevs, dataInput4$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput4), "character")
+ df <- as.data.frame(dataInput4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.025, typeOfDesign = "WT",
+ deltaWT = 0.28, informationRates = c(0.5, 0.7, 1)
+ )
+
+ x2 <- getAnalysisResults(
+ design = design1, dataInput = dataInput4,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Simes",
+ stratifiedAnalysis = TRUE,
+ stage = 2
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
+ expect_equal(x2$thetaH1[1, ], -34.35943, tolerance = 1e-07, label = paste0(x2$thetaH1[1, ]))
+ expect_equal(x2$thetaH1[2, ], NA_real_, label = paste0(x2$thetaH1[2, ]))
+ expect_equal(x2$thetaH1[3, ], -39.831088, tolerance = 1e-07, label = paste0(x2$thetaH1[3, ]))
+ expect_equal(x2$thetaH1[4, ], NA_real_, label = paste0(x2$thetaH1[4, ]))
+ expect_equal(x2$assumedStDevs[1, ], 135.6664, tolerance = 1e-07, label = paste0(x2$assumedStDevs[1, ]))
+ expect_equal(x2$assumedStDevs[2, ], NA_real_, label = paste0(x2$assumedStDevs[2, ]))
+ expect_equal(x2$assumedStDevs[3, ], 135.69515, tolerance = 1e-07, label = paste0(x2$assumedStDevs[3, ]))
+ expect_equal(x2$assumedStDevs[4, ], NA_real_, label = paste0(x2$assumedStDevs[4, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.14436944, 0.18888867, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.14436944, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[3, ], c(0.14436944, 0.23567728, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x2$conditionalRejectionProbabilities[4, ], c(0.33356756, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$conditionalRejectionProbabilities[4, ]))
+ expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[1, ]))
+ expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[2, ]))
+ expect_equal(x2$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[3, ]))
+ expect_equal(x2$conditionalPower[4, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x2$conditionalPower[4, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(-124.13667, -87.790806, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(-119.97906, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[3, ], c(-122.68924, -91.731817, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[4, ], c(-97.969856, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalLowerBounds[4, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(28.41771, 15.834301, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(30.295343, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[3, ], c(25.470801, 9.1408918, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[4, ], c(3.369313, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedConfidenceIntervalUpperBounds[4, ]))
+ expect_equal(x2$repeatedPValues[1, ], c(0.096549841, 0.052699984, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[1, ]))
+ expect_equal(x2$repeatedPValues[2, ], c(0.096549841, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[2, ]))
+ expect_equal(x2$repeatedPValues[3, ], c(0.096549841, 0.042135201, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[3, ]))
+ expect_equal(x2$repeatedPValues[4, ], c(0.039953198, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x2$repeatedPValues[4, ]))
+ 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$thetaH1, x2$thetaH1, tolerance = 1e-07)
+ expect_equal(x2CodeBased$assumedStDevs, x2$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
+ }
})
test_plan_section("Testing Analysis Enrichment Means Function (more sub-populations)")
test_that("'getAnalysisResults': select S1 at first IA, gMax = 3, no early efficacy stop", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedtTestEnrichment}
- S1 <- getDataset(
- sampleSize1 = c(14, 22, 24),
- sampleSize2 = c(11, 18, 21),
- mean1 = c(68.3, 107.4, 101.2),
- mean2 = c(100.1, 140.9, 133.8),
- stDev1 = c(124.0, 134.7, 124.2),
- stDev2 = c(116.8, 133.7, 131.2)
- )
-
- S2 <- getDataset(
- sampleSize1 = c(12, NA, NA),
- sampleSize2 = c(18, NA, NA),
- mean1 = c(107.7, NA, NA),
- mean2 = c(125.6, NA, NA),
- stDev1 = c(128.5, NA, NA),
- stDev2 = c(120.1, NA, NA)
- )
-
- F <- getDataset(
- sampleSize1 = c(83, NA, NA),
- sampleSize2 = c(79, NA, NA),
- mean1 = c(77.1, NA, NA),
- mean2 = c(142.4, NA, NA),
- stDev1 = c(163.5, NA, NA),
- stDev2 = c(120.6, NA, NA)
- )
-
- dataInput3 <- getDataset(S1 = S1, S2 = S2, F = F)
-
- ## Comparison of the results of DatasetMeans object 'dataInput3' with expected results
- expect_equal(dataInput3$overallSampleSizes, c(14, 12, 83, 11, 18, 79, 36, NA_real_, NA_real_, 29, NA_real_, NA_real_, 60, NA_real_, NA_real_, 50, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput3$overallSampleSizes, collapse = ", "), ")"))
- expect_equal(dataInput3$overallMeans, c(68.3, 107.7, 77.1, 100.1, 125.6, 142.4, 92.194444, NA_real_, NA_real_, 125.42414, NA_real_, NA_real_, 95.796667, NA_real_, NA_real_, 128.942, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$overallMeans, collapse = ", "), ")"))
- expect_equal(dataInput3$overallStDevs, c(124, 128.5, 163.5, 116.8, 120.1, 120.6, 130.27375, NA_real_, NA_real_, 127.0088, NA_real_, NA_real_, 126.8892, NA_real_, NA_real_, 127.51934, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$overallStDevs, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput3), NA)))
- expect_output(print(dataInput3)$show())
- invisible(capture.output(expect_error(summary(dataInput3), NA)))
- expect_output(summary(dataInput3)$show())
- dataInput3CodeBased <- eval(parse(text = getObjectRCode(dataInput3, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput3CodeBased$overallSampleSizes, dataInput3$overallSampleSizes, tolerance = 1e-07)
- expect_equal(dataInput3CodeBased$overallMeans, dataInput3$overallMeans, tolerance = 1e-07)
- expect_equal(dataInput3CodeBased$overallStDevs, dataInput3$overallStDevs, tolerance = 1e-07)
- expect_type(names(dataInput3), "character")
- df <- as.data.frame(dataInput3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design3 <- getDesignInverseNormal(
- kMax = 3, alpha = 0.025, typeOfDesign = "noEarlyEfficacy",
- informationRates = c(0.4, 0.7, 1)
- )
-
- x3 <- getAnalysisResults(
- design = design3, dataInput = dataInput3,
- thetaH0 = 30,
- directionUpper = FALSE,
- normalApproximation = FALSE,
- varianceOption = "notPooled",
- intersectionTest = "Simes",
- stratifiedAnalysis = FALSE
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x3' with expected results
- expect_equal(x3$thetaH1[1, ], -33.145333, tolerance = 1e-07, label = paste0("c(", paste0(x3$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x3$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x3$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x3$thetaH1[3, ], NA_real_, label = paste0("c(", paste0(x3$thetaH1[3, ], collapse = ", "), ")"))
- expect_equal(x3$assumedStDevs[1, ], 127.17548, tolerance = 1e-07, label = paste0("c(", paste0(x3$assumedStDevs[1, ], collapse = ", "), ")"))
- expect_equal(x3$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(x3$assumedStDevs[2, ], collapse = ", "), ")"))
- expect_equal(x3$assumedStDevs[3, ], NA_real_, label = paste0("c(", paste0(x3$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.043562209, 0.16805804, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.043562209, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[3, ], c(0.72997271, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(NA_real_, NA_real_, -94.8291), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(NA_real_, NA_real_, 29.811159), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[1, ], c(NA_real_, NA_real_, 0.010432269), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x3$repeatedPValues[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$thetaH1, x3$thetaH1, tolerance = 1e-07)
- expect_equal(x3CodeBased$assumedStDevs, x3$assumedStDevs, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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)
- }
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichment}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedtTestEnrichment}
+ S1 <- getDataset(
+ sampleSize1 = c(14, 22, 24),
+ sampleSize2 = c(11, 18, 21),
+ mean1 = c(68.3, 107.4, 101.2),
+ mean2 = c(100.1, 140.9, 133.8),
+ stDev1 = c(124.0, 134.7, 124.2),
+ stDev2 = c(116.8, 133.7, 131.2)
+ )
+
+ S2 <- getDataset(
+ sampleSize1 = c(12, NA, NA),
+ sampleSize2 = c(18, NA, NA),
+ mean1 = c(107.7, NA, NA),
+ mean2 = c(125.6, NA, NA),
+ stDev1 = c(128.5, NA, NA),
+ stDev2 = c(120.1, NA, NA)
+ )
+
+ F <- getDataset(
+ sampleSize1 = c(83, NA, NA),
+ sampleSize2 = c(79, NA, NA),
+ mean1 = c(77.1, NA, NA),
+ mean2 = c(142.4, NA, NA),
+ stDev1 = c(163.5, NA, NA),
+ stDev2 = c(120.6, NA, NA)
+ )
+
+ dataInput3 <- getDataset(S1 = S1, S2 = S2, F = F)
+
+ ## Comparison of the results of DatasetMeans object 'dataInput3' with expected results
+ expect_equal(dataInput3$overallSampleSizes, c(14, 12, 83, 11, 18, 79, 36, NA_real_, NA_real_, 29, NA_real_, NA_real_, 60, NA_real_, NA_real_, 50, NA_real_, NA_real_), label = paste0(dataInput3$overallSampleSizes))
+ expect_equal(dataInput3$overallMeans, c(68.3, 107.7, 77.1, 100.1, 125.6, 142.4, 92.194444, NA_real_, NA_real_, 125.42414, NA_real_, NA_real_, 95.796667, NA_real_, NA_real_, 128.942, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(dataInput3$overallMeans))
+ expect_equal(dataInput3$overallStDevs, c(124, 128.5, 163.5, 116.8, 120.1, 120.6, 130.27375, NA_real_, NA_real_, 127.0088, NA_real_, NA_real_, 126.8892, NA_real_, NA_real_, 127.51934, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(dataInput3$overallStDevs))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput3), NA)))
+ expect_output(print(dataInput3)$show())
+ invisible(capture.output(expect_error(summary(dataInput3), NA)))
+ expect_output(summary(dataInput3)$show())
+ dataInput3CodeBased <- eval(parse(text = getObjectRCode(dataInput3, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput3CodeBased$overallSampleSizes, dataInput3$overallSampleSizes, tolerance = 1e-07)
+ expect_equal(dataInput3CodeBased$overallMeans, dataInput3$overallMeans, tolerance = 1e-07)
+ expect_equal(dataInput3CodeBased$overallStDevs, dataInput3$overallStDevs, tolerance = 1e-07)
+ expect_type(names(dataInput3), "character")
+ df <- as.data.frame(dataInput3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design3 <- getDesignInverseNormal(
+ kMax = 3, alpha = 0.025, typeOfDesign = "noEarlyEfficacy",
+ informationRates = c(0.4, 0.7, 1)
+ )
+
+ x3 <- getAnalysisResults(
+ design = design3, dataInput = dataInput3,
+ thetaH0 = 30,
+ directionUpper = FALSE,
+ normalApproximation = FALSE,
+ varianceOption = "notPooled",
+ intersectionTest = "Simes",
+ stratifiedAnalysis = FALSE
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x3' with expected results
+ expect_equal(x3$thetaH1[1, ], -33.145333, tolerance = 1e-07, label = paste0(x3$thetaH1[1, ]))
+ expect_equal(x3$thetaH1[2, ], NA_real_, label = paste0(x3$thetaH1[2, ]))
+ expect_equal(x3$thetaH1[3, ], NA_real_, label = paste0(x3$thetaH1[3, ]))
+ expect_equal(x3$assumedStDevs[1, ], 127.17548, tolerance = 1e-07, label = paste0(x3$assumedStDevs[1, ]))
+ expect_equal(x3$assumedStDevs[2, ], NA_real_, label = paste0(x3$assumedStDevs[2, ]))
+ expect_equal(x3$assumedStDevs[3, ], NA_real_, label = paste0(x3$assumedStDevs[3, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.043562209, 0.16805804, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[1, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.043562209, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[2, ]))
+ expect_equal(x3$conditionalRejectionProbabilities[3, ], c(0.72997271, NA_real_, NA_real_), tolerance = 1e-07, label = paste0(x3$conditionalRejectionProbabilities[3, ]))
+ expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPower[1, ]))
+ expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPower[2, ]))
+ expect_equal(x3$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$conditionalPower[3, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(NA_real_, NA_real_, -94.8291), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ]))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$repeatedConfidenceIntervalLowerBounds[3, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(NA_real_, NA_real_, 29.811159), tolerance = 1e-07, label = paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ]))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$repeatedConfidenceIntervalUpperBounds[3, ]))
+ expect_equal(x3$repeatedPValues[1, ], c(NA_real_, NA_real_, 0.010432269), tolerance = 1e-07, label = paste0(x3$repeatedPValues[1, ]))
+ expect_equal(x3$repeatedPValues[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$repeatedPValues[2, ]))
+ expect_equal(x3$repeatedPValues[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0(x3$repeatedPValues[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$thetaH1, x3$thetaH1, tolerance = 1e-07)
+ expect_equal(x3CodeBased$assumedStDevs, x3$assumedStDevs, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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)
+ }
})
-
diff --git a/tests/testthat/test-f_analysis_enrichment_survival.R b/tests/testthat/test-f_analysis_enrichment_survival.R
index 3a91c15f..1af2e4d4 100644
--- a/tests/testthat/test-f_analysis_enrichment_survival.R
+++ b/tests/testthat/test-f_analysis_enrichment_survival.R
@@ -1,556 +1,561 @@
-## |
+## |
## | *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_analysis_enrichment_survival.R
## | Creation date: 08 November 2023, 08:55:32
-## | File version: $Revision: 7682 $
-## | Last changed: $Date: 2024-03-05 07:53:40 +0100 (Di, 05 Mrz 2024) $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
-## |
+## |
test_plan_section("Testing Analysis Enrichment Survival Function")
test_that("'getAnalysisResults': enrichment survival, one sub-population, non-stratified analysis, select S1 at second, gMax = 2", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentSurvival}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedTestEnrichmentSurvival}
- # @refFS[Formula]{fs:testStatisticEnrichmentSurvival}
- S1 <- getDataset(
- events = c(37, 35, 22),
- logRanks = c(1.66, 1.38, 1.22),
- allocationRatios = c(1, 1, 1)
- )
-
- F <- getDataset(
- events = c(66, 55, NA),
- logRanks = c(1.98, 1.57, NA),
- allocationRatios = c(1, 1, NA)
- )
-
- dataInput1 <- getDataset(S1 = S1, F = F)
-
- ## Comparison of the results of DatasetSurvival object 'dataInput1' with expected results
- expect_equal(dataInput1$events, c(37, 66, 35, 55, 22, NA_real_), label = paste0("c(", paste0(dataInput1$events, collapse = ", "), ")"))
- expect_equal(dataInput1$allocationRatios, c(1, 1, 1, 1, 1, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$allocationRatios, collapse = ", "), ")"))
- expect_equal(dataInput1$logRanks, c(1.66, 1.98, 1.38, 1.57, 1.22, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$logRanks, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput1), NA)))
- expect_output(print(dataInput1)$show())
- invisible(capture.output(expect_error(summary(dataInput1), NA)))
- expect_output(summary(dataInput1)$show())
- dataInput1CodeBased <- eval(parse(text = getObjectRCode(dataInput1, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput1CodeBased$events, dataInput1$events, tolerance = 1e-07)
- expect_equal(dataInput1CodeBased$allocationRatios, dataInput1$allocationRatios, tolerance = 1e-07)
- expect_equal(dataInput1CodeBased$logRanks, dataInput1$logRanks, tolerance = 1e-07)
- expect_type(names(dataInput1), "character")
- df <- as.data.frame(dataInput1)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput1)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, typeOfDesign = "asP", typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.025,
- informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
- )
-
- x1 <- getAnalysisResults(
- design = design1,
- dataInput = dataInput1,
- directionUpper = TRUE,
- stage = 3,
- allocationRatioPlanned = 1,
- intersectionTest = "SpiessensDebois"
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
- expect_equal(x1$thetaH1[1, ], 1.6657832, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.082268614, 0.17873234, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.10062355, 0.20651301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(0.77807561, 0.90042934, 0.98057987), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(0.89663851, 0.98596182, NA_real_), tolerance = 1e-06, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(3.8287578, 3.0779077, 2.841847), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(2.9564444, 2.541245, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[1, ], c(0.09262834, 0.035310721, 0.016798032), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[2, ], c(0.074049848, 0.03027247, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], 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$thetaH1, x1$thetaH1, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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 <- getAnalysisResults(
- design = design1,
- dataInput = dataInput1,
- directionUpper = TRUE,
- stage = 3,
- allocationRatioPlanned = 1,
- intersectionTest = "Sidak"
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
- expect_equal(x2$thetaH1[1, ], 1.6657832, tolerance = 1e-07, label = paste0("c(", paste0(x2$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x2$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x2$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.082268614, 0.14135111, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.08442718, 0.14135111, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(0.76355966, 0.87078132, 0.95099133), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(0.88408373, 0.96064864, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(3.9015478, 3.1815164, 2.9283489), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(2.9984281, 2.606883, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[1, ], c(0.09262834, 0.044241863, 0.02067471), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[2, ], c(0.090100155, 0.044241863, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], 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$thetaH1, x2$thetaH1, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
- }
-
- design2 <- getDesignFisher(kMax = 3, method = "equalAlpha", alpha = 0.025, informationRates = c(0.4, 0.7, 1))
-
- x3 <- getAnalysisResults(
- design = design2,
- dataInput = dataInput1,
- stratifiedAnalysis = TRUE,
- directionUpper = TRUE,
- stage = 2,
- nPlanned = 30,
- allocationRatioPlanned = 1,
- intersectionTest = "SpiessensDebois"
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x3' with expected results
- expect_equal(x3$thetaH1[1, ], 1.6607445, tolerance = 1e-07, label = paste0("c(", paste0(x3$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x3$thetaH1[2, ], 1.5814324, tolerance = 1e-07, label = paste0("c(", paste0(x3$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.058300881, 0.080849353, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.073230444, 0.10089716, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, 0.49594042), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, 0.49151717), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(0.77887293, 0.87495539, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(0.89732572, 0.9655589, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(3.8248388, 3.1694642, NA_real_), tolerance = 1e-06, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(2.9541783, 2.6004037, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[1, ], c(0.086600177, 0.047636937, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x3$repeatedPValues[2, ], c(0.070085432, 0.040357555, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[2, ], 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$thetaH1, x3$thetaH1, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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)
- }
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentSurvival}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedTestEnrichmentSurvival}
+ # @refFS[Formula]{fs:testStatisticEnrichmentSurvival}
+ S1 <- getDataset(
+ events = c(37, 35, 22),
+ logRanks = c(1.66, 1.38, 1.22),
+ allocationRatios = c(1, 1, 1)
+ )
+
+ F <- getDataset(
+ events = c(66, 55, NA),
+ logRanks = c(1.98, 1.57, NA),
+ allocationRatios = c(1, 1, NA)
+ )
+
+ dataInput1 <- getDataset(S1 = S1, F = F)
+
+ ## Comparison of the results of DatasetSurvival object 'dataInput1' with expected results
+ expect_equal(dataInput1$events, c(37, 66, 35, 55, 22, NA_real_), label = paste0("c(", paste0(dataInput1$events, collapse = ", "), ")"))
+ expect_equal(dataInput1$allocationRatios, c(1, 1, 1, 1, 1, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$allocationRatios, collapse = ", "), ")"))
+ expect_equal(dataInput1$logRanks, c(1.66, 1.98, 1.38, 1.57, 1.22, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput1$logRanks, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput1), NA)))
+ expect_output(print(dataInput1)$show())
+ invisible(capture.output(expect_error(summary(dataInput1), NA)))
+ expect_output(summary(dataInput1)$show())
+ dataInput1CodeBased <- eval(parse(text = getObjectRCode(dataInput1, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput1CodeBased$events, dataInput1$events, tolerance = 1e-07)
+ expect_equal(dataInput1CodeBased$allocationRatios, dataInput1$allocationRatios, tolerance = 1e-07)
+ expect_equal(dataInput1CodeBased$logRanks, dataInput1$logRanks, tolerance = 1e-07)
+ expect_type(names(dataInput1), "character")
+ df <- as.data.frame(dataInput1)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput1)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, typeOfDesign = "asP", typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.025,
+ informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
+ )
+
+ x1 <- getAnalysisResults(
+ design = design1,
+ dataInput = dataInput1,
+ directionUpper = TRUE,
+ stage = 3,
+ allocationRatioPlanned = 1,
+ intersectionTest = "SpiessensDebois"
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
+ expect_equal(x1$thetaH1[1, ], 1.6657832, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[1, ], collapse = ", "), ")"))
+ expect_equal(x1$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[2, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.082268614, 0.17873234, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.10062355, 0.20651301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(0.77807561, 0.90042934, 0.98057987), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(0.89663851, 0.98596182, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(3.8287578, 3.0779077, 2.841847), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(2.9564444, 2.541245, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedPValues[1, ], c(0.09262834, 0.035310721, 0.016798032), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedPValues[2, ], c(0.074049848, 0.03027247, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], 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$thetaH1, x1$thetaH1, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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 <- getAnalysisResults(
+ design = design1,
+ dataInput = dataInput1,
+ directionUpper = TRUE,
+ stage = 3,
+ allocationRatioPlanned = 1,
+ intersectionTest = "Sidak"
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
+ expect_equal(x2$thetaH1[1, ], 1.6657832, tolerance = 1e-07, label = paste0("c(", paste0(x2$thetaH1[1, ], collapse = ", "), ")"))
+ expect_equal(x2$thetaH1[2, ], NA_real_, label = paste0("c(", paste0(x2$thetaH1[2, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.082268614, 0.14135111, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.08442718, 0.14135111, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(0.76355966, 0.87078132, 0.95099133), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(0.88408373, 0.96064864, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(3.9015478, 3.1815164, 2.9283489), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(2.9984281, 2.606883, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedPValues[1, ], c(0.09262834, 0.044241863, 0.02067471), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedPValues[2, ], c(0.090100155, 0.044241863, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], 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$thetaH1, x2$thetaH1, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
+ }
+
+ design2 <- getDesignFisher(kMax = 3, method = "equalAlpha", alpha = 0.025, informationRates = c(0.4, 0.7, 1))
+
+ x3 <- getAnalysisResults(
+ design = design2,
+ dataInput = dataInput1,
+ stratifiedAnalysis = TRUE,
+ directionUpper = TRUE,
+ stage = 2,
+ nPlanned = 30,
+ allocationRatioPlanned = 1,
+ intersectionTest = "SpiessensDebois"
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentFisher object 'x3' with expected results
+ expect_equal(x3$thetaH1[1, ], 1.6607445, tolerance = 1e-07, label = paste0("c(", paste0(x3$thetaH1[1, ], collapse = ", "), ")"))
+ expect_equal(x3$thetaH1[2, ], 1.5814324, tolerance = 1e-07, label = paste0("c(", paste0(x3$thetaH1[2, ], collapse = ", "), ")"))
+ expect_equal(x3$conditionalRejectionProbabilities[1, ], c(0.058300881, 0.080849353, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(x3$conditionalRejectionProbabilities[2, ], c(0.073230444, 0.10089716, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
+ expect_equal(x3$conditionalPower[1, ], c(NA_real_, NA_real_, 0.49594042), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPower[1, ], collapse = ", "), ")"))
+ expect_equal(x3$conditionalPower[2, ], c(NA_real_, NA_real_, 0.49151717), tolerance = 1e-07, label = paste0("c(", paste0(x3$conditionalPower[2, ], collapse = ", "), ")"))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[1, ], c(0.77887293, 0.87495539, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x3$repeatedConfidenceIntervalLowerBounds[2, ], c(0.89732572, 0.9655589, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[1, ], c(3.8248388, 3.1694642, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x3$repeatedConfidenceIntervalUpperBounds[2, ], c(2.9541783, 2.6004037, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x3$repeatedPValues[1, ], c(0.086600177, 0.047636937, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[1, ], collapse = ", "), ")"))
+ expect_equal(x3$repeatedPValues[2, ], c(0.070085432, 0.040357555, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x3$repeatedPValues[2, ], 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$thetaH1, x3$thetaH1, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalRejectionProbabilities, x3$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x3CodeBased$conditionalPower, x3$conditionalPower, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalLowerBounds, x3$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedConfidenceIntervalUpperBounds, x3$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x3CodeBased$repeatedPValues, x3$repeatedPValues, 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)
+ }
+
})
test_that("'getAnalysisResults': enrichment survival, one sub-population, stratified data input, select S1 at first, gMax = 2", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentSurvival}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedTestEnrichmentSurvival}
- # @refFS[Formula]{fs:testStatisticEnrichmentSurvival}
- S1 <- getDataset(
- overallExpectedEvents = c(13.4, 35.4, 43.7),
- overallEvents = c(16, 38, 47),
- overallVarianceEvents = c(2.8, 4.7, 3.4),
- overallAllocationRatios = c(1, 1, 1)
- )
-
- R <- getDataset(
- overallExpectedEvents = c(23.3, NA, NA),
- overallEvents = c(27, NA, NA),
- overallVarianceEvents = c(3.9, NA, NA),
- overallAllocationRatios = c(1, NA, NA)
- )
-
- dataInput2 <- getDataset(S1 = S1, R = R)
-
- ## Comparison of the results of DatasetEnrichmentSurvival object 'dataInput2' with expected results
- expect_equal(dataInput2$events, c(16, 27, 22, NA_real_, 9, NA_real_), label = paste0("c(", paste0(dataInput2$events, collapse = ", "), ")"))
- expect_equal(dataInput2$allocationRatios, c(1, 1, 1, NA_real_, 1, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$allocationRatios, collapse = ", "), ")"))
- expect_equal(dataInput2$expectedEvents, c(13.4, 23.3, 22, NA_real_, 8.3, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$expectedEvents, collapse = ", "), ")"))
- expect_equal(dataInput2$varianceEvents, c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput2$varianceEvents, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput2), NA)))
- expect_output(print(dataInput2)$show())
- invisible(capture.output(expect_error(summary(dataInput2), NA)))
- expect_output(summary(dataInput2)$show())
- dataInput2CodeBased <- eval(parse(text = getObjectRCode(dataInput2, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput2CodeBased$events, dataInput2$events, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$allocationRatios, dataInput2$allocationRatios, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$expectedEvents, dataInput2$expectedEvents, tolerance = 1e-07)
- expect_equal(dataInput2CodeBased$varianceEvents, dataInput2$varianceEvents, tolerance = 1e-07)
- expect_type(names(dataInput2), "character")
- df <- as.data.frame(dataInput2)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput2)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, typeOfDesign = "asP",
- typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.025,
- informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
- )
-
- x4 <- getAnalysisResults(
- design = design1,
- dataInput = dataInput2,
- stratifiedAnalysis = TRUE,
- directionUpper = TRUE,
- stage = 2,
- nPlanned = 30,
- thetaH1 = 2.5,
- allocationRatioPlanned = 1,
- intersectionTest = "SpiessensDebois"
- )
-
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x4' with expected results
- expect_equal(x4$conditionalRejectionProbabilities[1, ], c(0.066531397, 0.014937437, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalRejectionProbabilities[2, ], c(0.21112053, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[1, ], c(NA_real_, NA_real_, 0.63217527), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x4$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[1, ], c(0.63930031, 0.68758378, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalLowerBounds[2, ], c(0.99553933, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[1, ], c(7.3977709, 3.5674239, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedConfidenceIntervalUpperBounds[2, ], c(4.4332679, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[1, ], c(0.11491566, 0.11491566, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x4$repeatedPValues[2, ], c(0.026005739, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[2, ], 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$conditionalRejectionProbabilities, x4$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x4CodeBased$conditionalPower, x4$conditionalPower, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedConfidenceIntervalLowerBounds, x4$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedConfidenceIntervalUpperBounds, x4$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x4CodeBased$repeatedPValues, x4$repeatedPValues, 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)
- }
+
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentSurvival}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedTestEnrichmentSurvival}
+ # @refFS[Formula]{fs:testStatisticEnrichmentSurvival}
+ S1 <- getDataset(
+ overallExpectedEvents = c(13.4, 35.4, 43.7),
+ overallEvents = c(16, 38, 47),
+ overallVarianceEvents = c(2.8, 4.7, 3.4),
+ overallAllocationRatios = c(1, 1, 1)
+ )
+
+ R <- getDataset(
+ overallExpectedEvents = c(23.3, NA, NA),
+ overallEvents = c(27, NA, NA),
+ overallVarianceEvents = c(3.9, NA, NA),
+ overallAllocationRatios = c(1, NA, NA)
+ )
+
+ dataInput2 <- getDataset(S1 = S1, R = R)
+
+ ## Comparison of the results of DatasetEnrichmentSurvival object 'dataInput2' with expected results
+ expect_equal(dataInput2$events, c(16, 27, 22, NA_real_, 9, NA_real_), label = paste0("c(", paste0(dataInput2$events, collapse = ", "), ")"))
+ expect_equal(dataInput2$allocationRatios, c(1, 1, 1, NA_real_, 1, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$allocationRatios, collapse = ", "), ")"))
+ expect_equal(dataInput2$expectedEvents, c(13.4, 23.3, 22, NA_real_, 8.3, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput2$expectedEvents, collapse = ", "), ")"))
+ expect_equal(dataInput2$varianceEvents, c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput2$varianceEvents, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput2), NA)))
+ expect_output(print(dataInput2)$show())
+ invisible(capture.output(expect_error(summary(dataInput2), NA)))
+ expect_output(summary(dataInput2)$show())
+ dataInput2CodeBased <- eval(parse(text = getObjectRCode(dataInput2, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput2CodeBased$events, dataInput2$events, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$allocationRatios, dataInput2$allocationRatios, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$expectedEvents, dataInput2$expectedEvents, tolerance = 1e-07)
+ expect_equal(dataInput2CodeBased$varianceEvents, dataInput2$varianceEvents, tolerance = 1e-07)
+ expect_type(names(dataInput2), "character")
+ df <- as.data.frame(dataInput2)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput2)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, typeOfDesign = "asP",
+ typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.025,
+ informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
+ )
+
+ x4 <- getAnalysisResults(
+ design = design1,
+ dataInput = dataInput2,
+ stratifiedAnalysis = TRUE,
+ directionUpper = TRUE,
+ stage = 2,
+ nPlanned = 30,
+ thetaH1 = 2.5,
+ allocationRatioPlanned = 1,
+ intersectionTest = "SpiessensDebois"
+ )
+
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x4' with expected results
+ expect_equal(x4$conditionalRejectionProbabilities[1, ], c(0.066531397, 0.014937437, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(x4$conditionalRejectionProbabilities[2, ], c(0.21112053, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
+ expect_equal(x4$conditionalPower[1, ], c(NA_real_, NA_real_, 0.63217527), tolerance = 1e-07, label = paste0("c(", paste0(x4$conditionalPower[1, ], collapse = ", "), ")"))
+ expect_equal(x4$conditionalPower[2, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x4$conditionalPower[2, ], collapse = ", "), ")"))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[1, ], c(0.63930031, 0.68758378, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x4$repeatedConfidenceIntervalLowerBounds[2, ], c(0.99553933, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[1, ], c(7.3977709, 3.5674239, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x4$repeatedConfidenceIntervalUpperBounds[2, ], c(4.4332679, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x4$repeatedPValues[1, ], c(0.11491566, 0.11491566, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[1, ], collapse = ", "), ")"))
+ expect_equal(x4$repeatedPValues[2, ], c(0.026005739, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x4$repeatedPValues[2, ], 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$conditionalRejectionProbabilities, x4$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x4CodeBased$conditionalPower, x4$conditionalPower, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedConfidenceIntervalLowerBounds, x4$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedConfidenceIntervalUpperBounds, x4$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x4CodeBased$repeatedPValues, x4$repeatedPValues, 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)
+ }
})
test_that("'getAnalysisResults': enrichment survival, two sub-populations, non-stratified analysis, select S1 and S2 at first IA, select S1 at second, gMax = 3", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentRates}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedTestEnrichmentRates}
- # @refFS[Formula]{fs:testStatisticEnrichmentRates}
- design1 <- getDesignInverseNormal(
- kMax = 3, typeOfDesign = "asP", typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.02,
- informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
- )
-
- F <- getDataset(
- events = c(66, NA, NA),
- logRanks = -c(2.18, NA, NA)
- )
-
- S1 <- getDataset(
- events = c(37, 13, 26),
- logRanks = -c(1.66, 1.239, 0.785)
- )
-
- S2 <- getDataset(
- events = c(31, 18, NA),
- logRanks = -c(1.98, 1.064, NA)
- )
-
- dataInput3 <- getDataset(S1 = S1, S2 = S2, F = F)
-
- ## Comparison of the results of DatasetSurvival object 'dataInput3' with expected results
- expect_equal(dataInput3$events, c(37, 31, 66, 13, 18, NA_real_, 26, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput3$events, collapse = ", "), ")"))
- expect_equal(dataInput3$allocationRatios, c(1, 1, 1, 1, 1, NA_real_, 1, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$allocationRatios, collapse = ", "), ")"))
- expect_equal(dataInput3$logRanks, c(-1.66, -1.98, -2.18, -1.239, -1.064, NA_real_, -0.785, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$logRanks, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput3), NA)))
- expect_output(print(dataInput3)$show())
- invisible(capture.output(expect_error(summary(dataInput3), NA)))
- expect_output(summary(dataInput3)$show())
- dataInput3CodeBased <- eval(parse(text = getObjectRCode(dataInput3, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput3CodeBased$events, dataInput3$events, tolerance = 1e-07)
- expect_equal(dataInput3CodeBased$allocationRatios, dataInput3$allocationRatios, tolerance = 1e-07)
- expect_equal(dataInput3CodeBased$logRanks, dataInput3$logRanks, tolerance = 1e-07)
- expect_type(names(dataInput3), "character")
- df <- as.data.frame(dataInput3)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput3)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- x1 <- getAnalysisResults(
- design = design1,
- dataInput = dataInput3,
- directionUpper = FALSE,
- stage = 2,
- nPlanned = 30,
- allocationRatioPlanned = 1,
- intersectionTest = "Sidak"
- )
-
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
- expect_equal(x1$thetaH1[1, ], 0.55845203, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[1, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[2, ], 0.53035001, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[2, ], collapse = ", "), ")"))
- expect_equal(x1$thetaH1[3, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[3, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.063444981, 0.051842822, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.065210901, 0.051842822, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalRejectionProbabilities[3, ], c(0.070888966, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, 0.48733039), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, 0.54365075), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x1$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(0.23870487, 0.2370187, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(0.1863782, 0.22932092, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalLowerBounds[3, ], c(0.30101352, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(1.406238, 1.2861572, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(1.2936975, 1.2386982, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedConfidenceIntervalUpperBounds[3, ], c(1.1356925, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[1, ], c(0.09262834, 0.074349301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[2, ], c(0.090100155, 0.074349301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x1$repeatedPValues[3, ], c(0.082670093, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[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$thetaH1, x1$thetaH1, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentRates}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedTestEnrichmentRates}
+ # @refFS[Formula]{fs:testStatisticEnrichmentRates}
+ design1 <- getDesignInverseNormal(
+ kMax = 3, typeOfDesign = "asP", typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.02,
+ informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
+ )
+
+ F <- getDataset(
+ events = c(66, NA, NA),
+ logRanks = -c(2.18, NA, NA)
+ )
+
+ S1 <- getDataset(
+ events = c(37, 13, 26),
+ logRanks = -c(1.66, 1.239, 0.785)
+ )
+
+ S2 <- getDataset(
+ events = c(31, 18, NA),
+ logRanks = -c(1.98, 1.064, NA)
+ )
+
+ dataInput3 <- getDataset(S1 = S1, S2 = S2, F = F)
+
+ ## Comparison of the results of DatasetSurvival object 'dataInput3' with expected results
+ expect_equal(dataInput3$events, c(37, 31, 66, 13, 18, NA_real_, 26, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput3$events, collapse = ", "), ")"))
+ expect_equal(dataInput3$allocationRatios, c(1, 1, 1, 1, 1, NA_real_, 1, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$allocationRatios, collapse = ", "), ")"))
+ expect_equal(dataInput3$logRanks, c(-1.66, -1.98, -2.18, -1.239, -1.064, NA_real_, -0.785, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput3$logRanks, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput3), NA)))
+ expect_output(print(dataInput3)$show())
+ invisible(capture.output(expect_error(summary(dataInput3), NA)))
+ expect_output(summary(dataInput3)$show())
+ dataInput3CodeBased <- eval(parse(text = getObjectRCode(dataInput3, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput3CodeBased$events, dataInput3$events, tolerance = 1e-07)
+ expect_equal(dataInput3CodeBased$allocationRatios, dataInput3$allocationRatios, tolerance = 1e-07)
+ expect_equal(dataInput3CodeBased$logRanks, dataInput3$logRanks, tolerance = 1e-07)
+ expect_type(names(dataInput3), "character")
+ df <- as.data.frame(dataInput3)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput3)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ x1 <- getAnalysisResults(
+ design = design1,
+ dataInput = dataInput3,
+ directionUpper = FALSE,
+ stage = 2,
+ nPlanned = 30,
+ allocationRatioPlanned = 1,
+ intersectionTest = "Sidak"
+ )
+
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x1' with expected results
+ expect_equal(x1$thetaH1[1, ], 0.55845203, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[1, ], collapse = ", "), ")"))
+ expect_equal(x1$thetaH1[2, ], 0.53035001, tolerance = 1e-07, label = paste0("c(", paste0(x1$thetaH1[2, ], collapse = ", "), ")"))
+ expect_equal(x1$thetaH1[3, ], NA_real_, label = paste0("c(", paste0(x1$thetaH1[3, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalRejectionProbabilities[1, ], c(0.063444981, 0.051842822, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalRejectionProbabilities[2, ], c(0.065210901, 0.051842822, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalRejectionProbabilities[3, ], c(0.070888966, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalPower[1, ], c(NA_real_, NA_real_, 0.48733039), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPower[1, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalPower[2, ], c(NA_real_, NA_real_, 0.54365075), tolerance = 1e-07, label = paste0("c(", paste0(x1$conditionalPower[2, ], collapse = ", "), ")"))
+ expect_equal(x1$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x1$conditionalPower[3, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[1, ], c(0.23870487, 0.2370187, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[2, ], c(0.1863782, 0.22932092, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalLowerBounds[3, ], c(0.30101352, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[1, ], c(1.406238, 1.2861572, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[2, ], c(1.2936975, 1.2386982, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedConfidenceIntervalUpperBounds[3, ], c(1.1356925, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedPValues[1, ], c(0.09262834, 0.074349301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[1, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedPValues[2, ], c(0.090100155, 0.074349301, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[2, ], collapse = ", "), ")"))
+ expect_equal(x1$repeatedPValues[3, ], c(0.082670093, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x1$repeatedPValues[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$thetaH1, x1$thetaH1, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalRejectionProbabilities, x1$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x1CodeBased$conditionalPower, x1$conditionalPower, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalLowerBounds, x1$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedConfidenceIntervalUpperBounds, x1$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x1CodeBased$repeatedPValues, x1$repeatedPValues, 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)
+ }
})
test_that("'getAnalysisResults': enrichment survival, two sub-populations, stratified analysis, select S1 and S2 at first IA, select S1 at second, gMax = 3", {
- .skipTestIfDisabled()
-
- # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
- # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentRates}
- # @refFS[Formula]{fs:computeRCIsEnrichment}
- # @refFS[Formula]{fs:conditionalPowerEnrichment}
- # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
- # @refFS[Formula]{fs:stratifiedTestEnrichmentRates}
- # @refFS[Formula]{fs:testStatisticEnrichmentRates}
- S1 <- getDataset(
- overallExpectedEvents = c(13.4, 35.4, 43.7),
- overallEvents = c(16, 37, 47),
- overallVarianceEvents = c(2.8, 4.7, 3.4),
- overallAllocationRatios = c(1, 1, 1)
- )
-
- S2 <- getDataset(
- overallExpectedEvents = c(11.5, 31.1, NA),
- overallEvents = c(15, 33, NA),
- overallVarianceEvents = c(2.2, 4.4, NA),
- overallAllocationRatios = c(1, 1, NA)
- )
-
- S12 <- getDataset(
- overallExpectedEvents = c(10.1, 29.6, 39.1),
- overallEvents = c(11, 31, 42),
- overallVarianceEvents = c(2.8, 4.7, 3.4),
- overallAllocationRatios = c(1, 1, 1)
- )
-
- R <- getDataset(
- overallExpectedEvents = c(23.3, NA, NA),
- overallEvents = c(25, NA, NA),
- overallVarianceEvents = c(3.9, NA, NA),
- overallAllocationRatios = c(1, NA, NA)
- )
-
- dataInput4 <- getDataset(S1 = S1, S2 = S2, S12 = S12, R = R)
-
- ## Comparison of the results of DatasetEnrichmentSurvival object 'dataInput4' with expected results
- expect_equal(dataInput4$events, c(16, 15, 11, 25, 21, 18, 20, NA_real_, 10, NA_real_, 11, NA_real_), label = paste0("c(", paste0(dataInput4$events, collapse = ", "), ")"))
- expect_equal(dataInput4$allocationRatios, c(1, 1, 1, 1, 1, 1, 1, NA_real_, 1, NA_real_, 1, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput4$allocationRatios, collapse = ", "), ")"))
- expect_equal(dataInput4$expectedEvents, c(13.4, 11.5, 10.1, 23.3, 22, 19.6, 19.5, NA_real_, 8.3, NA_real_, 9.5, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput4$expectedEvents, collapse = ", "), ")"))
- expect_equal(dataInput4$varianceEvents, c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput4$varianceEvents, collapse = ", "), ")"))
- if (isTRUE(.isCompleteUnitTestSetEnabled())) {
- invisible(capture.output(expect_error(print(dataInput4), NA)))
- expect_output(print(dataInput4)$show())
- invisible(capture.output(expect_error(summary(dataInput4), NA)))
- expect_output(summary(dataInput4)$show())
- dataInput4CodeBased <- eval(parse(text = getObjectRCode(dataInput4, stringWrapParagraphWidth = NULL)))
- expect_equal(dataInput4CodeBased$events, dataInput4$events, tolerance = 1e-07)
- expect_equal(dataInput4CodeBased$allocationRatios, dataInput4$allocationRatios, tolerance = 1e-07)
- expect_equal(dataInput4CodeBased$expectedEvents, dataInput4$expectedEvents, tolerance = 1e-07)
- expect_equal(dataInput4CodeBased$varianceEvents, dataInput4$varianceEvents, tolerance = 1e-07)
- expect_type(names(dataInput4), "character")
- df <- as.data.frame(dataInput4)
- expect_s3_class(df, "data.frame")
- expect_true(nrow(df) > 0 && ncol(df) > 0)
- mtx <- as.matrix(dataInput4)
- expect_true(is.matrix(mtx))
- expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
- }
-
- design1 <- getDesignInverseNormal(
- kMax = 3, typeOfDesign = "asP", typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.02,
- informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
- )
-
- x2 <- getAnalysisResults(
- design = design1,
- dataInput = dataInput4,
- stratifiedAnalysis = TRUE,
- directionUpper = TRUE,
- stage = 2,
- nPlanned = 30,
- thetaH1 = 2,
- allocationRatioPlanned = 1,
- intersectionTest = "Sidak"
- )
-
- ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
- expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.043010929, 0.0010677592, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.063395248, 0.0010677592, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalRejectionProbabilities[3, ], c(0.15397803, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, 0.12050895), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, 0.12050895), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
- expect_equal(x2$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(0.62578554, 0.64439022, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(0.75127376, 0.66639106, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalLowerBounds[3, ], c(0.96321381, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(4.9893102, 2.8192192, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(6.2314391, 3.0969281, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedConfidenceIntervalUpperBounds[3, ], c(3.5981376, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[1, ], c(0.13298203, 0.13298203, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[2, ], c(0.092701773, 0.092701773, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], collapse = ", "), ")"))
- expect_equal(x2$repeatedPValues[3, ], c(0.031299575, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[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$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
- expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
- expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
- }
+
+ .skipTestIfDisabled()
+
+ # @refFS[Formula]{fs:adjustedPValueBonferroniEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCIBonferroniSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueForRCISpiessensEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSidakEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSimesEnrichment}
+ # @refFS[Formula]{fs:adjustedPValueSpiessensDeboisEnrichmentRates}
+ # @refFS[Formula]{fs:computeRCIsEnrichment}
+ # @refFS[Formula]{fs:conditionalPowerEnrichment}
+ # @refFS[Formula]{fs:conditionalRejectionProbabilityEnrichment}
+ # @refFS[Formula]{fs:stratifiedTestEnrichmentRates}
+ # @refFS[Formula]{fs:testStatisticEnrichmentRates}
+ S1 <- getDataset(
+ overallExpectedEvents = c(13.4, 35.4, 43.7),
+ overallEvents = c(16, 37, 47),
+ overallVarianceEvents = c(2.8, 4.7, 3.4),
+ overallAllocationRatios = c(1, 1, 1)
+ )
+
+ S2 <- getDataset(
+ overallExpectedEvents = c(11.5, 31.1, NA),
+ overallEvents = c(15, 33, NA),
+ overallVarianceEvents = c(2.2, 4.4, NA),
+ overallAllocationRatios = c(1, 1, NA)
+ )
+
+ S12 <- getDataset(
+ overallExpectedEvents = c(10.1, 29.6, 39.1),
+ overallEvents = c(11, 31, 42),
+ overallVarianceEvents = c(2.8, 4.7, 3.4),
+ overallAllocationRatios = c(1, 1, 1)
+ )
+
+ R <- getDataset(
+ overallExpectedEvents = c(23.3, NA, NA),
+ overallEvents = c(25, NA, NA),
+ overallVarianceEvents = c(3.9, NA, NA),
+ overallAllocationRatios = c(1, NA, NA)
+ )
+
+ dataInput4 <- getDataset(S1 = S1, S2 = S2, S12 = S12, R = R)
+
+ ## Comparison of the results of DatasetEnrichmentSurvival object 'dataInput4' with expected results
+ expect_equal(dataInput4$events, c(16, 15, 11, 25, 21, 18, 20, NA_real_, 10, NA_real_, 11, NA_real_), label = paste0("c(", paste0(dataInput4$events, collapse = ", "), ")"))
+ expect_equal(dataInput4$allocationRatios, c(1, 1, 1, 1, 1, 1, 1, NA_real_, 1, NA_real_, 1, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput4$allocationRatios, collapse = ", "), ")"))
+ expect_equal(dataInput4$expectedEvents, c(13.4, 11.5, 10.1, 23.3, 22, 19.6, 19.5, NA_real_, 8.3, NA_real_, 9.5, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(dataInput4$expectedEvents, collapse = ", "), ")"))
+ expect_equal(dataInput4$varianceEvents, c(NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(dataInput4$varianceEvents, collapse = ", "), ")"))
+ if (isTRUE(.isCompleteUnitTestSetEnabled())) {
+ invisible(capture.output(expect_error(print(dataInput4), NA)))
+ expect_output(print(dataInput4)$show())
+ invisible(capture.output(expect_error(summary(dataInput4), NA)))
+ expect_output(summary(dataInput4)$show())
+ dataInput4CodeBased <- eval(parse(text = getObjectRCode(dataInput4, stringWrapParagraphWidth = NULL)))
+ expect_equal(dataInput4CodeBased$events, dataInput4$events, tolerance = 1e-07)
+ expect_equal(dataInput4CodeBased$allocationRatios, dataInput4$allocationRatios, tolerance = 1e-07)
+ expect_equal(dataInput4CodeBased$expectedEvents, dataInput4$expectedEvents, tolerance = 1e-07)
+ expect_equal(dataInput4CodeBased$varianceEvents, dataInput4$varianceEvents, tolerance = 1e-07)
+ expect_type(names(dataInput4), "character")
+ df <- as.data.frame(dataInput4)
+ expect_s3_class(df, "data.frame")
+ expect_true(nrow(df) > 0 && ncol(df) > 0)
+ mtx <- as.matrix(dataInput4)
+ expect_true(is.matrix(mtx))
+ expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
+ }
+
+ design1 <- getDesignInverseNormal(
+ kMax = 3, typeOfDesign = "asP", typeBetaSpending = "bsKD", gammaB = 1.3, alpha = 0.02,
+ informationRates = c(0.4, 0.7, 1), bindingFutility = FALSE, beta = 0.1
+ )
+
+ x2 <- getAnalysisResults(
+ design = design1,
+ dataInput = dataInput4,
+ stratifiedAnalysis = TRUE,
+ directionUpper = TRUE,
+ stage = 2,
+ nPlanned = 30,
+ thetaH1 = 2,
+ allocationRatioPlanned = 1,
+ intersectionTest = "Sidak"
+ )
+
+ ## Comparison of the results of AnalysisResultsEnrichmentInverseNormal object 'x2' with expected results
+ expect_equal(x2$conditionalRejectionProbabilities[1, ], c(0.043010929, 0.0010677592, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalRejectionProbabilities[2, ], c(0.063395248, 0.0010677592, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalRejectionProbabilities[3, ], c(0.15397803, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalPower[1, ], c(NA_real_, NA_real_, 0.12050895), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPower[1, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalPower[2, ], c(NA_real_, NA_real_, 0.12050895), tolerance = 1e-07, label = paste0("c(", paste0(x2$conditionalPower[2, ], collapse = ", "), ")"))
+ expect_equal(x2$conditionalPower[3, ], c(NA_real_, NA_real_, NA_real_), label = paste0("c(", paste0(x2$conditionalPower[3, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[1, ], c(0.62578554, 0.64439022, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[2, ], c(0.75127376, 0.66639106, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalLowerBounds[3, ], c(0.96321381, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalLowerBounds[3, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[1, ], c(4.9893102, 2.8192192, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[1, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[2, ], c(6.2314391, 3.0969281, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[2, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedConfidenceIntervalUpperBounds[3, ], c(3.5981376, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedConfidenceIntervalUpperBounds[3, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedPValues[1, ], c(0.13298203, 0.13298203, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[1, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedPValues[2, ], c(0.092701773, 0.092701773, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[2, ], collapse = ", "), ")"))
+ expect_equal(x2$repeatedPValues[3, ], c(0.031299575, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(x2$repeatedPValues[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$conditionalRejectionProbabilities, x2$conditionalRejectionProbabilities, tolerance = 1e-07)
+ expect_equal(x2CodeBased$conditionalPower, x2$conditionalPower, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalLowerBounds, x2$repeatedConfidenceIntervalLowerBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedConfidenceIntervalUpperBounds, x2$repeatedConfidenceIntervalUpperBounds, tolerance = 1e-07)
+ expect_equal(x2CodeBased$repeatedPValues, x2$repeatedPValues, 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)
+ }
})
+
diff --git a/tests/testthat/test-f_analysis_input_validation.R b/tests/testthat/test-f_analysis_input_validation.R
index 4d4f30cd..6bbb507f 100644
--- a/tests/testthat/test-f_analysis_input_validation.R
+++ b/tests/testthat/test-f_analysis_input_validation.R
@@ -15,8 +15,8 @@
## |
## | File name: test-f_analysis_input_validation.R
## | Creation date: 08 November 2023, 08:56:03
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7928 $
+## | Last changed: $Date: 2024-05-23 16:35:16 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -79,7 +79,7 @@ test_that("Errors and warnings for calculation of analysis results with dataset
design = design1, dataInput = dataExample4,
intersectionTest = "Simes", varianceOption = "notPooled", nPlanned = 20
))
- expect_warning(getAnalysisResults(
+ expect_warning(getAnalysisResults(
design = design1, dataInput = dataExample4,
intersectionTest = "Simes", varianceOption = "notPooled", nPlanned = c()
))
diff --git a/tests/testthat/test-f_analysis_multiarm_means.R b/tests/testthat/test-f_analysis_multiarm_means.R
index 38557ee7..682a9c84 100644
--- a/tests/testthat/test-f_analysis_multiarm_means.R
+++ b/tests/testthat/test-f_analysis_multiarm_means.R
@@ -15,8 +15,8 @@
## |
## | File name: test-f_analysis_multiarm_means.R
## | Creation date: 08 November 2023, 08:56:03
-## | File version: $Revision: 7682 $
-## | Last changed: $Date: 2024-03-05 07:53:40 +0100 (Di, 05 Mrz 2024) $
+## | File version: $Revision: 7928 $
+## | Last changed: $Date: 2024-05-23 16:35:16 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -2821,7 +2821,7 @@ test_that("'getAnalysisResultsMultiArm' with dataset of means", {
expect_equal(results41$assumedStDevs[1, ], 22.357668, tolerance = 1e-06, label = paste0("c(", paste0(results41$assumedStDevs[1, ], collapse = ", "), ")"))
expect_equal(results41$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(results41$assumedStDevs[2, ], collapse = ", "), ")"))
expect_equal(results41$assumedStDevs[3, ], 22.943518, tolerance = 1e-06, label = paste0("c(", paste0(results41$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(results41$conditionalRejectionProbabilities[1, ], c(NA_real_, 0.061352937), tolerance = 1e-05, label = paste0("c(", paste0(results41$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(results41$conditionalRejectionProbabilities[1, ], c(NA_real_, 0.061352937), tolerance = 1e-06, label = paste0("c(", paste0(results41$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
expect_equal(results41$conditionalRejectionProbabilities[2, ], c(NA_real_, 0.03744742), tolerance = 1e-06, label = paste0("c(", paste0(results41$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
expect_equal(results41$conditionalRejectionProbabilities[3, ], c(NA_real_, 0.086511764), tolerance = 1e-06, label = paste0("c(", paste0(results41$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
expect_equal(results41$conditionalPower[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(results41$conditionalPower[1, ], collapse = ", "), ")"))
@@ -5609,7 +5609,7 @@ test_that("'getAnalysisResultsMultiArm' with dataset of means", {
expect_equal(results82$assumedStDevs[1, ], 22.357668, tolerance = 1e-06, label = paste0("c(", paste0(results82$assumedStDevs[1, ], collapse = ", "), ")"))
expect_equal(results82$assumedStDevs[2, ], NA_real_, label = paste0("c(", paste0(results82$assumedStDevs[2, ], collapse = ", "), ")"))
expect_equal(results82$assumedStDevs[3, ], 22.943518, tolerance = 1e-06, label = paste0("c(", paste0(results82$assumedStDevs[3, ], collapse = ", "), ")"))
- expect_equal(results82$conditionalRejectionProbabilities[1, ], c(NA_real_, 0.061352937), tolerance = 1e-05, label = paste0("c(", paste0(results82$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
+ expect_equal(results82$conditionalRejectionProbabilities[1, ], c(NA_real_, 0.061352937), tolerance = 1e-06, label = paste0("c(", paste0(results82$conditionalRejectionProbabilities[1, ], collapse = ", "), ")"))
expect_equal(results82$conditionalRejectionProbabilities[2, ], c(NA_real_, 0.03744742), tolerance = 1e-06, label = paste0("c(", paste0(results82$conditionalRejectionProbabilities[2, ], collapse = ", "), ")"))
expect_equal(results82$conditionalRejectionProbabilities[3, ], c(NA_real_, 0.086511764), tolerance = 1e-06, label = paste0("c(", paste0(results82$conditionalRejectionProbabilities[3, ], collapse = ", "), ")"))
expect_equal(results82$conditionalPower[1, ], c(NA_real_, NA_real_), label = paste0("c(", paste0(results82$conditionalPower[1, ], collapse = ", "), ")"))
diff --git a/tests/testthat/test-f_analysis_multiarm_rates.R b/tests/testthat/test-f_analysis_multiarm_rates.R
index fad075e2..2055526b 100644
--- a/tests/testthat/test-f_analysis_multiarm_rates.R
+++ b/tests/testthat/test-f_analysis_multiarm_rates.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_analysis_multiarm_rates.R
## | Creation date: 08 November 2023, 09:07:05
-## | File version: $Revision: 7662 $
-## | Last changed: $Date: 2024-02-23 12:42:26 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing the Analysis Rates Functionality for Three or More Treatments")
diff --git a/tests/testthat/test-f_analysis_multiarm_survival.R b/tests/testthat/test-f_analysis_multiarm_survival.R
index 427ccf2b..11e15ac4 100644
--- a/tests/testthat/test-f_analysis_multiarm_survival.R
+++ b/tests/testthat/test-f_analysis_multiarm_survival.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_analysis_multiarm_survival.R
## | Creation date: 08 November 2023, 09:08:43
-## | File version: $Revision: 7662 $
-## | Last changed: $Date: 2024-02-23 12:42:26 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing the Analysis Survival Functionality for Three or More Treatments")
diff --git a/tests/testthat/test-f_analysis_utilities.R b/tests/testthat/test-f_analysis_utilities.R
index 963e8a25..3b96ed8c 100644
--- a/tests/testthat/test-f_analysis_utilities.R
+++ b/tests/testthat/test-f_analysis_utilities.R
@@ -15,8 +15,8 @@
## |
## | File name: test-f_analysis_utilities.R
## | Creation date: 08 November 2023, 09:09:34
-## | File version: $Revision: 7665 $
-## | Last changed: $Date: 2024-02-23 17:33:46 +0100 (Fr, 23 Feb 2024) $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -99,4 +99,11 @@ test_that("'getObservedInformationRates': under-running with relative informatio
})
+test_that(".sigmaToBPD works correctly", {
+
+ bpd <- c(0.3, 0.4, 0.5)
+ sigma <- bpd %*% t(bpd)
+ diag(sigma) <- 1
+
+})
diff --git a/tests/testthat/test-f_as251.R b/tests/testthat/test-f_as251.R
index 5576d0da..bab9f346 100644
--- a/tests/testthat/test-f_as251.R
+++ b/tests/testthat/test-f_as251.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_as251.R
## | Creation date: 16 January 2024, 07:16:35
-## | File version: $Revision: 7662 $
-## | Last changed: $Date: 2024-02-23 12:42:26 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing Dunnett AS 251 Functions")
diff --git a/tests/testthat/test-f_core_output_formats.R b/tests/testthat/test-f_core_output_formats.R
index 78431f5e..2791473a 100644
--- a/tests/testthat/test-f_core_output_formats.R
+++ b/tests/testthat/test-f_core_output_formats.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_core_output_formats.R
## | Creation date: 08 November 2023, 09:09:35
-## | File version: $Revision: 7665 $
-## | Last changed: $Date: 2024-02-23 17:33:46 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing the Output Format Functions")
diff --git a/tests/testthat/test-f_core_plot.R b/tests/testthat/test-f_core_plot.R
index 216e7702..63c6d980 100644
--- a/tests/testthat/test-f_core_plot.R
+++ b/tests/testthat/test-f_core_plot.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_core_plot.R
## | Creation date: 08 November 2023, 09:09:36
-## | File version: $Revision: 7662 $
-## | Last changed: $Date: 2024-02-23 12:42:26 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing .reconstructSequenceCommand")
diff --git a/tests/testthat/test-f_design_plan_count_data.R b/tests/testthat/test-f_design_plan_count_data.R
index adc4c786..5f8ad6f9 100644
--- a/tests/testthat/test-f_design_plan_count_data.R
+++ b/tests/testthat/test-f_design_plan_count_data.R
@@ -14,10 +14,10 @@
## | Contact us for information about our services: info@rpact.com
## |
## | File name: test-f_design_plan_count_data.R
-## | Creation date: 16 January 2024, 11:26:11
-## | File version: $Revision$
-## | Last changed: $Date$
-## | Last changed by: $Author$
+## | Creation date: 28 May 2024, 09:45:32
+## | File version: $Revision: 7946 $
+## | Last changed: $Date: 2024-05-28 12:08:57 +0200 (Di, 28 Mai 2024) $
+## | Last changed by: $Author: pahlke $
## |
test_plan_section("Testing the Sample Size Calculation of Count Data Designs for Different Designs and Arguments")
@@ -28,7 +28,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result1 <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, lambda = 0.234, theta = 0.7,
@@ -74,7 +74,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result2 <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, lambda = 0.234, theta = 0.7,
@@ -121,7 +121,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result3 <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, lambda2 = 0.02, theta = c(0.7, 0.8),
@@ -165,7 +165,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result4 <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, lambda1 = seq(1.05, 1.35, 0.15),
@@ -207,7 +207,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
expect_true(nrow(mtx) > 0 && ncol(mtx) > 0)
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
expect_error(getSampleSizeCounts(
alpha = 0.01, beta = 0.05, lambda1 = seq(1.35, 1.35, 0.15),
@@ -215,7 +215,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
))
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result5 <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, thetaH0 = 0.9, lambda1 = seq(1.1, 1.15, 0.05),
@@ -257,7 +257,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result6 <- getSampleSizeCounts(
alpha = 0.01, beta = 0.05, theta = seq(1.05, 1.35, 0.15),
@@ -302,7 +302,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureOptimumAllocationRatio}
result7 <- getSampleSizeCounts(
@@ -349,7 +349,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
# @refFS[Formula]{fs:sampleSizeCountsVariableExposureOptimumAllocationRatio}
result8 <- getSampleSizeCounts(
@@ -406,7 +406,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result1 <- getSampleSizeCounts(
design = designGS1, lambda = 0.234, theta = 0.7,
@@ -480,7 +480,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result2 <- getSampleSizeCounts(
design = designGS1, lambda = 0.234, theta = 0.7,
@@ -555,7 +555,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result3 <- getSampleSizeCounts(
design = designGS1, lambda2 = 0.02, theta = c(0.7, 0.8),
@@ -627,7 +627,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result4 <- getSampleSizeCounts(
design = designGS1, lambda1 = seq(1.05, 1.35, 0.15),
@@ -637,6 +637,8 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
## Comparison of the results of TrialDesignPlanCountData object 'result4' with expected results
expect_equal(result4$directionUpper, c(FALSE, FALSE, FALSE), label = paste0(result4$directionUpper))
expect_equal(result4$theta, c(0.75, 0.85714286, 0.96428571), tolerance = 1e-07, label = paste0(result4$theta))
+ expect_equal(result4$maxNumberOfSubjects1, c(80, 80, 80), label = paste0(result4$maxNumberOfSubjects1))
+ expect_equal(result4$maxNumberOfSubjects2, c(20, 20, 20), label = paste0(result4$maxNumberOfSubjects2))
expect_equal(result4$rejectPerStage[1, ], 0.19514116, tolerance = 1e-07, label = paste0(result4$rejectPerStage[1, ]))
expect_equal(result4$rejectPerStage[2, ], 0.37204423, tolerance = 1e-07, label = paste0(result4$rejectPerStage[2, ]))
expect_equal(result4$rejectPerStage[3, ], 0.33281461, tolerance = 1e-07, label = paste0(result4$rejectPerStage[3, ]))
@@ -669,6 +671,8 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
result4CodeBased <- eval(parse(text = getObjectRCode(result4, stringWrapParagraphWidth = NULL)))
expect_equal(result4CodeBased$directionUpper, result4$directionUpper, tolerance = 1e-07)
expect_equal(result4CodeBased$theta, result4$theta, tolerance = 1e-07)
+ expect_equal(result4CodeBased$maxNumberOfSubjects1, result4$maxNumberOfSubjects1, tolerance = 1e-07)
+ expect_equal(result4CodeBased$maxNumberOfSubjects2, result4$maxNumberOfSubjects2, tolerance = 1e-07)
expect_equal(result4CodeBased$rejectPerStage, result4$rejectPerStage, tolerance = 1e-07)
expect_equal(result4CodeBased$futilityStop, result4$futilityStop, tolerance = 1e-07)
expect_equal(result4CodeBased$futilityPerStage, result4$futilityPerStage, tolerance = 1e-07)
@@ -693,7 +697,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result5 <- getSampleSizeCounts(
design = designGS1, lambda1 = seq(1.05, 1.35, 0.15),
@@ -765,7 +769,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result6 <- getSampleSizeCounts(
design = designGS1, thetaH0 = 0.9, lambda1 = seq(1.1, 1.15, 0.05),
@@ -775,6 +779,8 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
## Comparison of the results of TrialDesignPlanCountData object 'result6' with expected results
expect_equal(result6$directionUpper, c(FALSE, FALSE), label = paste0(result6$directionUpper))
expect_equal(result6$theta, c(0.64705882, 0.67647059), tolerance = 1e-07, label = paste0(result6$theta))
+ expect_equal(result6$maxNumberOfSubjects1, c(150, 150), label = paste0(result6$maxNumberOfSubjects1))
+ expect_equal(result6$maxNumberOfSubjects2, c(150, 150), label = paste0(result6$maxNumberOfSubjects2))
expect_equal(result6$rejectPerStage[1, ], 0.19514116, tolerance = 1e-07, label = paste0(result6$rejectPerStage[1, ]))
expect_equal(result6$rejectPerStage[2, ], 0.37204423, tolerance = 1e-07, label = paste0(result6$rejectPerStage[2, ]))
expect_equal(result6$rejectPerStage[3, ], 0.33281461, tolerance = 1e-07, label = paste0(result6$rejectPerStage[3, ]))
@@ -807,6 +813,8 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
result6CodeBased <- eval(parse(text = getObjectRCode(result6, stringWrapParagraphWidth = NULL)))
expect_equal(result6CodeBased$directionUpper, result6$directionUpper, tolerance = 1e-07)
expect_equal(result6CodeBased$theta, result6$theta, tolerance = 1e-07)
+ expect_equal(result6CodeBased$maxNumberOfSubjects1, result6$maxNumberOfSubjects1, tolerance = 1e-07)
+ expect_equal(result6CodeBased$maxNumberOfSubjects2, result6$maxNumberOfSubjects2, tolerance = 1e-07)
expect_equal(result6CodeBased$rejectPerStage, result6$rejectPerStage, tolerance = 1e-07)
expect_equal(result6CodeBased$futilityStop, result6$futilityStop, tolerance = 1e-07)
expect_equal(result6CodeBased$futilityPerStage, result6$futilityPerStage, tolerance = 1e-07)
@@ -831,7 +839,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result7 <- getSampleSizeCounts(
design = designGS1, lambda1 = seq(1.05, 1.35, 0.15),
@@ -904,7 +912,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureOptimumAllocationRatio}
result8 <- getSampleSizeCounts(
@@ -979,7 +987,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
# @refFS[Formula]{fs:sampleSizeCountsVariableExposureOptimumAllocationRatio}
result9 <- getSampleSizeCounts(
@@ -1064,7 +1072,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result1 <- getSampleSizeCounts(
design = designGS2, lambda = 0.234, theta = 0.7,
@@ -1130,7 +1138,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result2 <- getSampleSizeCounts(
design = designGS2, lambda = 0.234, theta = 0.7,
@@ -1197,7 +1205,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result3 <- getSampleSizeCounts(
design = designGS2, lambda2 = 0.02, theta = c(0.7, 0.8),
@@ -1215,7 +1223,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
expect_equal(result3$rejectPerStage[3, ], 0.49132609, tolerance = 1e-07, label = paste0(result3$rejectPerStage[3, ]))
expect_equal(result3$earlyStop, 0.30867391, tolerance = 1e-07, label = paste0(result3$earlyStop))
expect_equal(result3$calendarTime[1, ], c(3.2316907, 3.2313779), tolerance = 1e-07, label = paste0(result3$calendarTime[1, ]))
- expect_equal(result3$calendarTime[2, ], c(4.9818015, 4.9813797), tolerance = 1e-07, label = paste0(result3$calendarTime[2, ]))
+ expect_equal(result3$calendarTime[2, ], c(4.9818015, 4.9813796), tolerance = 1e-07, label = paste0(result3$calendarTime[2, ]))
expect_equal(result3$calendarTime[3, ], c(9, 9), label = paste0(result3$calendarTime[3, ]))
expect_equal(result3$expectedStudyDurationH1, c(7.7010947, 7.7009681), tolerance = 1e-07, label = paste0(result3$expectedStudyDurationH1))
expect_equal(result3$numberOfSubjects[1, ], c(4348, 10310), label = paste0(result3$numberOfSubjects[1, ]))
@@ -1261,7 +1269,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result4 <- getSampleSizeCounts(
design = designGS2, lambda1 = seq(1.05, 1.35, 0.15),
@@ -1271,6 +1279,8 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
## Comparison of the results of TrialDesignPlanCountData object 'result4' with expected results
expect_equal(result4$directionUpper, c(FALSE, FALSE, FALSE), label = paste0(result4$directionUpper))
expect_equal(result4$theta, c(0.75, 0.85714286, 0.96428571), tolerance = 1e-07, label = paste0(result4$theta))
+ expect_equal(result4$maxNumberOfSubjects1, c(80, 80, 80), label = paste0(result4$maxNumberOfSubjects1))
+ expect_equal(result4$maxNumberOfSubjects2, c(20, 20, 20), label = paste0(result4$maxNumberOfSubjects2))
expect_equal(result4$rejectPerStage[1, ], 0.033479189, tolerance = 1e-07, label = paste0(result4$rejectPerStage[1, ]))
expect_equal(result4$rejectPerStage[2, ], 0.27519472, tolerance = 1e-07, label = paste0(result4$rejectPerStage[2, ]))
expect_equal(result4$rejectPerStage[3, ], 0.49132609, tolerance = 1e-07, label = paste0(result4$rejectPerStage[3, ]))
@@ -1298,6 +1308,8 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
result4CodeBased <- eval(parse(text = getObjectRCode(result4, stringWrapParagraphWidth = NULL)))
expect_equal(result4CodeBased$directionUpper, result4$directionUpper, tolerance = 1e-07)
expect_equal(result4CodeBased$theta, result4$theta, tolerance = 1e-07)
+ expect_equal(result4CodeBased$maxNumberOfSubjects1, result4$maxNumberOfSubjects1, tolerance = 1e-07)
+ expect_equal(result4CodeBased$maxNumberOfSubjects2, result4$maxNumberOfSubjects2, tolerance = 1e-07)
expect_equal(result4CodeBased$rejectPerStage, result4$rejectPerStage, tolerance = 1e-07)
expect_equal(result4CodeBased$earlyStop, result4$earlyStop, tolerance = 1e-07)
expect_equal(result4CodeBased$calendarTime, result4$calendarTime, tolerance = 1e-07)
@@ -1319,7 +1331,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result5 <- getSampleSizeCounts(
design = designGS2, lambda1 = seq(1.05, 1.35, 0.15),
@@ -1383,7 +1395,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
result6 <- getSampleSizeCounts(
design = designGS2, lambda1 = seq(1.05, 1.35, 0.15),
@@ -1448,7 +1460,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
# @refFS[Formula]{fs:FisherInfCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureSingleStage}
- # @refFS[Formula]{fs:sampleSizePerStageFixedExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeFixedExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
# @refFS[Formula]{fs:sampleSizeCountsFixedExposureOptimumAllocationRatio}
result7 <- getSampleSizeCounts(
@@ -1515,7 +1527,7 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
}
# @refFS[Formula]{fs:FisherInfCounts}
- # @refFS[Formula]{fs:sampleSizePerStageVariableExposureCounts}
+ # @refFS[Formula]{fs:maximumSampleSizeVariableExposureCounts}
# @refFS[Formula]{fs:observationTimePerStageCounts}
# @refFS[Formula]{fs:sampleSizeCountsVariableExposureOptimumAllocationRatio}
result8 <- getSampleSizeCounts(
@@ -1535,9 +1547,9 @@ test_that("'getSampleSizeCounts': Sample size calculation of testing count data
expect_equal(result8$rejectPerStage[3, ], 0.49132609, tolerance = 1e-07, label = paste0(result8$rejectPerStage[3, ]))
expect_equal(result8$earlyStop, 0.30867391, tolerance = 1e-07, label = paste0(result8$earlyStop))
expect_equal(result8$calendarTime[1, ], c(4.4478569, 4.4878996), tolerance = 1e-07, label = paste0(result8$calendarTime[1, ]))
- expect_equal(result8$calendarTime[2, ], c(5.9668445, 5.9911665), tolerance = 1e-07, label = paste0(result8$calendarTime[2, ]))
+ expect_equal(result8$calendarTime[2, ], c(5.9668444, 5.9911665), tolerance = 1e-07, label = paste0(result8$calendarTime[2, ]))
expect_equal(result8$calendarTime[3, ], c(8, 8), label = paste0(result8$calendarTime[3, ]))
- expect_equal(result8$expectedStudyDurationH1, c(7.3215635, 7.3295973), tolerance = 1e-07, label = paste0(result8$expectedStudyDurationH1))
+ expect_equal(result8$expectedStudyDurationH1, c(7.3215634, 7.3295973), tolerance = 1e-07, label = paste0(result8$expectedStudyDurationH1))
expect_equal(result8$numberOfSubjects[1, ], c(52, 1032), label = paste0(result8$numberOfSubjects[1, ]))
expect_equal(result8$numberOfSubjects[2, ], c(69, 1378), label = paste0(result8$numberOfSubjects[2, ]))
expect_equal(result8$numberOfSubjects[3, ], c(82, 1610), label = paste0(result8$numberOfSubjects[3, ]))
diff --git a/tests/testthat/test-f_object_r_code.R b/tests/testthat/test-f_object_r_code.R
new file mode 100644
index 00000000..68023aa2
--- /dev/null
+++ b/tests/testthat/test-f_object_r_code.R
@@ -0,0 +1,77 @@
+## |
+## | *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_quality_assurance.R
+## | Creation date: 23 May 2024, 11:59:52
+## | File version: $Revision: 7928 $
+## | Last changed: $Date: 2024-05-23 16:35:16 +0200 (Do, 23 Mai 2024) $
+## | Last changed by: $Author: pahlke $
+## |
+
+test_plan_section("Testing the Get Object R Code Function")
+
+
+test_that("'getObjectRCode': varied input arguments", {
+ .skipTestIfDisabled()
+
+ obj <- getSampleSizeMeans(getDesignGroupSequential())
+
+ result1 <- getObjectRCode(obj, stringWrapParagraphWidth = 20, stringWrapPrefix = " ", pipeOperator = "R")
+
+ ## Comparison of the results of character object 'result1' with expected results
+ expect_equal(result1, c("getDesignGroupSequential() |> ", "getSampleSizeMeans()"), label = paste0(result1))
+
+ result2 <- getObjectRCode(obj, output = "markdown", pipeOperator = "R")
+
+ ## Comparison of the results of character object 'result2' with expected results
+ expect_equal(result2, "getDesignGroupSequential() |>
+ getSampleSizeMeans()", label = paste0(result2))
+
+ result3 <- getObjectRCode(obj, explicitPrint = TRUE, pipeOperator = "R")
+
+ ## Comparison of the results of character object 'result3' with expected results
+ expect_equal(result3, c("getDesignGroupSequential() |>", "getSampleSizeMeans() |>", "print()"), label = paste0(result3))
+
+ result4 <- getObjectRCode(obj, postfix = c("|>", "print()"), pipeOperator = "R")
+
+ ## Comparison of the results of character object 'result4' with expected results
+ expect_equal(result4, c("getDesignGroupSequential() |>", "getSampleSizeMeans()|>", "print()"), label = paste0(result4))
+
+ result5 <- getObjectRCode(obj, leadingArguments = "", pipeOperator = "R")
+
+ ## Comparison of the results of character object 'result5' with expected results
+ expect_equal(result5, c("getDesignGroupSequential() |>", "getSampleSizeMeans()"), label = paste0(result5))
+
+ result6 <- getObjectRCode(summary(obj), pipeOperator = "R")
+
+ ## Comparison of the results of character object 'result6' with expected results
+ expect_equal(result6, c("getDesignGroupSequential() |>", "getSampleSizeMeans() |>", "summary()"), label = paste0(result6))
+
+ result7 <- getObjectRCode(obj, pipeOperator = "none")
+
+ ## Comparison of the results of character object 'result7' with expected results
+ expect_equal(result7, c("design <- getDesignGroupSequential()", "getSampleSizeMeans(design = design)"), label = paste0(result7))
+
+ result8 <- getObjectRCode(obj, pipeOperator = "magrittr")
+
+ ## Comparison of the results of character object 'result8' with expected results
+ expect_equal(result8, c("getDesignGroupSequential() %>%", "getSampleSizeMeans()"), label = paste0(result8))
+
+ expect_output(print(getObjectRCode(obj)))
+
+ expect_output(getObjectRCode(obj, output = "cat", pipeOperator = "R"))
+
+ suppressMessages(expect_output(print(getObjectRCode(obj, output = "test", pipeOperator = "R"))))
+})
diff --git a/tests/testthat/test-f_quality_assurance.R b/tests/testthat/test-f_quality_assurance.R
deleted file mode 100644
index d1c109a0..00000000
--- a/tests/testthat/test-f_quality_assurance.R
+++ /dev/null
@@ -1,62 +0,0 @@
-## |
-## | *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_quality_assurance.R
-## | Creation date: 06 February 2023, 12:13:45
-## | File version: $Revision: 7644 $
-## | Last changed: $Date: 2024-02-16 10:36:28 +0100 (Fr, 16 Feb 2024) $
-## | Last changed by: $Author: pahlke $
-## |
-
-test_plan_section("Testing Quality Assurance Functions")
-
-test_that("Quality assurance functions throw errors when arguments are missing or wrong", {
- rVersion <- .isMinimumRVersion4()
- expect_true(rVersion)
-
- dummyContent <- "[ OK: 6 ] [FAILED: 3]"
- res_1 <- .getTestthatResultLine(dummyContent)
- expect_type(res_1, "character")
- expect_equal(2 * 2, 4)
-
- res_2 <- .getTestthatResultNumberOfFailures(dummyContent)
- expect_type(res_2, "character")
- expect_equal(2 * 2, 4)
-
- res_3 <- .getTestthatResultNumberOfSkippedTests(dummyContent)
- expect_type(res_3, "character")
- expect_equal(2 * 2, 4)
-
- expect_error(.downloadUnitTests(
- testFileTargetDirectory = NULL,
- token = "token",
- secret = "secret",
- connectionType = "pkg"
- ))
-
- expect_error(.prepareUnitTestFiles())
-
- expect_error(.downloadUnitTestsViaHttp())
-
- expect_error(.downloadUnitTestsViaFtp())
-
- expect_error(.getConnectionArgument())
-
- expect_error(testPackage(NULL))
-
- expect_error(.testInstalledPackage(NULL))
-
- expect_type(.isCompleteUnitTestSetEnabled(), "logical")
-})
diff --git a/tests/testthat/test-f_simulation_base_count_data.R b/tests/testthat/test-f_simulation_base_count_data.R
new file mode 100644
index 00000000..a7a0ea5c
--- /dev/null
+++ b/tests/testthat/test-f_simulation_base_count_data.R
@@ -0,0 +1,180 @@
+## |
+## | *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_base_count_data.R
+## | Creation date: 23 May 2024, 10:12:16
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
+## |
+
+test_plan_section("Testing Simulation Counts Function")
+
+
+test_that("'getSimulationCounts': variable exposure", {
+ .skipTestIfDisabled()
+
+ design <- getDesignGroupSequential(
+ informationRates = c(0.3, 0.55, 1),
+ alpha = 0.025, beta = 0.2, typeOfDesign = "asOF",
+ typeBetaSpending = "bsOF", bindingFutility = TRUE
+ )
+
+ suppressWarnings(result1 <- getSimulationCounts(
+ design = design,
+ directionUpper = FALSE,
+ plannedMaxSubjects = 110,
+ plannedCalendarTime = c(4.886914, 7.878929, 14),
+ lambda1 = c(0.7, 0.3),
+ lambda2 = 0.7,
+ overdispersion = 2,
+ maxNumberOfIterations = 100,
+ accrualTime = 12,
+ followUpTime = 2,
+ seed = 4378628
+ ))
+
+ ## Comparison of the results of SimulationResultsBaseCountDataSimulationResultsParameterSetFieldSetR6 object 'result1' with expected results
+ expect_equal(result1$theta, c(1, 0.42857143), tolerance = 1e-07, label = paste0(result1$theta))
+ expect_equal(result1$iterations[1, ], c(100, 100), label = paste0(result1$iterations[1, ]))
+ expect_equal(result1$iterations[2, ], c(74, 95), label = paste0(result1$iterations[2, ]))
+ expect_equal(result1$iterations[3, ], c(19, 72), label = paste0(result1$iterations[3, ]))
+ expect_equal(result1$overallReject, c(0.04, 0.78), tolerance = 1e-07, label = paste0(result1$overallReject))
+ expect_equal(result1$rejectPerStage[1, ], c(0, 0.01), tolerance = 1e-07, label = paste0(result1$rejectPerStage[1, ]))
+ expect_equal(result1$rejectPerStage[2, ], c(0, 0.17), tolerance = 1e-07, label = paste0(result1$rejectPerStage[2, ]))
+ expect_equal(result1$rejectPerStage[3, ], c(0.04, 0.6), tolerance = 1e-07, label = paste0(result1$rejectPerStage[3, ]))
+ expect_equal(result1$futilityStop, c(0.81, 0.1), tolerance = 1e-07, label = paste0(result1$futilityStop))
+ expect_equal(result1$futilityPerStage[1, ], c(0.26, 0.04), tolerance = 1e-07, label = paste0(result1$futilityPerStage[1, ]))
+ expect_equal(result1$futilityPerStage[2, ], c(0.55, 0.06), tolerance = 1e-07, label = paste0(result1$futilityPerStage[2, ]))
+ expect_equal(result1$earlyStop[1, ], c(0.81, 0.28), tolerance = 1e-07, label = paste0(result1$earlyStop[1, ]))
+
+ suppressWarnings(result2 <- getSimulationCounts(
+ getDesignGroupSequential(
+ alpha = 0.025,
+ futilityBounds = c(-0.5, 0.5)
+ ),
+ lambda1 = seq(1, 1.4, 0.1),
+ lambda2 = 1.4,
+ overdispersion = 1.1,
+ plannedCalendarTime = c(4, 5, 6),
+ allocationRatioPlanned = 3,
+ accrualTime = c(4),
+ accrualIntensity = c(100),
+ maxNumberOfIterations = 100,
+ followUpTime = 3,
+ directionUpper = FALSE,
+ seed = 4378628
+ ))
+
+
+ ## Comparison of the results of SimulationResultsBaseCountDataSimulationResultsParameterSetFieldSetR6 object 'result2' with expected results
+ expect_equal(result2$theta, c(0.71428571, 0.78571429, 0.85714286, 0.92857143, 1), tolerance = 1e-07, label = paste0(result2$theta))
+ expect_equal(result2$numberOfSubjects, 400, label = paste0(result2$numberOfSubjects))
+ expect_equal(result2$numberOfSubjects1, 300, label = paste0(result2$numberOfSubjects1))
+ expect_equal(result2$numberOfSubjects2, 100, label = paste0(result2$numberOfSubjects2))
+ expect_equal(result2$iterations[1, ], c(100, 100, 100, 100, 100), label = paste0(result2$iterations[1, ]))
+ expect_equal(result2$iterations[2, ], c(86, 94, 96, 86, 69), label = paste0(result2$iterations[2, ]))
+ expect_equal(result2$iterations[3, ], c(40, 53, 72, 50, 25), label = paste0(result2$iterations[3, ]))
+ expect_equal(result2$overallReject, c(0.77, 0.47, 0.26, 0.08, 0.01), tolerance = 1e-07, label = paste0(result2$overallReject))
+ expect_equal(result2$rejectPerStage[1, ], c(0.14, 0.05, 0.02, 0, 0), tolerance = 1e-07, label = paste0(result2$rejectPerStage[1, ]))
+ expect_equal(result2$rejectPerStage[2, ], c(0.44, 0.28, 0.09, 0.02, 0.01), tolerance = 1e-07, label = paste0(result2$rejectPerStage[2, ]))
+ expect_equal(result2$rejectPerStage[3, ], c(0.19, 0.14, 0.15, 0.06, 0), tolerance = 1e-07, label = paste0(result2$rejectPerStage[3, ]))
+ expect_equal(result2$futilityStop, c(0.02, 0.14, 0.17, 0.48, 0.74), tolerance = 1e-07, label = paste0(result2$futilityStop))
+ expect_equal(result2$futilityPerStage[1, ], c(0, 0.01, 0.02, 0.14, 0.31), tolerance = 1e-07, label = paste0(result2$futilityPerStage[1, ]))
+ expect_equal(result2$futilityPerStage[2, ], c(0.02, 0.13, 0.15, 0.34, 0.43), tolerance = 1e-07, label = paste0(result2$futilityPerStage[2, ]))
+ expect_equal(result2$earlyStop[1, ], c(0.6, 0.47, 0.28, 0.5, 0.75), tolerance = 1e-07, label = paste0(result2$earlyStop[1, ]))
+})
+
+test_that("'getSimulationCounts': fixed exposure", {
+ design <- getDesignGroupSequential(
+ informationRates = c(0.3, 0.55, 1),
+ alpha = 0.025, beta = 0.2, typeOfDesign = "asOF",
+ typeBetaSpending = "bsOF", bindingFutility = TRUE
+ )
+
+ suppressWarnings(result1 <- getSimulationCounts(
+ design = design,
+ directionUpper = FALSE,
+ plannedMaxSubjects = 110,
+ plannedCalendarTime = c(4.886914, 7.878929, 14),
+ lambda1 = c(0.7, 0.3),
+ lambda2 = 0.7,
+ overdispersion = 2,
+ accrualTime = 12,
+ fixedExposureTime = 1,
+ maxNumberOfIterations = 100,
+ seed = 4378628
+ ))
+
+
+ ## Comparison of the results of SimulationResultsBaseCountDataSimulationResultsParameterSetFieldSetR6 object 'result1' with expected results
+ expect_equal(result1$theta, c(1, 0.42857143), tolerance = 1e-07, label = paste0(result1$theta))
+ expect_equal(result1$iterations[1, ], c(100, 100), label = paste0(result1$iterations[1, ]))
+ expect_equal(result1$iterations[2, ], c(62, 97), label = paste0(result1$iterations[2, ]))
+ expect_equal(result1$iterations[3, ], c(27, 69), label = paste0(result1$iterations[3, ]))
+ expect_equal(result1$overallReject, c(0.02, 0.55), tolerance = 1e-07, label = paste0(result1$overallReject))
+ expect_equal(result1$rejectPerStage[1, ], c(0, 0), label = paste0(result1$rejectPerStage[1, ]))
+ expect_equal(result1$rejectPerStage[2, ], c(0, 0.08), tolerance = 1e-07, label = paste0(result1$rejectPerStage[2, ]))
+ expect_equal(result1$rejectPerStage[3, ], c(0.02, 0.47), tolerance = 1e-07, label = paste0(result1$rejectPerStage[3, ]))
+ expect_equal(result1$futilityStop, c(0.73, 0.23), tolerance = 1e-07, label = paste0(result1$futilityStop))
+ expect_equal(result1$futilityPerStage[1, ], c(0.38, 0.03), tolerance = 1e-07, label = paste0(result1$futilityPerStage[1, ]))
+ expect_equal(result1$futilityPerStage[2, ], c(0.35, 0.2), tolerance = 1e-07, label = paste0(result1$futilityPerStage[2, ]))
+ expect_equal(result1$earlyStop[1, ], c(0.73, 0.31), tolerance = 1e-07, label = paste0(result1$earlyStop[1, ]))
+
+ suppressWarnings(result2 <- getSimulationCounts(
+ maxNumberOfSubjects = 1000,
+ plannedMaxSubjects = 110,
+ plannedCalendarTime = as.matrix(10),
+ accrualTime = 5,
+ directionUpper = FALSE,
+ lambda2 = 1.4,
+ theta = c(0.75, 1.133333),
+ overdispersion = 1.5,
+ fixedExposureTime = 2,
+ maxNumberOfIterations = 100,
+ seed = 4378628
+ ))
+
+ ## Comparison of the results of SimulationResultsBaseCountDataSimulationResultsParameterSetFieldSetR6 object 'result2' with expected results
+ expect_equal(result2$lambda1, c(1.05, 1.5866662), tolerance = 1e-07, label = paste0(result2$lambda1))
+ expect_equal(result2$iterations[1, ], c(100, 100), label = paste0(result2$iterations[1, ]))
+ expect_equal(result2$overallReject, c(0.14, 0), tolerance = 1e-07, label = paste0(result2$overallReject))
+
+ suppressWarnings(result3 <- getSimulationCounts(
+ getDesignGroupSequential(kMax = 3, futilityBounds = c(0, 0)),
+ plannedMaxSubjects = 100,
+ plannedCalendarTime = as.matrix(c(2, 4, 6)),
+ maxNumberOfIterations = 100,
+ fixedExposureTime = 1,
+ accrualTime = 6,
+ lambda1 = seq(1.05, 1.35, 0.05),
+ lambda2 = 1.4,
+ seed = 4378628
+ ))
+
+ ## Comparison of the results of SimulationResultsBaseCountDataSimulationResultsParameterSetFieldSetR6 object 'result3' with expected results
+ expect_equal(result3$theta, c(0.75, 0.78571429, 0.82142857, 0.85714286, 0.89285714, 0.92857143, 0.96428571), tolerance = 1e-07, label = paste0(result3$theta))
+ expect_equal(result3$iterations[1, ], c(100, 100, 100, 100, 100, 100, 100), label = paste0(result3$iterations[1, ]))
+ expect_equal(result3$iterations[2, ], c(25, 32, 34, 38, 34, 47, 56), label = paste0(result3$iterations[2, ]))
+ expect_equal(result3$iterations[3, ], c(6, 11, 17, 18, 20, 31, 35), label = paste0(result3$iterations[3, ]))
+ expect_equal(result3$overallReject, c(0, 0, 0.01, 0, 0, 0.01, 0), tolerance = 1e-07, label = paste0(result3$overallReject))
+ expect_equal(result3$rejectPerStage[1, ], c(0, 0, 0, 0, 0, 0, 0), label = paste0(result3$rejectPerStage[1, ]))
+ expect_equal(result3$rejectPerStage[2, ], c(0, 0, 0.01, 0, 0, 0, 0), tolerance = 1e-07, label = paste0(result3$rejectPerStage[2, ]))
+ expect_equal(result3$rejectPerStage[3, ], c(0, 0, 0, 0, 0, 0.01, 0), tolerance = 1e-07, label = paste0(result3$rejectPerStage[3, ]))
+ expect_equal(result3$futilityStop, c(0.94, 0.89, 0.82, 0.82, 0.8, 0.69, 0.65), tolerance = 1e-07, label = paste0(result3$futilityStop))
+ expect_equal(result3$futilityPerStage[1, ], c(0.75, 0.68, 0.66, 0.62, 0.66, 0.53, 0.44), tolerance = 1e-07, label = paste0(result3$futilityPerStage[1, ]))
+ expect_equal(result3$futilityPerStage[2, ], c(0.19, 0.21, 0.16, 0.2, 0.14, 0.16, 0.21), tolerance = 1e-07, label = paste0(result3$futilityPerStage[2, ]))
+ expect_equal(result3$earlyStop[1, ], c(0.94, 0.89, 0.83, 0.82, 0.8, 0.69, 0.65), tolerance = 1e-07, label = paste0(result3$earlyStop[1, ]))
+})
diff --git a/tests/testthat/test-f_simulation_base_means.R b/tests/testthat/test-f_simulation_base_means.R
index c7ee5ce7..87569b34 100644
--- a/tests/testthat/test-f_simulation_base_means.R
+++ b/tests/testthat/test-f_simulation_base_means.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_simulation_base_means.R
## | Creation date: 07 March 2024, 13:13:26
-## | File version: $Revision: 7702 $
-## | Last changed: $Date: 2024-03-07 13:30:30 +0100 (Do, 07 Mrz 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing Simulation Means Function")
diff --git a/tests/testthat/test-f_simulation_base_survival.R b/tests/testthat/test-f_simulation_base_survival.R
index 096ce955..84fd1664 100644
--- a/tests/testthat/test-f_simulation_base_survival.R
+++ b/tests/testthat/test-f_simulation_base_survival.R
@@ -15,8 +15,8 @@
## |
## | File name: test-f_simulation_base_survival.R
## | Creation date: 08 November 2023, 09:11:01
-## | File version: $Revision: 7665 $
-## | Last changed: $Date: 2024-02-23 17:33:46 +0100 (Fr, 23 Feb 2024) $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -138,12 +138,12 @@ test_that("'getSimulationSurvival': configuration 2", {
expect_equal(simulationResults$numberOfSubjects[1, ], c(186.51, 180.63, 173.73, 168.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], c(406.05, 420.67123, 424.60256, 393.44615), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], c(428.4, 466.33333, 480.96429, 488.78261), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], c(64.483333, 73.054795, 78.884615, 72.015385), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], c(70.6, 80.555556, 134.14286, 156.02174), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], c(84.483333, 93.054795, 98.884615, 92.015385), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], c(155.08333, 173.61035, 233.02747, 248.03712), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], c(64.483333, 73.054795, 78.884615, 72.015385), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], c(70.6, 80.555556, 134.14286, 156.02174), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], c(84.483333, 93.054795, 98.884615, 92.015385), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], c(155.08333, 173.61035, 233.02747, 248.03712), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], c(100, 100, 100, 100), label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], c(60, 73, 78, 65), label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], c(5, 9, 28, 46), label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -184,8 +184,8 @@ test_that("'getSimulationSurvival': configuration 2", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -247,12 +247,12 @@ test_that("'getSimulationSurvival': configuration 3", {
expect_equal(simulationResults$numberOfSubjects[1, ], c(275.04, 265.86, 248.46, 231.45), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], c(496.07246, 481.84722, 476, 463.84), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], c(500, 500, 500, 494), label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], c(86.507246, 74.541667, 74.677966, 74.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], c(155.24324, 97.666667, 124.28571, 37), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], c(106.50725, 94.541667, 94.677966, 94.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], c(261.75049, 192.20833, 218.96368, 131.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], c(86.507246, 74.541667, 74.677966, 74.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], c(155.24324, 97.666667, 124.28571, 37), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], c(106.50725, 94.541667, 94.677966, 94.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], c(261.75049, 192.20833, 218.96368, 131.48), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], c(100, 100, 100, 100), label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], c(69, 72, 59, 50), label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], c(37, 12, 7, 2), label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -293,8 +293,8 @@ test_that("'getSimulationSurvival': configuration 3", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -362,12 +362,12 @@ test_that("'getSimulationSurvival': configuration 4", {
expect_equal(simulationResults$numberOfSubjects[1, ], 231.41, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], 448.23158, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], 491.66667, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], 71.694737, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], 111.76667, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], 91.694737, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], 203.4614, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], 71.694737, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], 111.76667, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], 91.694737, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], 203.4614, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], 100, label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], 95, label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], 30, label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -398,8 +398,8 @@ test_that("'getSimulationSurvival': configuration 4", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -462,12 +462,12 @@ test_that("'getSimulationSurvival': configuration 5", {
expect_equal(simulationResults$numberOfSubjects[1, ], c(126.03, 121.42, 115.37, 113.16), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], c(187.50575, 190.98876, 193.16304, 192.33), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], c(199.11111, 200, 199.39655, 199.28571), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], c(28.54023, 31.561798, 35.130435, 35.79), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], c(26.388889, 33.558824, 37.155172, 37.792208), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], c(48.54023, 51.561798, 55.130435, 55.79), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], c(74.929119, 85.120621, 92.285607, 93.582208), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], c(28.54023, 31.561798, 35.130435, 35.79), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], c(26.388889, 33.558824, 37.155172, 37.792208), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], c(20, 20, 20, 20), label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], c(48.54023, 51.561798, 55.130435, 55.79), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], c(74.929119, 85.120621, 92.285607, 93.582208), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], c(100, 100, 100, 100), label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], c(87, 89, 92, 100), label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], c(18, 34, 58, 77), label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -508,8 +508,8 @@ test_that("'getSimulationSurvival': configuration 5", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -579,12 +579,12 @@ test_that("'getSimulationSurvival': configuration 6", {
expect_equal(simulationResults$numberOfSubjects[1, ], 205.17, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], 258.63158, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], 258.76923, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], 105.21053, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], 97.307692, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], 125.21053, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], 222.51822, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], 105.21053, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], 97.307692, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], 125.21053, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], 222.51822, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], 100, label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], 38, label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], 13, label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -615,8 +615,8 @@ test_that("'getSimulationSurvival': configuration 6", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -727,12 +727,12 @@ test_that("'getSimulationSurvival': configuration 7", {
expect_equal(simulationResults$numberOfSubjects[1, ], 211.81, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], 259.98, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], 260, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], 87.53, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], 93.376344, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], 107.53, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], 200.90634, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], 87.53, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], 93.376344, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], 107.53, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], 200.90634, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], 100, label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], 100, label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], 93, label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -765,8 +765,8 @@ test_that("'getSimulationSurvival': configuration 7", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -825,12 +825,12 @@ test_that("'getSimulationSurvival': configuration 8", {
expect_equal(simulationResults$numberOfSubjects[1, ], 199.73, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], 200, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], 60, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], 60, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], 100, label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], 99, label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], 95, label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -861,8 +861,8 @@ test_that("'getSimulationSurvival': configuration 8", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -922,12 +922,12 @@ test_that("'getSimulationSurvival': configuration 9;", {
expect_equal(simulationResults$numberOfSubjects[1, ], 257.27, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], 260, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], 260, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], 86.161616, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], 89.574713, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], 106.16162, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], 195.73633, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], 86.161616, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], 89.574713, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], 106.16162, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], 195.73633, tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], 100, label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], 99, label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], 87, label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -958,8 +958,8 @@ test_that("'getSimulationSurvival': configuration 9;", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -1023,12 +1023,12 @@ test_that("'getSimulationSurvival': configuration 10;", {
expect_equal(simulationResults$numberOfSubjects[1, ], c(195.58, 192.19, 190.21), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], c(258.86, 259.77778, 259.64646), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], c(260, 260, 260), label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], c(85.16, 89.353535, 92.363636), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], c(92, 90.181818, 98.623656), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], c(105.16, 109.35354, 112.36364), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], c(197.16, 199.53535, 210.98729), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], c(85.16, 89.353535, 92.363636), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], c(92, 90.181818, 98.623656), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], c(105.16, 109.35354, 112.36364), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], c(197.16, 199.53535, 210.98729), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], c(100, 100, 100), label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], c(100, 99, 99), label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], c(86, 88, 93), label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -1067,8 +1067,8 @@ test_that("'getSimulationSurvival': configuration 10;", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -1147,12 +1147,12 @@ test_that("'getSimulationSurvival': configuration 11;", {
expect_equal(simulationResults$numberOfSubjects[1, ], c(532.2, 476.1, 432.4, 414.9), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[2, ], c(788.2, 681.33333, 599.66667, 562.8), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$numberOfSubjects[3, ], c(800, 778.66667, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[1, ], c(58, 58, 58, 58), label = paste0("c(", paste0(simulationResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[2, ], c(162.8, 74.888889, 46, 44), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$singleEventsPerStage[3, ], c(162.8, 132, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[1, ], c(58, 58, 58, 58), label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[2, ], c(220.8, 132.88889, 104, 102), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResults$cumulativeEventsPerStage[3, ], c(383.6, 264.88889, 104, 102), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[1, ], c(58, 58, 58, 58), label = paste0("c(", paste0(simulationResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[2, ], c(162.8, 74.888889, 46, 44), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$eventsPerStage[3, ], c(162.8, 132, NA_real_, NA_real_), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[1, ], c(58, 58, 58, 58), label = paste0("c(", paste0(simulationResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[2, ], c(220.8, 132.88889, 104, 102), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResults$overallEventsPerStage[3, ], c(383.6, 264.88889, 104, 102), tolerance = 1e-07, label = paste0("c(", paste0(simulationResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[1, ], c(10, 10, 10, 10), label = paste0("c(", paste0(simulationResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[2, ], c(10, 9, 6, 5), label = paste0("c(", paste0(simulationResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResults$iterations[3, ], c(10, 3, 0, 0), label = paste0("c(", paste0(simulationResults$iterations[3, ], collapse = ", "), ")"))
@@ -1193,8 +1193,8 @@ test_that("'getSimulationSurvival': configuration 11;", {
expect_equal(simulationResultsCodeBased$studyDuration, simulationResults$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$eventsNotAchieved, simulationResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$numberOfSubjects, simulationResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$singleEventsPerStage, simulationResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultsCodeBased$cumulativeEventsPerStage, simulationResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$eventsPerStage, simulationResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultsCodeBased$overallEventsPerStage, simulationResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$iterations, simulationResults$iterations, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$overallReject, simulationResults$overallReject, tolerance = 1e-07)
expect_equal(simulationResultsCodeBased$rejectPerStage, simulationResults$rejectPerStage, tolerance = 1e-07)
@@ -1772,10 +1772,10 @@ test_that("'getSimulationSurvival': Specify effect size for a two-stage group de
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 199.47, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 97, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.27, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -1803,8 +1803,8 @@ test_that("'getSimulationSurvival': Specify effect size for a two-stage group de
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -1852,12 +1852,12 @@ test_that("'getSimulationSurvival': As above, but with a three-stage O'Brien and
expect_equal(simulationResult$numberOfSubjects[1, ], 195.313, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[3, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 16, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 12, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[3, ], 12, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 16, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 28, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[3, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 16, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 12, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[3, ], 12, label = paste0("c(", paste0(simulationResult$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 16, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 28, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[3, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 1000, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 985, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[3, ], 861, label = paste0("c(", paste0(simulationResult$iterations[3, ], collapse = ", "), ")"))
@@ -1890,8 +1890,8 @@ test_that("'getSimulationSurvival': As above, but with a three-stage O'Brien and
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -1936,10 +1936,10 @@ test_that("'getSimulationSurvival': Effect size is based on event rate at specif
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 199.69, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 92, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.52, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -1967,8 +1967,8 @@ test_that("'getSimulationSurvival': Effect size is based on event rate at specif
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2010,10 +2010,10 @@ test_that("'getSimulationSurvival': Effect size is based on hazard rate for the
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 195.5, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 94, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.49, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -2039,8 +2039,8 @@ test_that("'getSimulationSurvival': Effect size is based on hazard rate for the
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2081,10 +2081,10 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 193.51, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 96, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.32, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -2108,8 +2108,8 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2145,10 +2145,10 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 193.51, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 96, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.32, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -2172,8 +2172,8 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2214,10 +2214,10 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 193.51, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 96, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.32, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -2241,8 +2241,8 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2278,10 +2278,10 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 193.51, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 96, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.32, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -2305,8 +2305,8 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2341,10 +2341,10 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResult$eventsNotAchieved[2, ], 0, label = paste0("c(", paste0(simulationResult$eventsNotAchieved[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[1, ], 197.81, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$numberOfSubjects[2, ], 200, label = paste0("c(", paste0(simulationResult$numberOfSubjects[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$singleEventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simulationResult$cumulativeEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$eventsPerStage[2, ], 20, label = paste0("c(", paste0(simulationResult$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[1, ], 20, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simulationResult$overallEventsPerStage[2, ], 40, label = paste0("c(", paste0(simulationResult$overallEventsPerStage[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[1, ], 100, label = paste0("c(", paste0(simulationResult$iterations[1, ], collapse = ", "), ")"))
expect_equal(simulationResult$iterations[2, ], 100, label = paste0("c(", paste0(simulationResult$iterations[2, ], collapse = ", "), ")"))
expect_equal(simulationResult$overallReject, 0.06, tolerance = 1e-07, label = paste0("c(", paste0(simulationResult$overallReject, collapse = ", "), ")"))
@@ -2368,8 +2368,8 @@ test_that("'getSimulationSurvival': Specification of piecewise exponential survi
expect_equal(simulationResultCodeBased$studyDuration, simulationResult$studyDuration, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$eventsNotAchieved, simulationResult$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$numberOfSubjects, simulationResult$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$singleEventsPerStage, simulationResult$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simulationResultCodeBased$cumulativeEventsPerStage, simulationResult$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$eventsPerStage, simulationResult$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simulationResultCodeBased$overallEventsPerStage, simulationResult$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$iterations, simulationResult$iterations, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$overallReject, simulationResult$overallReject, tolerance = 1e-07)
expect_equal(simulationResultCodeBased$rejectPerStage, simulationResult$rejectPerStage, tolerance = 1e-07)
@@ -2427,12 +2427,12 @@ test_that("'getSimulationSurvival': Perform recalculation of number of events ba
expect_equal(resultsWithSSR1$numberOfSubjects[1, ], c(531.25, 521.07, 500.8, 498.42, 488.13, 473.47, 464.37), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR1$numberOfSubjects[2, ], c(800, 800, 799.45, 798.66327, 796.55208, 797.06061, 793.47826), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR1$numberOfSubjects[3, ], c(800, 800, 800, 800, 800, 800, 800), label = paste0("c(", paste0(resultsWithSSR1$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR1$singleEventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR1$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR1$singleEventsPerStage[2, ], c(175.65, 173.27, 171.84, 171.43878, 170.57292, 169.67677, 161.44565), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR1$singleEventsPerStage[3, ], c(175.28125, 169.51042, 154.10227, 148.89552, 137.3, 142.17143, 133.72727), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR1$cumulativeEventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR1$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR1$cumulativeEventsPerStage[2, ], c(233.65, 231.27, 229.84, 229.43878, 228.57292, 227.67677, 219.44565), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR1$cumulativeEventsPerStage[3, ], c(408.93125, 400.78042, 383.94227, 378.3343, 365.87292, 369.8482, 353.17292), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR1$eventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR1$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR1$eventsPerStage[2, ], c(175.65, 173.27, 171.84, 171.43878, 170.57292, 169.67677, 161.44565), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR1$eventsPerStage[3, ], c(175.28125, 169.51042, 154.10227, 148.89552, 137.3, 142.17143, 133.72727), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR1$overallEventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR1$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR1$overallEventsPerStage[2, ], c(233.65, 231.27, 229.84, 229.43878, 228.57292, 227.67677, 219.44565), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR1$overallEventsPerStage[3, ], c(408.93125, 400.78042, 383.94227, 378.3343, 365.87292, 369.8482, 353.17292), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR1$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR1$iterations[1, ], c(100, 100, 100, 100, 100, 100, 100), label = paste0("c(", paste0(resultsWithSSR1$iterations[1, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR1$iterations[2, ], c(100, 100, 100, 98, 96, 99, 92), label = paste0("c(", paste0(resultsWithSSR1$iterations[2, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR1$iterations[3, ], c(96, 96, 88, 67, 50, 35, 11), label = paste0("c(", paste0(resultsWithSSR1$iterations[3, ], collapse = ", "), ")"))
@@ -2465,8 +2465,8 @@ test_that("'getSimulationSurvival': Perform recalculation of number of events ba
expect_equal(resultsWithSSR1CodeBased$studyDuration, resultsWithSSR1$studyDuration, tolerance = 1e-07)
expect_equal(resultsWithSSR1CodeBased$eventsNotAchieved, resultsWithSSR1$eventsNotAchieved, tolerance = 1e-07)
expect_equal(resultsWithSSR1CodeBased$numberOfSubjects, resultsWithSSR1$numberOfSubjects, tolerance = 1e-07)
- expect_equal(resultsWithSSR1CodeBased$singleEventsPerStage, resultsWithSSR1$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(resultsWithSSR1CodeBased$cumulativeEventsPerStage, resultsWithSSR1$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(resultsWithSSR1CodeBased$eventsPerStage, resultsWithSSR1$eventsPerStage, tolerance = 1e-07)
+ expect_equal(resultsWithSSR1CodeBased$overallEventsPerStage, resultsWithSSR1$overallEventsPerStage, tolerance = 1e-07)
expect_equal(resultsWithSSR1CodeBased$iterations, resultsWithSSR1$iterations, tolerance = 1e-07)
expect_equal(resultsWithSSR1CodeBased$overallReject, resultsWithSSR1$overallReject, tolerance = 1e-07)
expect_equal(resultsWithSSR1CodeBased$rejectPerStage, resultsWithSSR1$rejectPerStage, tolerance = 1e-07)
@@ -2513,12 +2513,12 @@ test_that("'getSimulationSurvival': Perform recalculation of number of events ba
expect_equal(resultsWithSSR2$numberOfSubjects[1, ], c(531.25, 521.07, 500.8, 498.42, 488.13, 473.47, 464.37), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR2$numberOfSubjects[2, ], c(798.3, 792.67, 784.71, 785.72449, 774.40625, 754.47475, 731), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR2$numberOfSubjects[3, ], c(800, 800, 800, 800, 799.08333, 797.51111, 794.95238), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR2$singleEventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR2$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR2$singleEventsPerStage[2, ], c(171.71, 164.76, 155.91, 152.63265, 143.21875, 127.82828, 113.84783), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR2$singleEventsPerStage[3, ], c(173.88889, 169.45263, 147.34783, 139.60563, 120.25, 125.66667, 100.2381), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR2$cumulativeEventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR2$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR2$cumulativeEventsPerStage[2, ], c(229.71, 222.76, 213.91, 210.63265, 201.21875, 185.82828, 171.84783), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(resultsWithSSR2$cumulativeEventsPerStage[3, ], c(403.59889, 392.21263, 361.25783, 350.23829, 321.46875, 311.49495, 272.08592), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR2$eventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR2$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR2$eventsPerStage[2, ], c(171.71, 164.76, 155.91, 152.63265, 143.21875, 127.82828, 113.84783), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR2$eventsPerStage[3, ], c(173.88889, 169.45263, 147.34783, 139.60563, 120.25, 125.66667, 100.2381), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR2$overallEventsPerStage[1, ], c(58, 58, 58, 58, 58, 58, 58), label = paste0("c(", paste0(resultsWithSSR2$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR2$overallEventsPerStage[2, ], c(229.71, 222.76, 213.91, 210.63265, 201.21875, 185.82828, 171.84783), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(resultsWithSSR2$overallEventsPerStage[3, ], c(403.59889, 392.21263, 361.25783, 350.23829, 321.46875, 311.49495, 272.08592), tolerance = 1e-07, label = paste0("c(", paste0(resultsWithSSR2$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR2$iterations[1, ], c(100, 100, 100, 100, 100, 100, 100), label = paste0("c(", paste0(resultsWithSSR2$iterations[1, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR2$iterations[2, ], c(100, 100, 100, 98, 96, 99, 92), label = paste0("c(", paste0(resultsWithSSR2$iterations[2, ], collapse = ", "), ")"))
expect_equal(resultsWithSSR2$iterations[3, ], c(99, 95, 92, 71, 60, 45, 21), label = paste0("c(", paste0(resultsWithSSR2$iterations[3, ], collapse = ", "), ")"))
@@ -2551,8 +2551,8 @@ test_that("'getSimulationSurvival': Perform recalculation of number of events ba
expect_equal(resultsWithSSR2CodeBased$studyDuration, resultsWithSSR2$studyDuration, tolerance = 1e-07)
expect_equal(resultsWithSSR2CodeBased$eventsNotAchieved, resultsWithSSR2$eventsNotAchieved, tolerance = 1e-07)
expect_equal(resultsWithSSR2CodeBased$numberOfSubjects, resultsWithSSR2$numberOfSubjects, tolerance = 1e-07)
- expect_equal(resultsWithSSR2CodeBased$singleEventsPerStage, resultsWithSSR2$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(resultsWithSSR2CodeBased$cumulativeEventsPerStage, resultsWithSSR2$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(resultsWithSSR2CodeBased$eventsPerStage, resultsWithSSR2$eventsPerStage, tolerance = 1e-07)
+ expect_equal(resultsWithSSR2CodeBased$overallEventsPerStage, resultsWithSSR2$overallEventsPerStage, tolerance = 1e-07)
expect_equal(resultsWithSSR2CodeBased$iterations, resultsWithSSR2$iterations, tolerance = 1e-07)
expect_equal(resultsWithSSR2CodeBased$overallReject, resultsWithSSR2$overallReject, tolerance = 1e-07)
expect_equal(resultsWithSSR2CodeBased$rejectPerStage, resultsWithSSR2$rejectPerStage, tolerance = 1e-07)
@@ -2720,8 +2720,8 @@ test_that("'getSimulationSurvival': Confirm that different inputs of lambda, med
expect_equal(x2$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x2$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x2$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x2$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x2$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x2$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x2$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x2$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x2$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x2$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -2763,8 +2763,8 @@ test_that("'getSimulationSurvival': Confirm that different inputs of lambda, med
expect_equal(x3$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x3$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x3$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x3$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x3$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x3$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x3$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x3$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x3$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x3$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -2805,8 +2805,8 @@ test_that("'getSimulationSurvival': Confirm that different inputs of lambda, med
expect_equal(x4$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x4$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x4$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x4$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x4$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x4$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x4$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x4$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x4$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x4$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -2848,8 +2848,8 @@ test_that("'getSimulationSurvival': Confirm that different inputs of lambda, med
expect_equal(x5$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x5$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x5$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x5$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x5$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x5$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x5$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x5$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x5$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x5$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -2891,8 +2891,8 @@ test_that("'getSimulationSurvival': Confirm that different inputs of lambda, med
expect_equal(x6$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x6$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x6$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x6$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x6$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x6$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x6$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x6$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x6$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x6$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -2934,8 +2934,8 @@ test_that("'getSimulationSurvival': Confirm that different inputs of lambda, med
expect_equal(x7$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x7$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x7$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x7$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x7$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x7$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x7$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x7$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x7$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x7$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -3006,8 +3006,8 @@ test_that("'getSimulationSurvival': Confirm that different definitions of delaye
expect_equal(x2$numberOfSubjects[1, ], x1$numberOfSubjects[1, ], tolerance = 1e-07)
expect_equal(x2$numberOfSubjects1[1, ], x1$numberOfSubjects1[1, ], tolerance = 1e-07)
expect_equal(x2$numberOfSubjects2[1, ], x1$numberOfSubjects2[1, ], tolerance = 1e-07)
- expect_equal(x2$singleEventsPerStage[1, ], x1$singleEventsPerStage[1, ])
- expect_equal(x2$cumulativeEventsPerStage[1, ], x1$cumulativeEventsPerStage[1, ])
+ expect_equal(x2$eventsPerStage[1, ], x1$eventsPerStage[1, ])
+ expect_equal(x2$overallEventsPerStage[1, ], x1$overallEventsPerStage[1, ])
expect_equal(x2$expectedNumberOfSubjects, x1$expectedNumberOfSubjects, tolerance = 1e-07)
expect_equal(x2$rejectPerStage[1, ], x1$rejectPerStage[1, ], tolerance = 1e-07)
expect_equal(x2$overallReject, x1$overallReject, tolerance = 1e-07)
@@ -3065,12 +3065,12 @@ test_that("'getSimulationSurvival': Confirm that the function works correctly wi
expect_equal(simResults$numberOfSubjects[1, ], c(198.3, 183, 190.8), tolerance = 1e-07, label = paste0("c(", paste0(simResults$numberOfSubjects[1, ], collapse = ", "), ")"))
expect_equal(simResults$numberOfSubjects[2, ], c(260, 256, 260), label = paste0("c(", paste0(simResults$numberOfSubjects[2, ], collapse = ", "), ")"))
expect_equal(simResults$numberOfSubjects[3, ], c(260, 260, 260), label = paste0("c(", paste0(simResults$numberOfSubjects[3, ], collapse = ", "), ")"))
- expect_equal(simResults$singleEventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simResults$singleEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simResults$singleEventsPerStage[2, ], c(85.333333, 64.833333, 77), tolerance = 1e-07, label = paste0("c(", paste0(simResults$singleEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simResults$singleEventsPerStage[3, ], c(69.2, 57.8, 100), tolerance = 1e-07, label = paste0("c(", paste0(simResults$singleEventsPerStage[3, ], collapse = ", "), ")"))
- expect_equal(simResults$cumulativeEventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simResults$cumulativeEventsPerStage[1, ], collapse = ", "), ")"))
- expect_equal(simResults$cumulativeEventsPerStage[2, ], c(105.33333, 84.833333, 97), tolerance = 1e-07, label = paste0("c(", paste0(simResults$cumulativeEventsPerStage[2, ], collapse = ", "), ")"))
- expect_equal(simResults$cumulativeEventsPerStage[3, ], c(174.53333, 142.63333, 197), tolerance = 1e-07, label = paste0("c(", paste0(simResults$cumulativeEventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simResults$eventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simResults$eventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simResults$eventsPerStage[2, ], c(85.333333, 64.833333, 77), tolerance = 1e-07, label = paste0("c(", paste0(simResults$eventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simResults$eventsPerStage[3, ], c(69.2, 57.8, 100), tolerance = 1e-07, label = paste0("c(", paste0(simResults$eventsPerStage[3, ], collapse = ", "), ")"))
+ expect_equal(simResults$overallEventsPerStage[1, ], c(20, 20, 20), label = paste0("c(", paste0(simResults$overallEventsPerStage[1, ], collapse = ", "), ")"))
+ expect_equal(simResults$overallEventsPerStage[2, ], c(105.33333, 84.833333, 97), tolerance = 1e-07, label = paste0("c(", paste0(simResults$overallEventsPerStage[2, ], collapse = ", "), ")"))
+ expect_equal(simResults$overallEventsPerStage[3, ], c(174.53333, 142.63333, 197), tolerance = 1e-07, label = paste0("c(", paste0(simResults$overallEventsPerStage[3, ], collapse = ", "), ")"))
expect_equal(simResults$iterations[1, ], c(10, 10, 10), label = paste0("c(", paste0(simResults$iterations[1, ], collapse = ", "), ")"))
expect_equal(simResults$iterations[2, ], c(6, 6, 4), label = paste0("c(", paste0(simResults$iterations[2, ], collapse = ", "), ")"))
expect_equal(simResults$iterations[3, ], c(5, 5, 2), label = paste0("c(", paste0(simResults$iterations[3, ], collapse = ", "), ")"))
@@ -3103,8 +3103,8 @@ test_that("'getSimulationSurvival': Confirm that the function works correctly wi
expect_equal(simResultsCodeBased$studyDuration, simResults$studyDuration, tolerance = 1e-07)
expect_equal(simResultsCodeBased$eventsNotAchieved, simResults$eventsNotAchieved, tolerance = 1e-07)
expect_equal(simResultsCodeBased$numberOfSubjects, simResults$numberOfSubjects, tolerance = 1e-07)
- expect_equal(simResultsCodeBased$singleEventsPerStage, simResults$singleEventsPerStage, tolerance = 1e-07)
- expect_equal(simResultsCodeBased$cumulativeEventsPerStage, simResults$cumulativeEventsPerStage, tolerance = 1e-07)
+ expect_equal(simResultsCodeBased$eventsPerStage, simResults$eventsPerStage, tolerance = 1e-07)
+ expect_equal(simResultsCodeBased$overallEventsPerStage, simResults$overallEventsPerStage, tolerance = 1e-07)
expect_equal(simResultsCodeBased$iterations, simResults$iterations, tolerance = 1e-07)
expect_equal(simResultsCodeBased$overallReject, simResults$overallReject, tolerance = 1e-07)
expect_equal(simResultsCodeBased$rejectPerStage, simResults$rejectPerStage, tolerance = 1e-07)
diff --git a/tests/testthat/test-f_simulation_calc_subjects_function.R b/tests/testthat/test-f_simulation_calc_subjects_function.R
index 1cb8dc64..3cd01d88 100644
--- a/tests/testthat/test-f_simulation_calc_subjects_function.R
+++ b/tests/testthat/test-f_simulation_calc_subjects_function.R
@@ -15,13 +15,14 @@
## |
## | File name: test-f_simulation_calc_subjects_function.R
## | Creation date: 23 February 2024, 12:20:41
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7928 $
+## | Last changed: $Date: 2024-05-23 16:35:16 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
test_plan_section("Testing user defined 'calc subjects/events functions'")
+
test_that("Function .getCalcSubjectsFunctionCppCode works for C++ code", {
.skipTestIfDisabled()
diff --git a/tests/testthat/test-f_simulation_enrichment_survival.R b/tests/testthat/test-f_simulation_enrichment_survival.R
index d372c84d..319fa4af 100644
--- a/tests/testthat/test-f_simulation_enrichment_survival.R
+++ b/tests/testthat/test-f_simulation_enrichment_survival.R
@@ -15,9 +15,9 @@
## |
## | File name: test-f_simulation_enrichment_survival.R
## | Creation date: 08 November 2023, 09:11:32
-## | File version: $Revision: 7662 $
-## | Last changed: $Date: 2024-02-23 12:42:26 +0100 (Fr, 23 Feb 2024) $
-## | Last changed by: $Author: pahlke $
+## | File version: $Revision$
+## | Last changed: $Date$
+## | Last changed by: $Author$
## |
test_plan_section("Testing Simulation Enrichment Survival Function")
diff --git a/tests/testthat/test-f_simulation_multiarm_means.R b/tests/testthat/test-f_simulation_multiarm_means.R
index 77458156..01ab4ae7 100644
--- a/tests/testthat/test-f_simulation_multiarm_means.R
+++ b/tests/testthat/test-f_simulation_multiarm_means.R
@@ -1408,7 +1408,7 @@ test_that("'getSimulationMultiArmMeans': using selectArmsFunction", {
# @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
# @refFS[Formula]{fs:adjustedPValueSubsetSidak}
# @refFS[Formula]{fs:adjustedPValueSubsetSimes}
- selectArmsFunctionSimulationMultiArmMeans <- function(effectSizes) {
+ selectArmsFunctionSimulationMultiArmMeans <- function(effectVector) {
return(c(TRUE, FALSE, FALSE, FALSE))
}
diff --git a/tests/testthat/test-f_simulation_multiarm_rates.R b/tests/testthat/test-f_simulation_multiarm_rates.R
index 83a51e01..3c1bcd27 100644
--- a/tests/testthat/test-f_simulation_multiarm_rates.R
+++ b/tests/testthat/test-f_simulation_multiarm_rates.R
@@ -1424,7 +1424,7 @@ test_that("'getSimulationMultiArmRates': using selectArmsFunction", {
# @refFS[Formula]{fs:simulationMultiArmSelections}
# @refFS[Formula]{fs:multiarmRejectionRule}
# @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- selectArmsFunctionSimulationMultiArmRates <- function(effectSizes) {
+ selectArmsFunctionSimulationMultiArmRates <- function(effectVector) {
return(c(TRUE, FALSE, FALSE, FALSE))
}
diff --git a/tests/testthat/test-f_simulation_multiarm_survival.R b/tests/testthat/test-f_simulation_multiarm_survival.R
index 84813cb0..e8967463 100644
--- a/tests/testthat/test-f_simulation_multiarm_survival.R
+++ b/tests/testthat/test-f_simulation_multiarm_survival.R
@@ -15,8 +15,8 @@
## |
## | File name: test-f_simulation_multiarm_survival.R
## | Creation date: 09 February 2024, 10:57:46
-## | File version: $Revision: 7665 $
-## | Last changed: $Date: 2024-02-23 17:33:46 +0100 (Fr, 23 Feb 2024) $
+## | File version: $Revision: 7920 $
+## | Last changed: $Date: 2024-05-23 13:56:24 +0200 (Do, 23 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -1433,7 +1433,7 @@ test_that("'getSimulationMultiArmSurvival': using selectArmsFunction", {
# @refFS[Formula]{fs:simulationMultiArmSelections}
# @refFS[Formula]{fs:multiarmRejectionRule}
# @refFS[Formula]{fs:adjustedPValueSubsetDunnett}
- selectArmsFunctionSimulationMultiArmSurvival <- function(effectSizes) {
+ selectArmsFunctionSimulationMultiArmSurvival <- function(effectVector) {
return(c(TRUE, FALSE, FALSE, FALSE))
}
@@ -1626,7 +1626,7 @@ test_that("'getSimulationMultiArmSurvival': comparison of base and multi-arm, in
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$cumulativeEventsPerStage - x$cumulativeEventsPerStage[, , 1], 1)
+ 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, ]))
@@ -1694,7 +1694,7 @@ test_that("'getSimulationMultiArmSurvival': comparison of base and multi-arm, Fi
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$cumulativeEventsPerStage - x$cumulativeEventsPerStage[, , 1], 1)
+ 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, ]))
@@ -1764,7 +1764,7 @@ test_that("'getSimulationMultiArmSurvival': comparison of base and multi-arm, in
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$cumulativeEventsPerStage - x$cumulativeEventsPerStage[, , 1], 1)
+ 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, ]))
diff --git a/tests/testthat/test-f_simulation_performance_score.R b/tests/testthat/test-f_simulation_performance_score.R
index 56ed2d40..8531fee9 100644
--- a/tests/testthat/test-f_simulation_performance_score.R
+++ b/tests/testthat/test-f_simulation_performance_score.R
@@ -15,8 +15,8 @@
## |
## | File name: test-f_simulation_performance_score.R
## | Creation date: 06 February 2023, 12:14:51
-## | File version: $Revision: 7742 $
-## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $
+## | File version: $Revision: 7905 $
+## | Last changed: $Date: 2024-05-21 17:15:42 +0200 (Di, 21 Mai 2024) $
## | Last changed by: $Author: pahlke $
## |
@@ -71,13 +71,6 @@ test_that("getPerformanceScore handles SimulationResultsMeans", {
)
})
-# Test for a simulationResult that does not have `bindingFutility = TRUE`
-test_that("getPerformanceScore handles non-binding futility", {
- simulationResult <- createCorrectSimulationResultObject("SimulationResultsMeans")
- simulationResult$.design$bindingFutility <- FALSE
- expect_warning(getPerformanceScore(simulationResult))
-})
-
# Test for a simulationResult that does not have `kMax = 2`
test_that("getPerformanceScore handles non-two-stage designs", {
simulationResult <- createCorrectSimulationResultObject("SimulationResultsMeans")
@@ -102,15 +95,6 @@ test_that("getPerformanceScore calculates performance score correctly", {
expect_type(scores, "environment")
})
-# Test to verify that the warning about the function being experimental is issued
-test_that("getPerformanceScore issues warning", {
- simulationResult <- createCorrectSimulationResultObject("SimulationResultsMeans")
- expect_warning(
- getPerformanceScore(simulationResult),
- "The performance score function is experimental and hence not fully validated"
- )
-})
-
# Test to check if the correct values are returned
test_that("getPerformanceScore returns correct result object", {
simulationResult <- createCorrectSimulationResultObject("SimulationResultsMeans")