Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: gsDesign
Version: 3.9.0.9005
Version: 3.9.0.9006
Title: Group Sequential Design
Authors@R: c(
person("Keaven", "Anderson", email = "keaven_anderson@merck.com", role = c("aut", "cre")),
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
- `simBinomialSeasonalExact()` now supports `usTime`/`lsTime` inputs and
reports futility stopping probabilities (`futility_stop_rate` with
`futility_mc_se`) in scenario summaries.
- `simBinomialSeasonalExact()` now accepts `ve = 0` and `ve < 0`, allowing
null-hypothesis (`ve = 0`) and non-inferiority margin (`ve < 0`) scenarios.
Validation now requires only that `ve` values are finite and less than 1.
A feasibility check verifies that the implied experimental-arm event rates
(`control_event_rate * (1 - ve)`) remain in `[0, 1)` (#267).

## Bug fixes

Expand Down
13 changes: 10 additions & 3 deletions R/simBinomialSeasonalExact.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
#'
#' @param gsD A `gsSurv` object with `test.type` 1 or 4.
#' @param ve Numeric vector of vaccine efficacy (or prevention efficacy)
#' scenarios to simulate.
#' scenarios to simulate. Each value must be finite and less than 1.
#' `ve = 0` corresponds to equal event rates (superiority null); `ve < 0`
#' corresponds to experimental-arm event rates above control (non-inferiority
#' margin or harmful scenarios).
#' @param nsim Integer scalar or vector giving the number of simulations per
#' element of `ve`.
#' @param control_event_rate Numeric scalar or vector with control seasonal
Expand Down Expand Up @@ -105,8 +108,8 @@ simBinomialSeasonalExact <- function(
if (!(gsD$test.type %in% c(1, 4))) {
stop("gsD$test.type must be 1 or 4", call. = FALSE)
}
if (!is.numeric(ve) || length(ve) < 1 || any(!is.finite(ve)) || any(ve <= 0) || any(ve >= 1)) {
stop("ve must be a numeric vector with values strictly between 0 and 1", call. = FALSE)
if (!is.numeric(ve) || length(ve) < 1 || any(!is.finite(ve)) || any(ve >= 1)) {
stop("ve must be a numeric vector with finite values less than 1", call. = FALSE)
}
if (!is.numeric(season_length) || length(season_length) != 1 || !is.finite(season_length) || season_length <= 0) {
stop("season_length must be a positive scalar", call. = FALSE)
Expand Down Expand Up @@ -146,6 +149,10 @@ simBinomialSeasonalExact <- function(
any(!is.finite(control_event_rate)) || any(control_event_rate <= 0) || any(control_event_rate >= 1)) {
stop("control_event_rate must be a scalar or vector in (0, 1) with one value per ve scenario", call. = FALSE)
}
experimental_event_rate <- control_event_rate * (1 - ve)
if (any(experimental_event_rate < 0) || any(experimental_event_rate >= 1)) {
stop("ve and control_event_rate imply experimental event rates outside [0, 1)", call. = FALSE)
}

if (!is.logical(adaptive) || length(adaptive) < 1 || any(is.na(adaptive))) {
stop("adaptive must be a logical vector with at least one value", call. = FALSE)
Expand Down
12 changes: 11 additions & 1 deletion tests/testthat/test-independent-test-simBinomialSeasonalExact.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ test_that("simBinomialSeasonalExact validates core inputs", {

expect_error(
simBinomialSeasonalExact(gsD = design, ve = c(0.3, 1)),
"strictly between 0 and 1"
"finite values less than 1"
)
expect_no_error(
simBinomialSeasonalExact(gsD = design, ve = c(0, 0.3), nsim = c(1, 1))
)
expect_no_error(
simBinomialSeasonalExact(gsD = design, ve = c(-0.1, 0, 0.3), nsim = c(1, 1, 1))
)
expect_error(
simBinomialSeasonalExact(gsD = design, ve = -10, control_event_rate = 0.5),
"experimental event rates outside"
)

expect_error(
Expand Down
Loading