From dff2ff6ce97831a3ce4873239a70cae17037a4dd Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 21 May 2024 17:38:31 +0200 Subject: [PATCH 01/71] delete helpers --- R/helpers.R | 77 ----------------------------------- tests/testthat/test-helpers.R | 13 ------ 2 files changed, 90 deletions(-) delete mode 100644 R/helpers.R delete mode 100644 tests/testthat/test-helpers.R diff --git a/R/helpers.R b/R/helpers.R deleted file mode 100644 index 5b7b9c41..00000000 --- a/R/helpers.R +++ /dev/null @@ -1,77 +0,0 @@ -#' -#' Checking for scalar -#' -#' @param x the input -#' @return Returns \code{TRUE} if \code{x} is a length one vector -#' (i.e., a scalar) -#' -#' @keywords internal -is.scalar <- function(x) { - return(identical(length(x), 1L)) -} - - -#' Predicate checking for a boolean option -#' -#' @param x the object being checked -#' @return Returns \code{TRUE} if \code{x} is a length one logical vector (i.e., a -#' scalar) -#' -#' @keywords internal -is.bool <- function(x) { - return(is.scalar(x) && is.logical(x)) -} - -#' Predicate checking for a probability -#' -#' @param x the object being checked -#' @param bounds whether to include the bounds 0 and 1 (default) -#' @return Returns \code{TRUE} if \code{x} is a probability -#' -#' @keywords internal -is.probability <- function(x, - bounds = TRUE) { - return(is.scalar(x) && - if (bounds) { - 0 <= x && 1 >= x - } else { - 0 < x && 1 > x - }) -} - -#' Predicate checking for a probability range -#' -#' @param x the object being checked -#' @param bounds whether to include the bounds 0 and 1 (default) -#' @return Returns \code{TRUE} if \code{x} is a probability range -#' -#' @keywords internal -is.probRange <- function(x, - bounds = TRUE) { - return(identical(length(x), 2L) && - x[1] < x[2] && - if (bounds) { - 0 <= x[1] && 1 >= x[2] - } else { - 0 < x[1] && 1 > x[2] - }) -} - - -#' The Logit Function -#' -#' @description `r lifecycle::badge("experimental")` -#' -#' This just calculates the logit. -#' -#' @typed x: numeric -#' probabilities to transform. -#' @return The logit of `x`. -#' -#' @example examples/logit.R -#' @export -logit <- function(x) { - assert_numeric(x, lower = 0, upper = 1, finite = TRUE) - - stats::qlogis(x) -} diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R deleted file mode 100644 index 332acd98..00000000 --- a/tests/testthat/test-helpers.R +++ /dev/null @@ -1,13 +0,0 @@ -test_that("logit works as expected", { - probs <- seq(0, 1, length = 100) - result <- logit(probs) - expect_numeric(result, len = length(probs), sorted = TRUE, unique = TRUE) - expect_identical(result[1], -Inf) - expect_identical(result[100], Inf) -}) - -test_that("logit gives expected value for example value 0.2", { - result <- logit(0.2) - expected <- -1.386294 - expect_equal(result, expected, tolerance = 1e-4) -}) From 37561fcab0a269e17ae1253a1b676bc086e871cb Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 15:53:55 +0000 Subject: [PATCH 02/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 1 - man/is.bool.Rd | 19 ------------------- man/is.probRange.Rd | 20 -------------------- man/is.probability.Rd | 20 -------------------- man/is.scalar.Rd | 19 ------------------- man/logit.Rd | 23 ----------------------- 6 files changed, 102 deletions(-) delete mode 100644 man/is.bool.Rd delete mode 100644 man/is.probRange.Rd delete mode 100644 man/is.probability.Rd delete mode 100644 man/is.scalar.Rd delete mode 100644 man/logit.Rd diff --git a/DESCRIPTION b/DESCRIPTION index a7e3765b..bfdb50be 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,7 +52,6 @@ Collate: 'boundsPredprob.R' 'data.R' 'dbetabinom.R' - 'helpers.R' 'oc2.R' 'oc3.R' 'ocPostprob.R' diff --git a/man/is.bool.Rd b/man/is.bool.Rd deleted file mode 100644 index 23ff5261..00000000 --- a/man/is.bool.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{is.bool} -\alias{is.bool} -\title{Predicate checking for a boolean option} -\usage{ -is.bool(x) -} -\arguments{ -\item{x}{the object being checked} -} -\value{ -Returns \code{TRUE} if \code{x} is a length one logical vector (i.e., a -scalar) -} -\description{ -Predicate checking for a boolean option -} -\keyword{internal} diff --git a/man/is.probRange.Rd b/man/is.probRange.Rd deleted file mode 100644 index e27fd5f6..00000000 --- a/man/is.probRange.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{is.probRange} -\alias{is.probRange} -\title{Predicate checking for a probability range} -\usage{ -is.probRange(x, bounds = TRUE) -} -\arguments{ -\item{x}{the object being checked} - -\item{bounds}{whether to include the bounds 0 and 1 (default)} -} -\value{ -Returns \code{TRUE} if \code{x} is a probability range -} -\description{ -Predicate checking for a probability range -} -\keyword{internal} diff --git a/man/is.probability.Rd b/man/is.probability.Rd deleted file mode 100644 index c8335609..00000000 --- a/man/is.probability.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{is.probability} -\alias{is.probability} -\title{Predicate checking for a probability} -\usage{ -is.probability(x, bounds = TRUE) -} -\arguments{ -\item{x}{the object being checked} - -\item{bounds}{whether to include the bounds 0 and 1 (default)} -} -\value{ -Returns \code{TRUE} if \code{x} is a probability -} -\description{ -Predicate checking for a probability -} -\keyword{internal} diff --git a/man/is.scalar.Rd b/man/is.scalar.Rd deleted file mode 100644 index e8735c12..00000000 --- a/man/is.scalar.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{is.scalar} -\alias{is.scalar} -\title{Checking for scalar} -\usage{ -is.scalar(x) -} -\arguments{ -\item{x}{the input} -} -\value{ -Returns \code{TRUE} if \code{x} is a length one vector -(i.e., a scalar) -} -\description{ -Checking for scalar -} -\keyword{internal} diff --git a/man/logit.Rd b/man/logit.Rd deleted file mode 100644 index 3eb2ad42..00000000 --- a/man/logit.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/helpers.R -\name{logit} -\alias{logit} -\title{The Logit Function} -\usage{ -logit(x) -} -\arguments{ -\item{x}{(\code{numeric}):\cr probabilities to transform.} -} -\value{ -The logit of \code{x}. -} -\description{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} - -This just calculates the logit. -} -\examples{ -x <- seq(0.1, 0.9, 0.1) -logit(x) -} From ab9ba06d6dabefa1d0a2f9d9e7c4dd3cb1a67299 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 24 May 2024 13:48:38 +0200 Subject: [PATCH 03/71] clean --- R/boundsPostprob.R | 48 +++++++---- man/boundsPostprob.Rd | 30 ++++--- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++ tests/testthat/test-boundsPostProb.R | 28 +++++++ 4 files changed, 200 insertions(+), 27 deletions(-) create mode 100644 tests/testthat/test-boundsPostProb.R diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 09822eda..1493ec80 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -5,15 +5,11 @@ #' Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and #' Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL #' -#' @param nvec a vector of number of patients -#' @param p0 the efficacy threshold parameter in the postprob function -#' @param p1 the futility threshold parameter in the postprob function -#' (default = p0) -#' @param tL futility boundary probability threshold -#' @param tU efficacy boundary probability threshold -#' @param a the alpha parameter of the beta prior of treatment group -#' @param b the beta parameter of the beta prior of treatment group -#' @return A matrix where for each sample size in \code{nvec}, this function +#' @inheritParams postprob +#' @inheritParams ocPostprob +#' @typed nvec : numeric +#' a vector of number of patients in each look. +#' @return A matrix where for each sample size in `nvec`, this function #' returns the maximum number of responses that meet the futility #' threshold (xL), its corresponding response rate (pL), posterior probability #' (postL), upper bound of one sided 95% CI for the response rate based on an @@ -23,7 +19,19 @@ #' the lower bound of one sided 95% CI for the response rate based on exact #' binomial test (LciU). #' -#' @importFrom stats binom.test +#' A matrix for each same size in `nvec`. For each sample size, the following is returned: +#' - `xL` : the maximum number of responses that meet the futility. +#' threshold +#' - `pL` : posterior probability corresponding to `xL`. +#' - `postL`: posterior probability. +#' - `Ucil` : upper bound of one sided 95% CI for the response rate based on an +#' exact binomial test. +#' - `xU` : the minimal number of responses that meet the efficacy threshold. +#' - `pU` : the corresponding response rate. +#' - `postU` : posterior probability. +#' - `LciU` : lower bound of one sided 95% CI for the response rate based on exact +#' binomial test. +#' #' #' @example examples/boundsPostprob.R #' @export @@ -43,30 +51,36 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { k <- 0 for (n in nvec) { k <- k + 1 - # initialize so will return NA if 0 or n in "continue" region xL <- NA xU <- NA for (x in 0:n) { postp <- postprob(x, n, p1, parE = c(a, b)) if (postp <= tL) { xL <- x + postL <- postp } if (p0 != p1) { postp <- postprob(x, n, p0, parE = c(a, b)) } if (postp >= tU) { xU <- x - # done: leave innermost for loop - break + postU <- postp + break # needed ? } } - # calculate posterior probabilities at boundaries - postL <- postprob(xL, n, p1, parE = c(a, b)) - postU <- postprob(xU, n, p0, parE = c(a, b)) # calculate lower CI at boundaries UciL <- ifelse(!is.na(xL), stats::binom.test(xL, n, alt = "less")$conf.int[2], NA) LciU <- ifelse(!is.na(xU), stats::binom.test(xU, n, alt = "greater")$conf.int[1], NA) - z[k, ] <- c(xL, xL / n, postL, UciL, xU, xU / n, postU, LciU) + z[k, ] <- c( + xL, + xL / n, + postL, + UciL, + xU, + xU / n, + postU, + LciU + ) } return(round(data.frame(nvec, z), 4)) } diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 1cb2ae60..a26478ff 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -7,20 +7,15 @@ boundsPostprob(nvec, p0, p1 = p0, tL, tU, a, b) } \arguments{ -\item{nvec}{a vector of number of patients} +\item{nvec}{(\code{numeric}):\cr a vector of number of patients in each look.} -\item{p0}{the efficacy threshold parameter in the postprob function} +\item{p0}{(\code{number}):\cr lower Futility threshold of response rate.} -\item{p1}{the futility threshold parameter in the postprob function -(default = p0)} +\item{p1}{(\code{number}):\cr upper Efficacy threshold of response rate.} -\item{tL}{futility boundary probability threshold} +\item{tL}{(\code{number}):\cr posterior probability threshold for being below \code{p0}.} -\item{tU}{efficacy boundary probability threshold} - -\item{a}{the alpha parameter of the beta prior of treatment group} - -\item{b}{the beta parameter of the beta prior of treatment group} +\item{tU}{(\code{number}):\cr posterior probability threshold for being above \code{p1}.} } \value{ A matrix where for each sample size in \code{nvec}, this function @@ -32,6 +27,21 @@ the minimal number of responses that meet the efficacy threshold (xU), the corresponding response rate (pU), posterior probability (postU) and the lower bound of one sided 95\% CI for the response rate based on exact binomial test (LciU). + +A matrix for each same size in \code{nvec}. For each sample size, the following is returned: +\itemize{ +\item \code{xL} : the maximum number of responses that meet the futility. +threshold +\item \code{pL} : posterior probability corresponding to \code{xL}. +\item \code{postL}: posterior probability. +\item \code{Ucil} : upper bound of one sided 95\% CI for the response rate based on an +exact binomial test. +\item \code{xU} : the minimal number of responses that meet the efficacy threshold. +\item \code{pU} : the corresponding response rate. +\item \code{postU} : posterior probability. +\item \code{LciU} : lower bound of one sided 95\% CI for the response rate based on exact +binomial test. +} } \description{ This function is used to identify the efficacy and futility diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..fa79aa7c 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 100, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R new file mode 100644 index 00000000..0ae6eadf --- /dev/null +++ b/tests/testthat/test-boundsPostProb.R @@ -0,0 +1,28 @@ +# boundsPostProb ---- +test_that("h_decision_one_RctPredProbDist gives correct result and list when relativeDelta = TRUE", { + result <- boundsPostprob( + nvec = c(10, 20, 30, 40), + p0 = 0.2, + p1 = 0.2, + tL = 0.10, + tU = 0.90, + a = 1, + b = 1 + ) + expected <- data.frame( + list( + nvec = c(10, 20, 30, 40), + xL = c(0, 1, 2, 4), + pL = c(0, 0.05, 0.0667, 0.1), + postL = c(0.0859, 0.0576, 0.0374, 0.0664), + UciL = c(0.2589, 0.2161, 0.1953, 0.2144), + xU = c(4, 7, 9, 12), + pU = c(0.4, 0.35, 0.3, 0.3), + postU = c(0.9496, 0.9569, 0.9254, 0.9479), + LciU = c(0.15, 0.1773, 0.1663, 0.1831) + ) + ) + expect_equal(result$xL, c(0, 1, 2, 4)) + expect_equal(result$pL, c(0.0000, 0.0500, 0.0667, 0.1000)) + expect_equal(result$UciL, c(0.2589, 0.2161, 0.1953, 0.2144)) +}) From ab510302661d18d4368c4f46c358b7565a643525 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 11:51:21 +0000 Subject: [PATCH 04/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index fa79aa7c..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 100, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 008502dd2c31565eb6ea5e1942897da76afe4102 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 24 May 2024 14:00:43 +0200 Subject: [PATCH 05/71] clean --- R/boundsPostprob.R | 13 +++++++------ man/boundsPostprob.Rd | 13 ++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 1493ec80..f1f32fc8 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -5,6 +5,9 @@ #' Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and #' Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL #' +#' Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and +#' Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL +#' #' @inheritParams postprob #' @inheritParams ocPostprob #' @typed nvec : numeric @@ -22,20 +25,18 @@ #' A matrix for each same size in `nvec`. For each sample size, the following is returned: #' - `xL` : the maximum number of responses that meet the futility. #' threshold -#' - `pL` : posterior probability corresponding to `xL`. -#' - `postL`: posterior probability. +#' - `pL` : response rate corresponding to `xL`. +#' - `postL`: posterior probability corresponding to `xL`. #' - `Ucil` : upper bound of one sided 95% CI for the response rate based on an #' exact binomial test. #' - `xU` : the minimal number of responses that meet the efficacy threshold. -#' - `pU` : the corresponding response rate. -#' - `postU` : posterior probability. +#' - `pU` : response rate corresponding to `xU`. +#' - `postU` : posterior probability corresponding to `xU`. #' - `LciU` : lower bound of one sided 95% CI for the response rate based on exact #' binomial test. #' -#' #' @example examples/boundsPostprob.R #' @export -#' @keywords graphics boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { z <- matrix(NA, length(nvec), 6) dimnames(z) <- list(nvec, c( diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index a26478ff..860636e2 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -32,13 +32,13 @@ A matrix for each same size in \code{nvec}. For each sample size, the following \itemize{ \item \code{xL} : the maximum number of responses that meet the futility. threshold -\item \code{pL} : posterior probability corresponding to \code{xL}. -\item \code{postL}: posterior probability. +\item \code{pL} : response rate corresponding to \code{xL}. +\item \code{postL}: posterior probability corresponding to \code{xL}. \item \code{Ucil} : upper bound of one sided 95\% CI for the response rate based on an exact binomial test. \item \code{xU} : the minimal number of responses that meet the efficacy threshold. -\item \code{pU} : the corresponding response rate. -\item \code{postU} : posterior probability. +\item \code{pU} : response rate corresponding to \code{xU}. +\item \code{postU} : posterior probability corresponding to \code{xU}. \item \code{LciU} : lower bound of one sided 95\% CI for the response rate based on exact binomial test. } @@ -49,6 +49,10 @@ boundaries based on posterior probabilities, i.e.: Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL } +\details{ +Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and +Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL +} \examples{ ## 40 pts trial with interim looks after each 10 pts., ## efficacy decision if more than 90\% probability to be above 20\% ORR, @@ -61,4 +65,3 @@ boundsPostprob( ## From this we see e.g. that at the third IA at 30 pts, we would stop for futility ## if 5 or less patients responded, and for efficacy if 9 or more pts responded. } -\keyword{graphics} From 34a2313c0cb2011300a200919c1f8e2e929229e1 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 24 May 2024 14:51:35 +0200 Subject: [PATCH 06/71] empty From 0cd95a75ad572ad32d77147a31485cac1156703e Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 26 May 2024 18:08:04 +0200 Subject: [PATCH 07/71] examples and test there --- R/boundsPostprob.R | 37 +++----- examples/boundsPostprob.R | 14 ++-- man/boundsPostprob.Rd | 34 +++----- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++ tests/testthat/test-boundsPostProb.R | 31 ++++--- 5 files changed, 167 insertions(+), 70 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index f1f32fc8..f7b5415d 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -1,28 +1,16 @@ #' Decision cutpoints for boundary (based on posterior probability) #' #' This function is used to identify the efficacy and futility -#' boundaries based on posterior probabilities, i.e.: -#' Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and -#' Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL +#' boundaries based on the following rules: #' -#' Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and -#' Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL +#' Efficacy boundary: find minimum x (xU) where Pr(P > p1 |x, n, a, b) >= tU and +#' Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL #' #' @inheritParams postprob #' @inheritParams ocPostprob #' @typed nvec : numeric -#' a vector of number of patients in each look. -#' @return A matrix where for each sample size in `nvec`, this function -#' returns the maximum number of responses that meet the futility -#' threshold (xL), its corresponding response rate (pL), posterior probability -#' (postL), upper bound of one sided 95% CI for the response rate based on an -#' exact binomial test (UciL), and the same boundary parameters for efficacy: -#' the minimal number of responses that meet the efficacy threshold (xU), -#' the corresponding response rate (pU), posterior probability (postU) and -#' the lower bound of one sided 95% CI for the response rate based on exact -#' binomial test (LciU). -#' -#' A matrix for each same size in `nvec`. For each sample size, the following is returned: +#' A vector of number of patients in each look. +#' @return A matrix for each same size in `nvec`. For each sample size, the following is returned: #' - `xL` : the maximum number of responses that meet the futility. #' threshold #' - `pL` : response rate corresponding to `xL`. @@ -52,21 +40,20 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { k <- 0 for (n in nvec) { k <- k + 1 + # initialize so will return NA if 0 or n in "continue" region xL <- NA xU <- NA for (x in 0:n) { - postp <- postprob(x, n, p1, parE = c(a, b)) - if (postp <= tL) { - xL <- x + postp <- 1 - postprob(x, n, p0, parE = c(a, b)) # futility look + if (postp >= tL) { postL <- postp + xL <- x } - if (p0 != p1) { - postp <- postprob(x, n, p0, parE = c(a, b)) - } + postp <- postprob(x, n, p0, parE = c(a, b)) # efficacy look if (postp >= tU) { - xU <- x postU <- postp - break # needed ? + xU <- x + break } } # calculate lower CI at boundaries diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index 97491a9f..f4377968 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -1,10 +1,8 @@ -## 40 pts trial with interim looks after each 10 pts., -## efficacy decision if more than 90% probability to be above 20% ORR, -## futility decision if less than 10% probability to be above 20% ORR, -## with uniform prior (i.e. beta(1, 1)) on the ORR: +# 40 pts trial with interim looks after each 10 pts., +# Efficacy decision if more than 60% probability to be above 20% ORR, +# Futility decision if less than 60% probability to be below 20% ORR, +# with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( - nvec = c(10, 20, 30, 40), p0 = 0.20, - tL = 0.10, tU = 0.90, a = 1, b = 1 + nvec = c(10, 20, 30, 40), p0 = 0.20, p1 = 0.2, + tL = 0.60, tU = 0.60, a = 1, b = 1 ) -## From this we see e.g. that at the third IA at 30 pts, we would stop for futility -## if 5 or less patients responded, and for efficacy if 9 or more pts responded. diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 860636e2..b405a75c 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -7,7 +7,7 @@ boundsPostprob(nvec, p0, p1 = p0, tL, tU, a, b) } \arguments{ -\item{nvec}{(\code{numeric}):\cr a vector of number of patients in each look.} +\item{nvec}{(\code{numeric}):\cr A vector of number of patients in each look.} \item{p0}{(\code{number}):\cr lower Futility threshold of response rate.} @@ -18,16 +18,6 @@ boundsPostprob(nvec, p0, p1 = p0, tL, tU, a, b) \item{tU}{(\code{number}):\cr posterior probability threshold for being above \code{p1}.} } \value{ -A matrix where for each sample size in \code{nvec}, this function -returns the maximum number of responses that meet the futility -threshold (xL), its corresponding response rate (pL), posterior probability -(postL), upper bound of one sided 95\% CI for the response rate based on an -exact binomial test (UciL), and the same boundary parameters for efficacy: -the minimal number of responses that meet the efficacy threshold (xU), -the corresponding response rate (pU), posterior probability (postU) and -the lower bound of one sided 95\% CI for the response rate based on exact -binomial test (LciU). - A matrix for each same size in \code{nvec}. For each sample size, the following is returned: \itemize{ \item \code{xL} : the maximum number of responses that meet the futility. @@ -45,23 +35,19 @@ binomial test. } \description{ This function is used to identify the efficacy and futility -boundaries based on posterior probabilities, i.e.: -Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and -Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL +boundaries based on the following rules: } \details{ -Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and -Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL +Efficacy boundary: find minimum x (xU) where Pr(P > p1 |x, n, a, b) >= tU and +Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL } \examples{ -## 40 pts trial with interim looks after each 10 pts., -## efficacy decision if more than 90\% probability to be above 20\% ORR, -## futility decision if less than 10\% probability to be above 20\% ORR, -## with uniform prior (i.e. beta(1, 1)) on the ORR: +# 40 pts trial with interim looks after each 10 pts., +# Efficacy decision if more than 60\% probability to be above 20\% ORR, +# Futility decision if less than 60\% probability to be below 20\% ORR, +# with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( - nvec = c(10, 20, 30, 40), p0 = 0.20, - tL = 0.10, tU = 0.90, a = 1, b = 1 + nvec = c(10, 20, 30, 40), p0 = 0.20, p1 = 0.2, + tL = 0.60, tU = 0.60, a = 1, b = 1 ) -## From this we see e.g. that at the third IA at 30 pts, we would stop for futility -## if 5 or less patients responded, and for efficacy if 9 or more pts responded. } diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..fa79aa7c 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 100, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index 0ae6eadf..ccbc3458 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -4,25 +4,30 @@ test_that("h_decision_one_RctPredProbDist gives correct result and list when rel nvec = c(10, 20, 30, 40), p0 = 0.2, p1 = 0.2, - tL = 0.10, - tU = 0.90, + tL = 0.60, + tU = 0.60, a = 1, b = 1 ) expected <- data.frame( list( nvec = c(10, 20, 30, 40), - xL = c(0, 1, 2, 4), - pL = c(0, 0.05, 0.0667, 0.1), - postL = c(0.0859, 0.0576, 0.0374, 0.0664), - UciL = c(0.2589, 0.2161, 0.1953, 0.2144), - xU = c(4, 7, 9, 12), - pU = c(0.4, 0.35, 0.3, 0.3), - postU = c(0.9496, 0.9569, 0.9254, 0.9479), - LciU = c(0.15, 0.1773, 0.1663, 0.1831) + xL = c(1, 3, 5, 6), + pL = c(0.1, 0.15, 0.1667, 0.15), + postL = c(0.6779, 0.6296, 0.6069, 0.739), + UciL = c(0.3942, 0.3437, 0.319, 0.2747), + xU = c(2, 5, 7, 9), + pU = c(0.2, 0.25, 0.2333, 0.225), + postU = c(0.6174, 0.7693, 0.73, 0.704), + LciU = c(0.0368, 0.1041, 0.115, 0.1227) ) ) - expect_equal(result$xL, c(0, 1, 2, 4)) - expect_equal(result$pL, c(0.0000, 0.0500, 0.0667, 0.1000)) - expect_equal(result$UciL, c(0.2589, 0.2161, 0.1953, 0.2144)) + expect_equal(result$xL, c(1, 3, 5, 6)) + expect_equal(result$pL, c(0.1, 0.15, 0.1667, 0.15)) + expect_equal(result$postL, c(0.6779, 0.6296, 0.6069, 0.739)) + expect_equal(result$UciL, c(0.3942, 0.3437, 0.319, 0.2747)) + expect_equal(result$xU, c(2, 5, 7, 9)) + expect_equal(result$pU, c(0.2, 0.25, 0.2333, 0.225)) + expect_equal(result$postU, c(0.6174, 0.7693, 0.73, 0.704)) + expect_equal(result$LciU, c(0.0368, 0.1041, 0.115, 0.1227)) }) From 51db59a10385b06a25807d86c7984374f14a9d28 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 16:10:51 +0000 Subject: [PATCH 08/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index fa79aa7c..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 100, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From df9a7cacba18258425b9e91e57af6ef286e051f3 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 26 May 2024 18:13:31 +0200 Subject: [PATCH 09/71] clean --- R/boundsPostprob.R | 1 - man/boundsPostprob.Rd | 2 -- tests/testthat/test-boundsPostProb.R | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index f7b5415d..617d3095 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -2,7 +2,6 @@ #' #' This function is used to identify the efficacy and futility #' boundaries based on the following rules: -#' #' Efficacy boundary: find minimum x (xU) where Pr(P > p1 |x, n, a, b) >= tU and #' Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL #' diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index b405a75c..4488c20d 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -36,8 +36,6 @@ binomial test. \description{ This function is used to identify the efficacy and futility boundaries based on the following rules: -} -\details{ Efficacy boundary: find minimum x (xU) where Pr(P > p1 |x, n, a, b) >= tU and Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL } diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index ccbc3458..cbc28b7b 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -1,5 +1,5 @@ # boundsPostProb ---- -test_that("h_decision_one_RctPredProbDist gives correct result and list when relativeDelta = TRUE", { +test_that("boundsPostProb gives correct result and list", { result <- boundsPostprob( nvec = c(10, 20, 30, 40), p0 = 0.2, From bd327cc140ad1750c5edd26c1a8915c10edde5f7 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 26 May 2024 18:14:56 +0200 Subject: [PATCH 10/71] NAMESPACE stuff --- NAMESPACE | 1 - man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 3af942e9..9b572e48 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,7 +6,6 @@ export(dbetaMix) export(dbetabinom) export(dbetabinomMix) export(dbetadiff) -export(logit) export(myPlot) export(myPlotDiff) export(oc2) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..fa79aa7c 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 100, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From e25e4fd3df8e84bfc647c591ff9cbe9237a5dd7f Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Sun, 26 May 2024 16:17:30 +0000 Subject: [PATCH 11/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index fa79aa7c..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 100, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From c6ec5cc4851db079b1edb3a8e15fdaa3ebb10098 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 27 May 2024 12:08:37 +0200 Subject: [PATCH 12/71] empty From fe22df674048ba24a13c9d07195b58dfdec8e804 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 27 May 2024 14:14:43 +0200 Subject: [PATCH 13/71] add rmarkdown to DESCRIPTIOPM --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index bfdb50be..6fd25763 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,6 +22,7 @@ BugReports: https://github.com/genentech/phase1b/issues Depends: R (>= 3.6) Suggests: + rmarkdown, knitr, officer, shiny, From 95a6080e5eb1a143a6e57db3d2042451c4fd6e40 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 27 May 2024 15:27:51 +0200 Subject: [PATCH 14/71] clean --- DESCRIPTION | 2 + R/boundsPostprob.R | 16 ++-- man/boundsPostprob.Rd | 4 +- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++ tests/testthat/test-boundsPostProb.R | 8 +- 5 files changed, 137 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a7e3765b..7f3faddd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,6 +22,8 @@ BugReports: https://github.com/genentech/phase1b/issues Depends: R (>= 3.6) Suggests: + rmarkdown, + bookdown, knitr, officer, shiny, diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 617d3095..b50fee96 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -14,12 +14,12 @@ #' threshold #' - `pL` : response rate corresponding to `xL`. #' - `postL`: posterior probability corresponding to `xL`. -#' - `Ucil` : upper bound of one sided 95% CI for the response rate based on an +#' - `pL_upper_ci` : upper bound of one sided 95% CI for the response rate `pL` based on an #' exact binomial test. #' - `xU` : the minimal number of responses that meet the efficacy threshold. #' - `pU` : response rate corresponding to `xU`. #' - `postU` : posterior probability corresponding to `xU`. -#' - `LciU` : lower bound of one sided 95% CI for the response rate based on exact +#' - `pU_lower_ci` : lower bound of one sided 95% CI for the response rate `pU` based on exact #' binomial test. #' #' @example examples/boundsPostprob.R @@ -31,8 +31,8 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { "xU", "pU", "postU" )) znames <- c( - "xL", "pL", "postL", "UciL", - "xU", "pU", "postU", "LciU" + "xL", "pL", "postL", "pL_upper_ci", + "xU", "pU", "postU", "pU_lower_ci" ) z <- matrix(NA, length(nvec), length(znames)) dimnames(z) <- list(nvec, znames) @@ -56,17 +56,17 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { } } # calculate lower CI at boundaries - UciL <- ifelse(!is.na(xL), stats::binom.test(xL, n, alt = "less")$conf.int[2], NA) - LciU <- ifelse(!is.na(xU), stats::binom.test(xU, n, alt = "greater")$conf.int[1], NA) + pL_upper_ci <- ifelse(!is.na(xL), stats::binom.test(xL, n, alt = "less")$conf.int[2], NA) + pU_lower_ci <- ifelse(!is.na(xU), stats::binom.test(xU, n, alt = "greater")$conf.int[1], NA) z[k, ] <- c( xL, xL / n, postL, - UciL, + pL_upper_ci, xU, xU / n, postU, - LciU + pU_lower_ci ) } return(round(data.frame(nvec, z), 4)) diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 4488c20d..4394ef94 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -24,12 +24,12 @@ A matrix for each same size in \code{nvec}. For each sample size, the following threshold \item \code{pL} : response rate corresponding to \code{xL}. \item \code{postL}: posterior probability corresponding to \code{xL}. -\item \code{Ucil} : upper bound of one sided 95\% CI for the response rate based on an +\item \code{pL_upper_ci} : upper bound of one sided 95\% CI for the response rate \code{pL} based on an exact binomial test. \item \code{xU} : the minimal number of responses that meet the efficacy threshold. \item \code{pU} : response rate corresponding to \code{xU}. \item \code{postU} : posterior probability corresponding to \code{xU}. -\item \code{LciU} : lower bound of one sided 95\% CI for the response rate based on exact +\item \code{pU_lower_ci} : lower bound of one sided 95\% CI for the response rate \code{pU} based on exact binomial test. } } diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..fa79aa7c 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 100, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index cbc28b7b..3d74d3bc 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -15,19 +15,19 @@ test_that("boundsPostProb gives correct result and list", { xL = c(1, 3, 5, 6), pL = c(0.1, 0.15, 0.1667, 0.15), postL = c(0.6779, 0.6296, 0.6069, 0.739), - UciL = c(0.3942, 0.3437, 0.319, 0.2747), + pL_upper_ci = c(0.3942, 0.3437, 0.319, 0.2747), xU = c(2, 5, 7, 9), pU = c(0.2, 0.25, 0.2333, 0.225), postU = c(0.6174, 0.7693, 0.73, 0.704), - LciU = c(0.0368, 0.1041, 0.115, 0.1227) + pU_lower_ci = c(0.0368, 0.1041, 0.115, 0.1227) ) ) expect_equal(result$xL, c(1, 3, 5, 6)) expect_equal(result$pL, c(0.1, 0.15, 0.1667, 0.15)) expect_equal(result$postL, c(0.6779, 0.6296, 0.6069, 0.739)) - expect_equal(result$UciL, c(0.3942, 0.3437, 0.319, 0.2747)) + expect_equal(result$pL_upper_ci, c(0.3942, 0.3437, 0.319, 0.2747)) expect_equal(result$xU, c(2, 5, 7, 9)) expect_equal(result$pU, c(0.2, 0.25, 0.2333, 0.225)) expect_equal(result$postU, c(0.6174, 0.7693, 0.73, 0.704)) - expect_equal(result$LciU, c(0.0368, 0.1041, 0.115, 0.1227)) + expect_equal(result$pU_lower_ci, c(0.0368, 0.1041, 0.115, 0.1227)) }) From 670558da97cd2b4da3246b84013dd105cf89b64f Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 13:31:18 +0000 Subject: [PATCH 15/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index fa79aa7c..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 100, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From a29fd0fd1921d2e89390f3e1dd3293cf7d62d1f6 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 2 Jun 2024 19:37:45 +0200 Subject: [PATCH 16/71] should pass CMD checks From fe3f37fac2d62b821404a5ebbf9b93b57cccb041 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 3 Jun 2024 08:43:45 +0200 Subject: [PATCH 17/71] see if CMD checks pass now From 1b7d9c14de11b68004b92d8165d9e2335bb7da8c Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 11 Jun 2024 11:37:03 +0200 Subject: [PATCH 18/71] clean --- .pre-commit-config.yaml | 1 + DESCRIPTION | 1 + R/boundsPostprob.R | 10 ++-- R/ocPostprob.R | 4 +- examples/boundsPostprob.R | 9 ++- man/boundsPostprob.Rd | 9 ++- man/ocPostprob.Rd | 4 +- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++ 8 files changed, 146 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 42db738a..c6ea30b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: args: [--style_pkg=styler, --style_fun=tidyverse_style] - id: roxygenize additional_dependencies: + - ggplot2 - devtools - shiny - checkmate diff --git a/DESCRIPTION b/DESCRIPTION index cbeab397..dcc649f8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -22,6 +22,7 @@ BugReports: https://github.com/genentech/phase1b/issues Depends: R (>= 3.6) Suggests: + ggplot2 rmarkdown, bookdown, knitr, diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index b50fee96..bbf7682d 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -43,13 +43,13 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { xL <- NA xU <- NA for (x in 0:n) { - postp <- 1 - postprob(x, n, p0, parE = c(a, b)) # futility look - if (postp >= tL) { + postp <- postprob(x, n, p0, parE = c(a, b)) # futility look + if (postp >= tL) { # Rule is P(RR < p0) > tL postL <- postp xL <- x } - postp <- postprob(x, n, p0, parE = c(a, b)) # efficacy look - if (postp >= tU) { + postp <- 1 - postprob(x, n, p1, parE = c(a, b)) # efficacy look + if (postp >= tU) { # Rule is P(RR > p1) > tU postU <- postp xU <- x break @@ -69,5 +69,5 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { pU_lower_ci ) } - return(round(data.frame(nvec, z), 4)) + round(data.frame(nvec, z), 4) } diff --git a/R/ocPostprob.R b/R/ocPostprob.R index 060a0b1c..f7dcd334 100644 --- a/R/ocPostprob.R +++ b/R/ocPostprob.R @@ -187,11 +187,11 @@ h_get_oc <- function(all_sizes, Nmax, decision) { #' #' Stop criteria for Efficacy : #' -#' `Pr(truep > p1) > tU` +#' `Pr(RR > p1) > tU` #' #' Stop criteria for Futility : #' -#' `Pr(truep < p0) > tL` +#' `Pr(RR < p0) > tL` #' #' Resulting operating characteristics include the following: #' diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index f4377968..fc78db8d 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -3,6 +3,11 @@ # Futility decision if less than 60% probability to be below 20% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( - nvec = c(10, 20, 30, 40), p0 = 0.20, p1 = 0.2, - tL = 0.60, tU = 0.60, a = 1, b = 1 + nvec = c(10, 20, 30, 40), + p0 = 0.20, + p1 = 0.20, + tL = 0.20, + tU = 0.20, + a = 1, + b = 1 ) diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 4394ef94..7780d583 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -45,7 +45,12 @@ Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL # Futility decision if less than 60\% probability to be below 20\% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( - nvec = c(10, 20, 30, 40), p0 = 0.20, p1 = 0.2, - tL = 0.60, tU = 0.60, a = 1, b = 1 + nvec = c(10, 20, 30, 40), + p0 = 0.20, + p1 = 0.20, + tL = 0.20, + tU = 0.20, + a = 1, + b = 1 ) } diff --git a/man/ocPostprob.Rd b/man/ocPostprob.Rd index 23095a77..950cde0a 100644 --- a/man/ocPostprob.Rd +++ b/man/ocPostprob.Rd @@ -63,11 +63,11 @@ probability to be below \code{p0} is larger than \code{tL}: Stop criteria for Efficacy : -\code{Pr(truep > p1) > tU} +\code{Pr(RR > p1) > tU} Stop criteria for Futility : -\code{Pr(truep < p0) > tL} +\code{Pr(RR < p0) > tL} Resulting operating characteristics include the following: \itemize{ diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 150f2438ba693f1b18ab3ad2157a948777fce10a Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 11 Jun 2024 14:05:26 +0200 Subject: [PATCH 19/71] Update examples/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- examples/boundsPostprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index fc78db8d..265b5099 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -1,6 +1,6 @@ # 40 pts trial with interim looks after each 10 pts., # Efficacy decision if more than 60% probability to be above 20% ORR, -# Futility decision if less than 60% probability to be below 20% ORR, +# Futility decision if more than 60% probability to be below 20% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( nvec = c(10, 20, 30, 40), From 40afb1a997f8470f59fe654e870493a6b81a2686 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 11 Jun 2024 14:07:29 +0200 Subject: [PATCH 20/71] clean --- R/boundsPostprob.R | 12 +++++----- man/boundsPostprob.Rd | 2 +- tests/testthat/test-boundsPostProb.R | 36 +++++++++++++--------------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index bbf7682d..5910a964 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -25,16 +25,15 @@ #' @example examples/boundsPostprob.R #' @export boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { - z <- matrix(NA, length(nvec), 6) - dimnames(z) <- list(nvec, c( - "xL", "pL", "postL", - "xU", "pU", "postU" - )) + z <- matrix(NA, nrow = length(nvec), ncol = 8) + # dimnames(z) <- list(nvec, c( + # "xL", "pL", "postL", + # "xU", "pU", "postU" + # )) znames <- c( "xL", "pL", "postL", "pL_upper_ci", "xU", "pU", "postU", "pU_lower_ci" ) - z <- matrix(NA, length(nvec), length(znames)) dimnames(z) <- list(nvec, znames) k <- 0 for (n in nvec) { @@ -68,6 +67,7 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { postU, pU_lower_ci ) + break } round(data.frame(nvec, z), 4) } diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 7780d583..8a95e17e 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -42,7 +42,7 @@ Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL \examples{ # 40 pts trial with interim looks after each 10 pts., # Efficacy decision if more than 60\% probability to be above 20\% ORR, -# Futility decision if less than 60\% probability to be below 20\% ORR, +# Futility decision if more than 60\% probability to be below 20\% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( nvec = c(10, 20, 30, 40), diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index 3d74d3bc..e31397a8 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -10,24 +10,22 @@ test_that("boundsPostProb gives correct result and list", { b = 1 ) expected <- data.frame( - list( - nvec = c(10, 20, 30, 40), - xL = c(1, 3, 5, 6), - pL = c(0.1, 0.15, 0.1667, 0.15), - postL = c(0.6779, 0.6296, 0.6069, 0.739), - pL_upper_ci = c(0.3942, 0.3437, 0.319, 0.2747), - xU = c(2, 5, 7, 9), - pU = c(0.2, 0.25, 0.2333, 0.225), - postU = c(0.6174, 0.7693, 0.73, 0.704), - pU_lower_ci = c(0.0368, 0.1041, 0.115, 0.1227) - ) + nvec = c(10, 20, 30, 40), + xL = c(1, 3, 5, 6), + pL = c(0.1, 0.15, 0.1667, 0.15), + postL = c(0.6779, 0.6296, 0.6069, 0.739), + pL_upper_ci = c(0.3942, 0.3437, 0.319, 0.2747), + xU = c(2, 5, 7, 9), + pU = c(0.2, 0.25, 0.2333, 0.225), + postU = c(0.6174, 0.7693, 0.73, 0.704), + pU_lower_ci = c(0.0368, 0.1041, 0.115, 0.1227) ) - expect_equal(result$xL, c(1, 3, 5, 6)) - expect_equal(result$pL, c(0.1, 0.15, 0.1667, 0.15)) - expect_equal(result$postL, c(0.6779, 0.6296, 0.6069, 0.739)) - expect_equal(result$pL_upper_ci, c(0.3942, 0.3437, 0.319, 0.2747)) - expect_equal(result$xU, c(2, 5, 7, 9)) - expect_equal(result$pU, c(0.2, 0.25, 0.2333, 0.225)) - expect_equal(result$postU, c(0.6174, 0.7693, 0.73, 0.704)) - expect_equal(result$pU_lower_ci, c(0.0368, 0.1041, 0.115, 0.1227)) + expect_equal(result$xL, expected$xL) + expect_equal(result$pL, expected$pL) + expect_equal(result$postL, expected$postL) + expect_equal(result$pL_upper_ci, expected$pL_upper_ci) + expect_equal(result$xU, expected$xU) + expect_equal(result$pU, expected$pU) + expect_equal(result$postU, expected$postU) + expect_equal(result$pU_lower_ci, expected$pU_lower_ci) }) From bbb8c264d297b46ecb8fcbf3b85a33bde79bed1f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 12 Jun 2024 11:19:51 +0200 Subject: [PATCH 21/71] added ggplot2 in vignette --- R/dbetabinom.R | 2 +- tests/testthat/test-boundsPredprob.R | 33 ++++++++++++++++++++++++++++ vignettes/introduction.Rmd | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/test-boundsPredprob.R diff --git a/R/dbetabinom.R b/R/dbetabinom.R index 0150304a..e6f1d223 100644 --- a/R/dbetabinom.R +++ b/R/dbetabinom.R @@ -157,7 +157,7 @@ dbetaMix <- Vectorize(dbetaMix, vectorize.args = "x") #' @example examples/pbetaMix.R #' @export pbetaMix <- function(q, par, weights, lower.tail = TRUE) { - assert_number(q, lower = 0, upper = 1, finite = TRUE) + assert_numeric(q, lower = 0, upper = 1, finite = TRUE) assert_numeric(weights, lower = 0, upper = 1, finite = TRUE) assert_matrix(par) assert_flag(lower.tail) diff --git a/tests/testthat/test-boundsPredprob.R b/tests/testthat/test-boundsPredprob.R new file mode 100644 index 00000000..5d43c25f --- /dev/null +++ b/tests/testthat/test-boundsPredprob.R @@ -0,0 +1,33 @@ +# boundsPostProb ---- +test_that("boundsPredprob gives correct result and list", { + result <- boundsPredprob( + nvec = c(10, 20, 30, 40), + p0 = 0.2, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + a = 1, + b = 1 + ) + expected <- data.frame( + list( + nvec = c(10, 20, 30, 40), + xL = c(0, 2, 5, 9), + pL = c(0, 0.1, 0.1667, 0.225), + postL = c(0.0859, 0.1787, 0.3931, 0.704), + UciL = c(0.2589, 0.2826, 0.319, 0.3598), + xU = c(4, 7, 9, 10), + pU = c(0.4, 0.35, 0.3, 0.25), + postU = c(0.9496, 0.9569, 0.9254, 0.8177), + LciU = c(0.15, 0.1773, 0.1663, 0.1424) + ) + ) + expect_equal(result$xL, c(0, 2, 5, 9)) + expect_equal(result$pL, c(0, 0.1, 0.1667, 0.225)) + expect_equal(result$postL, c(0.0859, 0.1787, 0.3931, 0.704)) + expect_equal(result$UciL, c(0.2589, 0.2826, 0.319, 0.3598)) + expect_equal(result$xU, c(4, 7, 9, 10)) + expect_equal(result$pU, c(0.4, 0.35, 0.3, 0.25)) + expect_equal(result$postU, c(0.9496, 0.9569, 0.9254, 0.8177)) + expect_equal(result$LciU, c(0.15, 0.1773, 0.1663, 0.1424)) +}) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index e2b7a214..3ed739b2 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -153,6 +153,7 @@ following the instructions in the [Installation section](#installation) with the following command: ```{r load} library(phase1b) +library(ggplot2) ``` Once loaded, you will have access to all of the functions in the `phase1b` R-package. To see a list of all of the functions in the `phase1b` R-package, From 4bd29d1c51c8ccfd51ff285a3e97602d90d136ba Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 25 Jun 2024 14:41:49 +0200 Subject: [PATCH 22/71] empty From d8ce79ccce0e64251c00c704e74a5c54f8e93e3f Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 12:45:23 +0000 Subject: [PATCH 23/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 98fac80b13b598d1d25bfdad46cad688dd9cab5f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 26 Jun 2024 13:46:31 +0200 Subject: [PATCH 24/71] found postL --- R/boundsPostprob.R | 9 +--- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+), 7 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 5910a964..e39be43f 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -26,10 +26,6 @@ #' @export boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { z <- matrix(NA, nrow = length(nvec), ncol = 8) - # dimnames(z) <- list(nvec, c( - # "xL", "pL", "postL", - # "xU", "pU", "postU" - # )) znames <- c( "xL", "pL", "postL", "pL_upper_ci", "xU", "pU", "postU", "pU_lower_ci" @@ -42,12 +38,12 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { xL <- NA xU <- NA for (x in 0:n) { - postp <- postprob(x, n, p0, parE = c(a, b)) # futility look + postp <- 1 - postprob(x, n, p0, parE = c(a, b)) # futility look if (postp >= tL) { # Rule is P(RR < p0) > tL postL <- postp xL <- x } - postp <- 1 - postprob(x, n, p1, parE = c(a, b)) # efficacy look + postp <- postprob(x, n, p1, parE = c(a, b)) # efficacy look if (postp >= tU) { # Rule is P(RR > p1) > tU postU <- postp xU <- x @@ -67,7 +63,6 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { postU, pU_lower_ci ) - break } round(data.frame(nvec, z), 4) } diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From ed627cbbe8a09224528fc33f366739dfac957eaf Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:48:28 +0000 Subject: [PATCH 25/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 0b2e6adec89eaf509c76275b7f6e72502a10573c Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 27 Jun 2024 09:45:09 +0200 Subject: [PATCH 26/71] changed params in bounds example --- R/dbetabinom.R | 2 +- examples/boundsPostprob.R | 6 +- man/boundsPostprob.Rd | 6 +- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 7 deletions(-) diff --git a/R/dbetabinom.R b/R/dbetabinom.R index 7c3e70dc..e14f331a 100644 --- a/R/dbetabinom.R +++ b/R/dbetabinom.R @@ -157,7 +157,7 @@ dbetaMix <- Vectorize(dbetaMix, vectorize.args = "x") #' @example examples/pbetaMix.R #' @export pbetaMix <- function(q, par, weights, lower.tail = TRUE) { - assert_numeric(q, lower = 0, upper = 1, finite = TRUE) + assert_number(q, lower = 0, upper = 1, finite = TRUE) assert_numeric(weights, lower = 0, upper = 1, finite = TRUE) assert_matrix(par) assert_flag(lower.tail) diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index 265b5099..76513a22 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -1,13 +1,13 @@ # 40 pts trial with interim looks after each 10 pts., -# Efficacy decision if more than 60% probability to be above 20% ORR, +# Efficacy decision if more than 80% probability to be above 20% ORR, # Futility decision if more than 60% probability to be below 20% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( nvec = c(10, 20, 30, 40), p0 = 0.20, p1 = 0.20, - tL = 0.20, - tU = 0.20, + tL = 0.60, + tU = 0.80, a = 1, b = 1 ) diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 8a95e17e..126ed101 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -41,15 +41,15 @@ Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL } \examples{ # 40 pts trial with interim looks after each 10 pts., -# Efficacy decision if more than 60\% probability to be above 20\% ORR, +# Efficacy decision if more than 80\% probability to be above 20\% ORR, # Futility decision if more than 60\% probability to be below 20\% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( nvec = c(10, 20, 30, 40), p0 = 0.20, p1 = 0.20, - tL = 0.20, - tU = 0.20, + tL = 0.60, + tU = 0.80, a = 1, b = 1 ) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 25a5b01cf92b08dbef0c5c3769d92fd71f1a184c Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 27 Jun 2024 07:47:09 +0000 Subject: [PATCH 27/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 710d404db48ced6b5a22c2b07b9a153bb69224d6 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 23 Sep 2024 15:45:27 +0200 Subject: [PATCH 28/71] clean --- DESCRIPTION | 2 +- examples/boundsPostprob.R | 2 +- man/boundsPostprob.Rd | 2 +- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b568d599..d7f95063 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -44,7 +44,7 @@ Language: en-US LazyData: true Roxygen: list(markdown = TRUE, packages = "roxytypes") -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Config/Needs/documentation: roxytypes Remotes: diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index 76513a22..9d01ff4a 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -4,7 +4,7 @@ # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( nvec = c(10, 20, 30, 40), - p0 = 0.20, + p0 = 0.15, p1 = 0.20, tL = 0.60, tU = 0.80, diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 126ed101..bdb6a392 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -46,7 +46,7 @@ Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( nvec = c(10, 20, 30, 40), - p0 = 0.20, + p0 = 0.15, p1 = 0.20, tL = 0.60, tU = 0.80, diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From ce5f140f671bbdd7a437420e15b64cef243bdedb Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:48:59 +0000 Subject: [PATCH 29/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 366889765965db4b4bbba085694294593e3fb8c5 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 23 Sep 2024 16:12:07 +0200 Subject: [PATCH 30/71] clean --- tests/testthat/test-boundsPostProb.R | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index e31397a8..0b124b44 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -2,23 +2,23 @@ test_that("boundsPostProb gives correct result and list", { result <- boundsPostprob( nvec = c(10, 20, 30, 40), - p0 = 0.2, + p0 = 0.15, p1 = 0.2, - tL = 0.60, + tL = 0.70, tU = 0.60, a = 1, b = 1 ) expected <- data.frame( nvec = c(10, 20, 30, 40), - xL = c(1, 3, 5, 6), - pL = c(0.1, 0.15, 0.1667, 0.15), - postL = c(0.6779, 0.6296, 0.6069, 0.739), - pL_upper_ci = c(0.3942, 0.3437, 0.319, 0.2747), + xL = c(0, 1, 3, 4), + pL = c(0, 0.05, 0.1, 0.1), + postL = c(0.8327, 0.8450, 0.7039, 0.7567), + pL_upper_ci = c(0.2589, 0.2161, 0.2386, 0.2144), xU = c(2, 5, 7, 9), - pU = c(0.2, 0.25, 0.2333, 0.225), - postU = c(0.6174, 0.7693, 0.73, 0.704), - pU_lower_ci = c(0.0368, 0.1041, 0.115, 0.1227) + pU = c(0.2000, 0.2500, 0.2333, 0.2250), + postU = c(0.6174, 0.7693, 0.7300, 0.7040), + pU_lower_ci = c(0.0368, 0.1041, 0.1150, 0.1227) ) expect_equal(result$xL, expected$xL) expect_equal(result$pL, expected$pL) From b748246b202359815dd70401e78e65299cc89255 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 24 Sep 2024 20:19:47 +0200 Subject: [PATCH 31/71] made it flexible for beta mixture priors --- R/boundsPostprob.R | 24 ++++-- examples/boundsPostprob.R | 19 ++++- man/boundsPostprob.Rd | 32 +++++-- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++ tests/testthat/test-boundsPostProb.R | 38 ++++++++- 5 files changed, 212 insertions(+), 22 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index e39be43f..23ab2e0a 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -7,9 +7,11 @@ #' #' @inheritParams postprob #' @inheritParams ocPostprob -#' @typed nvec : numeric +#' @typed a : numeric +#' +#' @typed looks : numeric #' A vector of number of patients in each look. -#' @return A matrix for each same size in `nvec`. For each sample size, the following is returned: +#' @return A matrix for each same size in `looks`. For each sample size, the following is returned: #' - `xL` : the maximum number of responses that meet the futility. #' threshold #' - `pL` : response rate corresponding to `xL`. @@ -24,26 +26,30 @@ #' #' @example examples/boundsPostprob.R #' @export -boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { - z <- matrix(NA, nrow = length(nvec), ncol = 8) +boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { + z <- matrix(NA, nrow = length(looks), ncol = 8) znames <- c( "xL", "pL", "postL", "pL_upper_ci", "xU", "pU", "postU", "pU_lower_ci" ) - dimnames(z) <- list(nvec, znames) + dimnames(z) <- list(looks, znames) k <- 0 - for (n in nvec) { + parE <- t(parE) + if (missing(weights)) { + weights <- rep(1, nrow(parE)) + } + for (n in looks) { k <- k + 1 # initialize so will return NA if 0 or n in "continue" region xL <- NA xU <- NA for (x in 0:n) { - postp <- 1 - postprob(x, n, p0, parE = c(a, b)) # futility look + postp <- 1 - postprob(x, n, p0, parE, weights) # futility look if (postp >= tL) { # Rule is P(RR < p0) > tL postL <- postp xL <- x } - postp <- postprob(x, n, p1, parE = c(a, b)) # efficacy look + postp <- postprob(x, n, p1, parE, weights) # efficacy look if (postp >= tU) { # Rule is P(RR > p1) > tU postU <- postp xU <- x @@ -64,5 +70,5 @@ boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { pU_lower_ci ) } - round(data.frame(nvec, z), 4) + round(data.frame(looks, z), 4) } diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index 9d01ff4a..a7e9b125 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -3,11 +3,24 @@ # Futility decision if more than 60% probability to be below 20% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( - nvec = c(10, 20, 30, 40), + looks = c(10, 20, 30, 40), p0 = 0.15, p1 = 0.20, tL = 0.60, tU = 0.80, - a = 1, - b = 1 + parE = c(1, 1) +) + +# 40 pts trial with various interim looks. +# Efficacy decision if more than 80% probability to be above 20% ORR, +# Futility decision if more than 60% probability to be below 20% ORR, +# with mixed prior and weights: +boundsPostprob( + looks = c(7, 20, 40), + p0 = 0.15, + p1 = 0.20, + tL = 0.60, + tU = 0.80, + parE = rbind(c(1, 19), c(2, 10)), + weights = c(0.2, 0.8) ) diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index bdb6a392..e10c256a 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -4,10 +4,10 @@ \alias{boundsPostprob} \title{Decision cutpoints for boundary (based on posterior probability)} \usage{ -boundsPostprob(nvec, p0, p1 = p0, tL, tU, a, b) +boundsPostprob(looks, p0, p1 = p0, tL, tU, parE, weights) } \arguments{ -\item{nvec}{(\code{numeric}):\cr A vector of number of patients in each look.} +\item{looks}{(\code{numeric}):\cr A vector of number of patients in each look.} \item{p0}{(\code{number}):\cr lower Futility threshold of response rate.} @@ -16,9 +16,16 @@ boundsPostprob(nvec, p0, p1 = p0, tL, tU, a, b) \item{tL}{(\code{number}):\cr posterior probability threshold for being below \code{p0}.} \item{tU}{(\code{number}):\cr posterior probability threshold for being above \code{p1}.} + +\item{parE}{(\code{matrix}):\cr the beta parameters matrix, with \code{K} rows and 2 columns, +corresponding to the beta parameters of the \code{K} components.} + +\item{weights}{(\code{vector}):\cr The mixture weights of the beta mixture prior.} + +\item{}{(\if{html}{\out{}}):\cr \if{html}{\out{}}} } \value{ -A matrix for each same size in \code{nvec}. For each sample size, the following is returned: +A matrix for each same size in \code{looks}. For each sample size, the following is returned: \itemize{ \item \code{xL} : the maximum number of responses that meet the futility. threshold @@ -45,12 +52,25 @@ Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL # Futility decision if more than 60\% probability to be below 20\% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( - nvec = c(10, 20, 30, 40), + looks = c(10, 20, 30, 40), + p0 = 0.15, + p1 = 0.20, + tL = 0.60, + tU = 0.80, + parE = c(1, 1) +) + +# 40 pts trial with various interim looks. +# Efficacy decision if more than 80\% probability to be above 20\% ORR, +# Futility decision if more than 60\% probability to be below 20\% ORR, +# with mixed prior and weights: +boundsPostprob( + looks = c(7, 20, 40), p0 = 0.15, p1 = 0.20, tL = 0.60, tU = 0.80, - a = 1, - b = 1 + parE = rbind(c(1, 19), c(2, 10)), + weights = c(0.2, 0.8) ) } diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index 0b124b44..e65971a0 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -1,16 +1,15 @@ # boundsPostProb ---- test_that("boundsPostProb gives correct result and list", { result <- boundsPostprob( - nvec = c(10, 20, 30, 40), + looks = c(10, 20, 30, 40), p0 = 0.15, p1 = 0.2, tL = 0.70, tU = 0.60, - a = 1, - b = 1 + parE = c(1, 1) ) expected <- data.frame( - nvec = c(10, 20, 30, 40), + looks = c(10, 20, 30, 40), xL = c(0, 1, 3, 4), pL = c(0, 0.05, 0.1, 0.1), postL = c(0.8327, 0.8450, 0.7039, 0.7567), @@ -29,3 +28,34 @@ test_that("boundsPostProb gives correct result and list", { expect_equal(result$postU, expected$postU) expect_equal(result$pU_lower_ci, expected$pU_lower_ci) }) + +test_that("boundsPostProb for beta mixture gives correct result and list", { + result <- boundsPostprob( + looks = c(7, 20, 40), + p0 = 0.15, + p1 = 0.20, + tL = 0.60, + tU = 0.80, + parE = rbind(c(1, 19), c(2, 10)), + weights = c(0.2, 0.8) + ) + expected <- data.frame( + looks = c(7, 20, 40), + xL = c(0, 2, 5), + pL = c(0.000, 0.100, 0.125), + postL = c(0.7456, 0.6601, 0.6173), + pL_upper_ci = c(0.3482, 0.2826, 0.2450), + xU = c(2, 6, 10), + pU = c(0.2857, 0.3000, 0.2500), + postU = c(0.8890, 0.9054, 0.8012), + pU_lower_ci = c(.0534, 0.1396, 0.1424) + ) + expect_equal(result$xL, expected$xL) + expect_equal(result$pL, expected$pL) + expect_equal(result$postL, expected$postL) + expect_equal(result$pL_upper_ci, expected$pL_upper_ci) + expect_equal(result$xU, expected$xU) + expect_equal(result$pU, expected$pU) + expect_equal(result$postU, expected$postU) + expect_equal(result$pU_lower_ci, expected$pU_lower_ci) +}) From c1f312bb9bae794afe36b2bdafd7d6a671554548 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 24 Sep 2024 20:24:19 +0200 Subject: [PATCH 32/71] made it flexible for beta mixture priors --- R/boundsPostprob.R | 2 -- examples/boundsPostprob.R | 4 ++-- man/boundsPostprob.Rd | 6 ++---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 23ab2e0a..18bf5dd7 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -7,8 +7,6 @@ #' #' @inheritParams postprob #' @inheritParams ocPostprob -#' @typed a : numeric -#' #' @typed looks : numeric #' A vector of number of patients in each look. #' @return A matrix for each same size in `looks`. For each sample size, the following is returned: diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index a7e9b125..d30694c1 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -1,6 +1,6 @@ # 40 pts trial with interim looks after each 10 pts., # Efficacy decision if more than 80% probability to be above 20% ORR, -# Futility decision if more than 60% probability to be below 20% ORR, +# Futility decision if more than 60% probability to be below 15% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( looks = c(10, 20, 30, 40), @@ -13,7 +13,7 @@ boundsPostprob( # 40 pts trial with various interim looks. # Efficacy decision if more than 80% probability to be above 20% ORR, -# Futility decision if more than 60% probability to be below 20% ORR, +# Futility decision if more than 60% probability to be below 15% ORR, # with mixed prior and weights: boundsPostprob( looks = c(7, 20, 40), diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index e10c256a..1235a81e 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -21,8 +21,6 @@ boundsPostprob(looks, p0, p1 = p0, tL, tU, parE, weights) corresponding to the beta parameters of the \code{K} components.} \item{weights}{(\code{vector}):\cr The mixture weights of the beta mixture prior.} - -\item{}{(\if{html}{\out{}}):\cr \if{html}{\out{}}} } \value{ A matrix for each same size in \code{looks}. For each sample size, the following is returned: @@ -49,7 +47,7 @@ Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL \examples{ # 40 pts trial with interim looks after each 10 pts., # Efficacy decision if more than 80\% probability to be above 20\% ORR, -# Futility decision if more than 60\% probability to be below 20\% ORR, +# Futility decision if more than 60\% probability to be below 15\% ORR, # with uniform prior (i.e. beta(1, 1)) on the ORR: boundsPostprob( looks = c(10, 20, 30, 40), @@ -62,7 +60,7 @@ boundsPostprob( # 40 pts trial with various interim looks. # Efficacy decision if more than 80\% probability to be above 20\% ORR, -# Futility decision if more than 60\% probability to be below 20\% ORR, +# Futility decision if more than 60\% probability to be below 15\% ORR, # with mixed prior and weights: boundsPostprob( looks = c(7, 20, 40), From 9f90ee8bafb0cb8164cebd7d6d702e94a035e582 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:29:03 +0000 Subject: [PATCH 33/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From d11cce482798f341d0845a2ea971cdedf9535053 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:13:12 +0200 Subject: [PATCH 34/71] Update R/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- R/boundsPostprob.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 18bf5dd7..5ded27be 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -10,8 +10,7 @@ #' @typed looks : numeric #' A vector of number of patients in each look. #' @return A matrix for each same size in `looks`. For each sample size, the following is returned: -#' - `xL` : the maximum number of responses that meet the futility. -#' threshold +#' - `xL` : the maximum number of responses that meet the futility threshold. #' - `pL` : response rate corresponding to `xL`. #' - `postL`: posterior probability corresponding to `xL`. #' - `pL_upper_ci` : upper bound of one sided 95% CI for the response rate `pL` based on an From bee517e1dc7e8f609d4142717fd2e2e9fa58a78b Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:13:41 +0200 Subject: [PATCH 35/71] Update tests/testthat/test-boundsPostProb.R Co-authored-by: Daniel Sabanes Bove --- tests/testthat/test-boundsPostProb.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index e65971a0..1b5337de 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -48,7 +48,7 @@ test_that("boundsPostProb for beta mixture gives correct result and list", { xU = c(2, 6, 10), pU = c(0.2857, 0.3000, 0.2500), postU = c(0.8890, 0.9054, 0.8012), - pU_lower_ci = c(.0534, 0.1396, 0.1424) + pU_lower_ci = c(0.0534, 0.1396, 0.1424) ) expect_equal(result$xL, expected$xL) expect_equal(result$pL, expected$pL) From 9e6047feaf94bcd0639ea0c642e9f30fefc8d8d0 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:16:07 +0200 Subject: [PATCH 36/71] Update examples/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- examples/boundsPostprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/boundsPostprob.R b/examples/boundsPostprob.R index d30694c1..694942d0 100644 --- a/examples/boundsPostprob.R +++ b/examples/boundsPostprob.R @@ -11,7 +11,7 @@ boundsPostprob( parE = c(1, 1) ) -# 40 pts trial with various interim looks. +# 40 pts trial with interim looks at 7 and 20 pts. # Efficacy decision if more than 80% probability to be above 20% ORR, # Futility decision if more than 60% probability to be below 15% ORR, # with mixed prior and weights: From e21363f5b97a0668ea2b14c7970eb24ca2da4a6a Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:16:16 +0200 Subject: [PATCH 37/71] Update R/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- R/boundsPostprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 5ded27be..45a96676 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -46,7 +46,7 @@ boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { postL <- postp xL <- x } - postp <- postprob(x, n, p1, parE, weights) # efficacy look + postp_eff <- postprob(x, n, p1, parE, weights) # efficacy look if (postp >= tU) { # Rule is P(RR > p1) > tU postU <- postp xU <- x From 67546097650547918058d8de9e890de73bedcb61 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:16:45 +0200 Subject: [PATCH 38/71] Update R/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- R/boundsPostprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 45a96676..3795fac1 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -17,7 +17,7 @@ #' exact binomial test. #' - `xU` : the minimal number of responses that meet the efficacy threshold. #' - `pU` : response rate corresponding to `xU`. -#' - `postU` : posterior probability corresponding to `xU`. +#' - `postU` : posterior probability corresponding to `xU`, i.e. Pr(RR > p1 |xU, n, a, b). #' - `pU_lower_ci` : lower bound of one sided 95% CI for the response rate `pU` based on exact #' binomial test. #' From 629302526e530d0304c29624a57b5e26dcb26bfd Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:16:55 +0200 Subject: [PATCH 39/71] Update R/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- R/boundsPostprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 3795fac1..4f090dbe 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -41,7 +41,7 @@ boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { xL <- NA xU <- NA for (x in 0:n) { - postp <- 1 - postprob(x, n, p0, parE, weights) # futility look + postp_fut <- 1 - postprob(x, n, p0, parE, weights) # futility look if (postp >= tL) { # Rule is P(RR < p0) > tL postL <- postp xL <- x From a21a776ff93d15c86800fed4de04d55945e00713 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:17:03 +0200 Subject: [PATCH 40/71] Update R/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- R/boundsPostprob.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 4f090dbe..ad943c39 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -2,8 +2,8 @@ #' #' This function is used to identify the efficacy and futility #' boundaries based on the following rules: -#' Efficacy boundary: find minimum x (xU) where Pr(P > p1 |x, n, a, b) >= tU and -#' Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL +#' Efficacy boundary: find minimum x (xU) where Pr(RR > p1 |x, n, a, b) >= tU and +#' Futility boundary: find maximum x (xL) where Pr(RR < p0 | x, n, a, b) >= tL #' #' @inheritParams postprob #' @inheritParams ocPostprob From 515e02186f366716e7b127c8716eb3a58571cc06 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:17:11 +0200 Subject: [PATCH 41/71] Update tests/testthat/test-boundsPostProb.R Co-authored-by: Daniel Sabanes Bove --- tests/testthat/test-boundsPostProb.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index 1b5337de..8676f593 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -29,7 +29,7 @@ test_that("boundsPostProb gives correct result and list", { expect_equal(result$pU_lower_ci, expected$pU_lower_ci) }) -test_that("boundsPostProb for beta mixture gives correct result and list", { +test_that("boundsPostProb for beta mixture gives correct result", { result <- boundsPostprob( looks = c(7, 20, 40), p0 = 0.15, From 772d191a6531db8555f34371ad4df0216d796aa4 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:17:29 +0200 Subject: [PATCH 42/71] Update tests/testthat/test-boundsPostProb.R Co-authored-by: Daniel Sabanes Bove --- tests/testthat/test-boundsPostProb.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-boundsPostProb.R b/tests/testthat/test-boundsPostProb.R index 8676f593..225f7441 100644 --- a/tests/testthat/test-boundsPostProb.R +++ b/tests/testthat/test-boundsPostProb.R @@ -1,5 +1,5 @@ # boundsPostProb ---- -test_that("boundsPostProb gives correct result and list", { +test_that("boundsPostProb gives correct result", { result <- boundsPostprob( looks = c(10, 20, 30, 40), p0 = 0.15, From 929bdfadb823a2f1cc124366cd517c2b347eb25b Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:17:51 +0200 Subject: [PATCH 43/71] Update R/boundsPostprob.R Co-authored-by: Daniel Sabanes Bove --- R/boundsPostprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index ad943c39..0cab8d91 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -12,7 +12,7 @@ #' @return A matrix for each same size in `looks`. For each sample size, the following is returned: #' - `xL` : the maximum number of responses that meet the futility threshold. #' - `pL` : response rate corresponding to `xL`. -#' - `postL`: posterior probability corresponding to `xL`. +#' - `postL`: posterior probability corresponding to `xL`, i.e. Pr(RR < p0 | xL, n, a, b). #' - `pL_upper_ci` : upper bound of one sided 95% CI for the response rate `pL` based on an #' exact binomial test. #' - `xU` : the minimal number of responses that meet the efficacy threshold. From cd923d8b920b467adbc94257ebb3c170270efe66 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 06:21:13 +0000 Subject: [PATCH 44/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/boundsPostprob.Rd | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index 1235a81e..b2e98477 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -25,15 +25,14 @@ corresponding to the beta parameters of the \code{K} components.} \value{ A matrix for each same size in \code{looks}. For each sample size, the following is returned: \itemize{ -\item \code{xL} : the maximum number of responses that meet the futility. -threshold +\item \code{xL} : the maximum number of responses that meet the futility threshold. \item \code{pL} : response rate corresponding to \code{xL}. -\item \code{postL}: posterior probability corresponding to \code{xL}. +\item \code{postL}: posterior probability corresponding to \code{xL}, i.e. Pr(RR < p0 | xL, n, a, b). \item \code{pL_upper_ci} : upper bound of one sided 95\% CI for the response rate \code{pL} based on an exact binomial test. \item \code{xU} : the minimal number of responses that meet the efficacy threshold. \item \code{pU} : response rate corresponding to \code{xU}. -\item \code{postU} : posterior probability corresponding to \code{xU}. +\item \code{postU} : posterior probability corresponding to \code{xU}, i.e. Pr(RR > p1 |xU, n, a, b). \item \code{pU_lower_ci} : lower bound of one sided 95\% CI for the response rate \code{pU} based on exact binomial test. } @@ -41,8 +40,8 @@ binomial test. \description{ This function is used to identify the efficacy and futility boundaries based on the following rules: -Efficacy boundary: find minimum x (xU) where Pr(P > p1 |x, n, a, b) >= tU and -Futility boundary: find maximum x (xL) where Pr(P < p0 | x, n, a, b) >= tL +Efficacy boundary: find minimum x (xU) where Pr(RR > p1 |x, n, a, b) >= tU and +Futility boundary: find maximum x (xL) where Pr(RR < p0 | x, n, a, b) >= tL } \examples{ # 40 pts trial with interim looks after each 10 pts., @@ -58,7 +57,7 @@ boundsPostprob( parE = c(1, 1) ) -# 40 pts trial with various interim looks. +# 40 pts trial with interim looks at 7 and 20 pts. # Efficacy decision if more than 80\% probability to be above 20\% ORR, # Futility decision if more than 60\% probability to be below 15\% ORR, # with mixed prior and weights: From 3075a55509546ef84ded7dd48d95d564126d6958 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 08:40:42 +0200 Subject: [PATCH 45/71] clean --- R/boundsPostprob.R | 15 ++++-- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 4 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 0cab8d91..ea58af5e 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -24,6 +24,13 @@ #' @example examples/boundsPostprob.R #' @export boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { + assert_numeric(looks) + assert_number(p0, lower = 0, upper = 1) + assert_number(p1, lower = 0, upper = 1) + assert_number(tL, lower = 0, upper = 1) + assert_number(tU, lower = 0, upper = 1) + assert_numeric(parE, min.len = 2, any.missing = FALSE) + assert_numeric(weights, min.len = 0, len = nrow(par), finite = TRUE) z <- matrix(NA, nrow = length(looks), ncol = 8) znames <- c( "xL", "pL", "postL", "pL_upper_ci", @@ -42,13 +49,13 @@ boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { xU <- NA for (x in 0:n) { postp_fut <- 1 - postprob(x, n, p0, parE, weights) # futility look - if (postp >= tL) { # Rule is P(RR < p0) > tL - postL <- postp + if (postp_full >= tL) { # Rule is P(RR < p0) > tL + postL <- postp_eff xL <- x } postp_eff <- postprob(x, n, p1, parE, weights) # efficacy look - if (postp >= tU) { # Rule is P(RR > p1) > tU - postU <- postp + if (postp_eff >= tU) { # Rule is P(RR > p1) > tU + postU <- postp_eff xU <- x break } diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 2c0d0bc8526e9573f67bac06f36068e233931557 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 06:44:25 +0000 Subject: [PATCH 46/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 75693d705e4fec7141ee7651e4da27abb28121c6 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 11:19:27 +0200 Subject: [PATCH 47/71] assert weights to different position --- R/boundsPostprob.R | 6 +-- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 3 deletions(-) diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index ea58af5e..44405af9 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -30,7 +30,6 @@ boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { assert_number(tL, lower = 0, upper = 1) assert_number(tU, lower = 0, upper = 1) assert_numeric(parE, min.len = 2, any.missing = FALSE) - assert_numeric(weights, min.len = 0, len = nrow(par), finite = TRUE) z <- matrix(NA, nrow = length(looks), ncol = 8) znames <- c( "xL", "pL", "postL", "pL_upper_ci", @@ -42,6 +41,7 @@ boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { if (missing(weights)) { weights <- rep(1, nrow(parE)) } + assert_numeric(weights, min.len = 0, len = nrow(par), finite = TRUE) for (n in looks) { k <- k + 1 # initialize so will return NA if 0 or n in "continue" region @@ -49,8 +49,8 @@ boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { xU <- NA for (x in 0:n) { postp_fut <- 1 - postprob(x, n, p0, parE, weights) # futility look - if (postp_full >= tL) { # Rule is P(RR < p0) > tL - postL <- postp_eff + if (postp_fut >= tL) { # Rule is P(RR < p0) > tL + postL <- postp_fut xL <- x } postp_eff <- postprob(x, n, p1, parE, weights) # efficacy look diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 23973c7abce9fe7f44b3145c630950c522e553c2 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:23:22 +0000 Subject: [PATCH 48/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 601c8446cdfe8a37c9db1770b9c30f4329b5404c Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 26 Sep 2024 11:46:55 +0200 Subject: [PATCH 49/71] empty commit to make sure cmd checks pass for merge From ca82fc1e61dc12da4d45aea16b7dcc7aaf8ceb02 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 27 Sep 2024 09:35:41 +0200 Subject: [PATCH 50/71] clean --- R/boundsPostprob.R | 2 +- examples/ocPredprobDist.R | 12 ++- examples/plotBounds.R | 7 -- man/boundsPostprob.Rd | 2 +- man/ocPredprob.Rd | 121 +++++++++++++++++++++++++++ man/ocPredprobDist.Rd | 12 ++- man/plotBounds.Rd | 7 -- tests/testthat/test-boundsPredprob.R | 33 -------- 8 files changed, 139 insertions(+), 57 deletions(-) delete mode 100644 tests/testthat/test-boundsPredprob.R diff --git a/R/boundsPostprob.R b/R/boundsPostprob.R index 44405af9..a35fef8d 100644 --- a/R/boundsPostprob.R +++ b/R/boundsPostprob.R @@ -23,7 +23,7 @@ #' #' @example examples/boundsPostprob.R #' @export -boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { +boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE = c(1, 1), weights) { assert_numeric(looks) assert_number(p0, lower = 0, upper = 1) assert_number(p1, lower = 0, upper = 1) diff --git a/examples/ocPredprobDist.R b/examples/ocPredprobDist.R index e925a68a..4bc2715e 100644 --- a/examples/ocPredprobDist.R +++ b/examples/ocPredprobDist.R @@ -74,10 +74,14 @@ result$oc # True response rate or truep of the treatment group = 40% # Desired difference to Standard of Care for Efficacy and Futility = 50% # Delta calculation is absolute case. The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate + deltaE > 25% ) > 60% or P(response rate + deltaE > p0) > tT -# - Final look for Futility: Pr( response rate + deltaF < 25% ) < 60% or P(response rate + deltaF > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20% or P(success at final) < phiL +# - Final look for Efficacy: Pr( response rate + deltaE > 25% ) > 60% or +# P(response rate + deltaE > p0) > tT +# - Final look for Futility: Pr( response rate + deltaF < 25% ) < 60% or +# P(response rate + deltaF > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80% or +# P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20% or +# P(success at final) < phiL # We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. set.seed(20) diff --git a/examples/plotBounds.R b/examples/plotBounds.R index f4ba8525..c28479ea 100644 --- a/examples/plotBounds.R +++ b/examples/plotBounds.R @@ -7,10 +7,3 @@ plotBounds(boundsPredprob( nvec = c(10, 20, 30, 40), p = 0.20, tT = 0.80, phiL = 0.10, phiU = 0.90, a = 1, b = 1 ), yt = "p") -plotBounds( - boundsPostprob( - nvec = c(10, 20, 30, 40), p0 = 0.20, - tL = 0.10, tU = 0.90, a = 1, b = 1 - ), - yt = "p", add = TRUE -) diff --git a/man/boundsPostprob.Rd b/man/boundsPostprob.Rd index b2e98477..b21240cd 100644 --- a/man/boundsPostprob.Rd +++ b/man/boundsPostprob.Rd @@ -4,7 +4,7 @@ \alias{boundsPostprob} \title{Decision cutpoints for boundary (based on posterior probability)} \usage{ -boundsPostprob(looks, p0, p1 = p0, tL, tU, parE, weights) +boundsPostprob(looks, p0, p1 = p0, tL, tU, parE = c(1, 1), weights) } \arguments{ \item{looks}{(\code{numeric}):\cr A vector of number of patients in each look.} diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} diff --git a/man/ocPredprobDist.Rd b/man/ocPredprobDist.Rd index 2c1d66fc..3a570cfa 100644 --- a/man/ocPredprobDist.Rd +++ b/man/ocPredprobDist.Rd @@ -208,10 +208,14 @@ result$oc # True response rate or truep of the treatment group = 40\% # Desired difference to Standard of Care for Efficacy and Futility = 50\% # Delta calculation is absolute case. The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate + deltaE > 25\% ) > 60\% or P(response rate + deltaE > p0) > tT -# - Final look for Futility: Pr( response rate + deltaF < 25\% ) < 60\% or P(response rate + deltaF > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# - Final look for Efficacy: Pr( response rate + deltaE > 25\% ) > 60\% or +# P(response rate + deltaE > p0) > tT +# - Final look for Futility: Pr( response rate + deltaF < 25\% ) < 60\% or +# P(response rate + deltaF > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or +# P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or +# P(success at final) < phiL # We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. set.seed(20) diff --git a/man/plotBounds.Rd b/man/plotBounds.Rd index 5d24d8c6..0ee0034d 100644 --- a/man/plotBounds.Rd +++ b/man/plotBounds.Rd @@ -64,12 +64,5 @@ plotBounds(boundsPredprob( nvec = c(10, 20, 30, 40), p = 0.20, tT = 0.80, phiL = 0.10, phiU = 0.90, a = 1, b = 1 ), yt = "p") -plotBounds( - boundsPostprob( - nvec = c(10, 20, 30, 40), p0 = 0.20, - tL = 0.10, tU = 0.90, a = 1, b = 1 - ), - yt = "p", add = TRUE -) } \keyword{graphics} diff --git a/tests/testthat/test-boundsPredprob.R b/tests/testthat/test-boundsPredprob.R deleted file mode 100644 index 5d43c25f..00000000 --- a/tests/testthat/test-boundsPredprob.R +++ /dev/null @@ -1,33 +0,0 @@ -# boundsPostProb ---- -test_that("boundsPredprob gives correct result and list", { - result <- boundsPredprob( - nvec = c(10, 20, 30, 40), - p0 = 0.2, - tT = 0.80, - phiL = 0.10, - phiU = 0.90, - a = 1, - b = 1 - ) - expected <- data.frame( - list( - nvec = c(10, 20, 30, 40), - xL = c(0, 2, 5, 9), - pL = c(0, 0.1, 0.1667, 0.225), - postL = c(0.0859, 0.1787, 0.3931, 0.704), - UciL = c(0.2589, 0.2826, 0.319, 0.3598), - xU = c(4, 7, 9, 10), - pU = c(0.4, 0.35, 0.3, 0.25), - postU = c(0.9496, 0.9569, 0.9254, 0.8177), - LciU = c(0.15, 0.1773, 0.1663, 0.1424) - ) - ) - expect_equal(result$xL, c(0, 2, 5, 9)) - expect_equal(result$pL, c(0, 0.1, 0.1667, 0.225)) - expect_equal(result$postL, c(0.0859, 0.1787, 0.3931, 0.704)) - expect_equal(result$UciL, c(0.2589, 0.2826, 0.319, 0.3598)) - expect_equal(result$xU, c(4, 7, 9, 10)) - expect_equal(result$pU, c(0.4, 0.35, 0.3, 0.25)) - expect_equal(result$postU, c(0.9496, 0.9569, 0.9254, 0.8177)) - expect_equal(result$LciU, c(0.15, 0.1773, 0.1663, 0.1424)) -}) From d27b5457e4daf25f3617657a4932490161ee9ff2 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 07:39:09 +0000 Subject: [PATCH 51/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From f9ac9fac7ac3124a8a222e0906f839d1d2dc97e2 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 27 Sep 2024 09:58:47 +0200 Subject: [PATCH 52/71] ocProdprod.Rd rebuilt --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 297c0b2ce5408f69b99b767f2b9c4dd71171baef Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 08:02:18 +0000 Subject: [PATCH 53/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 431291e61a07f92ee07ed091004843a50feb3e5d Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 27 Sep 2024 20:30:59 +0200 Subject: [PATCH 54/71] see if man/ocPredprob.Rd blanks out --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 1a12b88e9400529333d2966ae63d786e9acd29e9 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 18:33:09 +0000 Subject: [PATCH 55/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From b18ccdd28cb43cbe54c5fdbd1cd98ef5fd039cd7 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 27 Sep 2024 20:39:45 +0200 Subject: [PATCH 56/71] did anything change from restarting session From 3b35b0f8d07be719d854812e95f7aaed60f5d5e8 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 27 Sep 2024 20:40:06 +0200 Subject: [PATCH 57/71] did anything change from restarting session From 791e2e53c7e881dbb89b466873594c1b054881c1 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 27 Sep 2024 23:59:51 +0200 Subject: [PATCH 58/71] checking again From 4060b7ff17956136f1606fac8d0f2f605c777325 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sat, 28 Sep 2024 00:01:02 +0200 Subject: [PATCH 59/71] that did not work --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 85790ac244ae9e19db0f3297ab518909f37e383c Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 22:04:00 +0000 Subject: [PATCH 60/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 75045a253ef452307d8b60f55585dfa5a52eaf1f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 30 Sep 2024 12:02:49 +0200 Subject: [PATCH 61/71] clean --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 3f2aabfdb07005351396c7377d8d6c491b3fad49 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:05:07 +0000 Subject: [PATCH 62/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 847839b1755ebfae3af1c8983e44d52316c50098 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 30 Sep 2024 12:06:36 +0200 Subject: [PATCH 63/71] clean --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From dfc536ee2b996c6a5395fd8aeff3e9c96ae87c22 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:09:04 +0000 Subject: [PATCH 64/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 612c10f5349bc37cfca1aad6f06467e215215601 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 30 Sep 2024 12:47:57 +0200 Subject: [PATCH 65/71] clean --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 685d990a34eda41f1c16f671897aaa13e37a8a4f Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:50:07 +0000 Subject: [PATCH 66/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From aaad040a2d19d6b185ca2ce38ed5fdf88f5bfca6 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 30 Sep 2024 13:09:02 +0200 Subject: [PATCH 67/71] rebuild --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From 319dd1608e1cc7f68c808157e043835e4044d128 Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:11:13 +0000 Subject: [PATCH 68/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ---------------------------------------------- 1 file changed, 121 deletions(-) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 63e17a09..25c8d9e2 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,124 +117,3 @@ The criteria for Decision 2 for Futility looks are : } } } -\examples{ -# Here we illustrate an example for Decision 1 with the following assumptions : -# True response rate or truep of the treatment group = 40\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 1 with no wiggle. -set.seed(20) -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - decision1 = TRUE -) -result$oc - -# Decision 1 with wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.4, - p0 = 0.25, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.4, - p0 = 0.25, - p1 = 0.2, - tT = 0.6, - phiL = 0.2, - phiU = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = TRUE, - nnF = c(10, 15, 20), - decision1 = TRUE -) -result$oc - -# Here we illustrate an example for Decision 2 with the following assumptions : -# True response rate or truep of the treatment group = 60\% -# The following are the Final Stop rules respectively : -# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT -# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF -# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU -# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu -# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. - -# Decision 2 without wiggle. -result <- ocPredprob( - nnE = c(10, 20), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiU = 0.8, - phiFu = 0.8, - parE = c(1, 1), - sim = 50, - wiggle = FALSE, - nnF = c(10, 20), - decision1 = FALSE -) -result$oc - -# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. -result <- ocPredprob( - nnE = c(10, 25, 30), - truep = 0.6, - p0 = 0.25, - p1 = 0.25, - tT = 0.6, - tF = 0.6, - phiL = 0.8, - phiU = 0.8, - parE = c(11, 19), - sim = 50, - wiggle = TRUE, - nnF = 30, - decision1 = FALSE -) -result$oc -} From 54cbf18b09181403b11413fc0860e11e35dbd79a Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 30 Sep 2024 13:15:23 +0200 Subject: [PATCH 69/71] clean --- examples/{ocPredprob.r => ocPredprob.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/{ocPredprob.r => ocPredprob.R} (100%) diff --git a/examples/ocPredprob.r b/examples/ocPredprob.R similarity index 100% rename from examples/ocPredprob.r rename to examples/ocPredprob.R From 431b119b420e46a78574b30cd542b19c72df081d Mon Sep 17 00:00:00 2001 From: "27856297+dependabot-preview[bot]@users.noreply.github.com" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:18:14 +0000 Subject: [PATCH 70/71] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +} From c1a46050bab5f38cf159da60314e771befea61c2 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 30 Sep 2024 13:19:53 +0200 Subject: [PATCH 71/71] clean --- man/ocPredprob.Rd | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/man/ocPredprob.Rd b/man/ocPredprob.Rd index 25c8d9e2..63e17a09 100644 --- a/man/ocPredprob.Rd +++ b/man/ocPredprob.Rd @@ -117,3 +117,124 @@ The criteria for Decision 2 for Futility looks are : } } } +\examples{ +# Here we illustrate an example for Decision 1 with the following assumptions : +# True response rate or truep of the treatment group = 40\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate > p0) < tT +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) < 20\% or P(success at final) < phiL +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 1 with no wiggle. +set.seed(20) +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + decision1 = TRUE +) +result$oc + +# Decision 1 with wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.4, + p0 = 0.25, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final without wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Decision 1 with separate Futility and Efficacy looks at interim and final with wiggle. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.4, + p0 = 0.25, + p1 = 0.2, + tT = 0.6, + phiL = 0.2, + phiU = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = TRUE, + nnF = c(10, 15, 20), + decision1 = TRUE +) +result$oc + +# Here we illustrate an example for Decision 2 with the following assumptions : +# True response rate or truep of the treatment group = 60\% +# The following are the Final Stop rules respectively : +# - Final look for Efficacy: Pr( response rate > 25\% ) > 60\% or P(response rate > p0) > tT +# - Final look for Futility: Pr( response rate < 25\% ) < 60\% or P(response rate < p1) > tF +# - Interim look for Efficacy: Pr( success at final ) > 80\% or P(success at final) > phiU +# - Interim look for Futility: Pr( failure at final ) > 80\% or P(failure at final) > phiFu +# We assume a prior of treatment arm parE = Beta(1,1), unless otherwise indicated. + +# Decision 2 without wiggle. +result <- ocPredprob( + nnE = c(10, 20), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiU = 0.8, + phiFu = 0.8, + parE = c(1, 1), + sim = 50, + wiggle = FALSE, + nnF = c(10, 20), + decision1 = FALSE +) +result$oc + +# Decision 2 with wiggle and with Futility only at final with non-uniform beta prior parE. +result <- ocPredprob( + nnE = c(10, 25, 30), + truep = 0.6, + p0 = 0.25, + p1 = 0.25, + tT = 0.6, + tF = 0.6, + phiL = 0.8, + phiU = 0.8, + parE = c(11, 19), + sim = 50, + wiggle = TRUE, + nnF = 30, + decision1 = FALSE +) +result$oc +}