Skip to content

Commit

Permalink
Revert "115 make website live" (#117)
Browse files Browse the repository at this point in the history
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
  • Loading branch information
audreyyeoCH and dependabot-preview[bot] authored Aug 7, 2024
1 parent 6dd1b82 commit 65bc5af
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 106 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export(dbetaMix)
export(dbetabinom)
export(dbetabinomMix)
export(dbetadiff)
export(myPlot)
export(myPlotDiff)
export(oc2)
export(oc3)
Expand Down
75 changes: 37 additions & 38 deletions R/boundsPostprob.R
Original file line number Diff line number Diff line change
@@ -1,38 +1,42 @@
#' Decision cutpoints for boundary (based on posterior probability)
#'
#' 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
#' 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
#'
#' @inheritParams postprob
#' @inheritParams ocPostprob
#' @typed nvec : 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:
#' - `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
#' 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`.
#' - `pU_lower_ci` : lower bound of one sided 95% CI for the response rate `pU` based on exact
#' binomial test.
#' @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
#' 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).
#'
#' @importFrom stats binom.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(
"xL", "pL", "postL",
"xU", "pU", "postU"
))
znames <- c(
"xL", "pL", "postL", "pL_upper_ci",
"xU", "pU", "postU", "pU_lower_ci"
"xL", "pL", "postL", "UciL",
"xU", "pU", "postU", "LciU"
)
z <- matrix(NA, length(nvec), length(znames))
dimnames(z) <- list(nvec, znames)
Expand All @@ -43,31 +47,26 @@ 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) {
postL <- postp
postp <- postprob(x, n, p1, parE = c(a, b))
if (postp <= tL) {
xL <- x
}
postp <- postprob(x, n, p0, parE = c(a, b)) # efficacy look
if (p0 != p1) {
postp <- postprob(x, n, p0, parE = c(a, b))
}
if (postp >= tU) {
postU <- postp
xU <- x
# done: leave innermost for loop
break
}
}
# 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
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,
pL_upper_ci,
xU,
xU / n,
postU,
pU_lower_ci
)
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)
}
return(round(data.frame(nvec, z), 4))
}
14 changes: 8 additions & 6 deletions examples/boundsPostprob.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# 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:
## 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:
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,
tL = 0.10, tU = 0.90, 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.
59 changes: 31 additions & 28 deletions man/boundsPostprob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions tests/testthat/test-boundsPostProb.R

This file was deleted.

0 comments on commit 65bc5af

Please sign in to comment.