From f15a2942eeabe338dc73891fd4e316e9bc4bd0f9 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 10 Oct 2025 09:14:18 +0200 Subject: [PATCH 01/17] first edits on documentation --- R/plotBounds.R | 113 ++++++++++++++++++++++++++++++--------------- man/plotBounds.Rd | 31 ++----------- man/sumBetaDiff.Rd | 11 +++++ 3 files changed, 92 insertions(+), 63 deletions(-) diff --git a/R/plotBounds.R b/R/plotBounds.R index 4e956771..2b0bdbd8 100644 --- a/R/plotBounds.R +++ b/R/plotBounds.R @@ -1,24 +1,24 @@ #' Plot the boundary decision cutpoints #' #' This function will plot the response rate on the futility and efficacy -#' boundaries, and is used together with \code{\link{boundsPredprob}} -#' and \code{\link{boundsPostprob}} +#' boundaries, and is used together with [boundsPredprob()] +#' and [boundsPostprob()] for Decision 1. See `boundsPredprob()` for rules. #' -#' @param z an output of \code{\link{boundsPredprob}} and -#' \code{\link{boundsPostprob}} -#' @param area color the futility/efficacy stop area -#' @param grid show the grid of y-axis or not -#' @param yt indicate the y axis: response rate is "p", number of responses +#' @typed z an output of [boundsPredprob()] and +#' [boundsPostprob()] +#' @typed area color the futility/efficacy stop area +#' @typed grid show the grid of y-axis or not +#' @typed yt indicate the y axis: response rate is "p", number of responses #' is "x" -#' @param add add the boundary lines or not -#' @param cols specific the color of `[1]` efficacy area `[2]` futility area +#' @typed add add the boundary lines or not +#' @typed cols specific the color of `[1]` efficacy area `[2]` futility area #' `[3]` efficacy boundary `[4]` futility boundary -#' @param lwds line width (a two dimensional vector) -#' @param ltype line type -#' @param lpch a value of plotting characters or symbols -#' @param lcex a value giving the amount by which plotting characters and +#' @typed lwds line width (a two dimensional vector) +#' @typed ltype line type +#' @typed lpch a value of plotting characters or symbols +#' @typed lcex a value giving the amount by which plotting characters and #' symbols should be scaled relative to the default. -#' @param gy a value to adjust the gray level of the plot (default 20), +#' @typed gy a value to adjust the gray level of the plot (default 20), #' applies when \code{grid==TRUE} #' @return nothing, only produces the plot as side effect #' @@ -27,9 +27,19 @@ #' @example examples/plotBounds.R #' @export #' @keywords graphics -plotBounds <- function(z, area = TRUE, grid = TRUE, yt = "x", add = FALSE, - cols = c("green", "red", "darkgreen", "orange"), - lwds = c(3, 3), ltype = "l", lpch = 16, lcex = 1, gy = 20) { +plotBounds <- function( + z, + area = TRUE, + grid = TRUE, + yt = "x", + add = FALSE, + cols = c("green", "red", "darkgreen", "orange"), + lwds = c(3, 3), + ltype = "l", + lpch = 16, + lcex = 1, + gy = 20 +) { n <- nrow(z) nmin <- min(z$looks) nmax <- max(z$looks) @@ -51,40 +61,71 @@ plotBounds <- function(z, area = TRUE, grid = TRUE, yt = "x", add = FALSE, stop("yt can only be x or p") } if (add) { - graphics::lines(z$looks, z2, - lwd = lwds[1], col = cols[3], type = ltype, - pch = lpch, cex = lcex + graphics::lines( + z$looks, + z2, + lwd = lwds[1], + col = cols[3], + type = ltype, + pch = lpch, + cex = lcex ) - graphics::lines(z$looks, z1, - lwd = lwds[2], col = cols[4], type = ltype, - pch = lpch, cex = lcex + graphics::lines( + z$looks, + z1, + lwd = lwds[2], + col = cols[4], + type = ltype, + pch = lpch, + cex = lcex ) return(invisible()) } - graphics::plot(z$looks, rep(0, n), - xlim = c(0, max(z$looks)), ylim = c(0, yU), type = "n", - xlab = "n", ylab = ylabel + graphics::plot( + z$looks, + rep(0, n), + xlim = c(0, max(z$looks)), + ylim = c(0, yU), + type = "n", + xlab = "n", + ylab = ylabel ) if (grid) { graphics::abline(h = gridy, col = "gray") } if (area) { - graphics::polygon(c(z$looks, nmax, nmin), c(z2, yU, yU2), + graphics::polygon( + c(z$looks, nmax, nmin), + c(z2, yU, yU2), lwd = lwds[1], - col = cols[1], border = cols[1] + col = cols[1], + border = cols[1] ) - graphics::polygon(c(z$looks, nmax, nmin), c(z1, 0, 0), + graphics::polygon( + c(z$looks, nmax, nmin), + c(z1, 0, 0), lwd = lwds[2], - col = cols[2], border = cols[2] + col = cols[2], + border = cols[2] ) } else { - graphics::lines(z$looks, z2, - lwd = lwds[1], col = cols[1], type = ltype, - pch = lpch, cex = lcex + graphics::lines( + z$looks, + z2, + lwd = lwds[1], + col = cols[1], + type = ltype, + pch = lpch, + cex = lcex ) - graphics::lines(z$looks, z1, - lwd = lwds[2], col = cols[2], type = ltype, - pch = lpch, cex = lcex + graphics::lines( + z$looks, + z1, + lwd = lwds[2], + col = cols[2], + type = ltype, + pch = lpch, + cex = lcex ) } return(invisible()) diff --git a/man/plotBounds.Rd b/man/plotBounds.Rd index 0caf508c..9511770f 100644 --- a/man/plotBounds.Rd +++ b/man/plotBounds.Rd @@ -19,40 +19,17 @@ plotBounds( ) } \arguments{ -\item{z}{an output of \code{\link{boundsPredprob}} and -\code{\link{boundsPostprob}}} +\item{yt indicate the y axis}{(\verb{response rate is "p", number of responses}):\cr is "x"} -\item{area}{color the futility/efficacy stop area} - -\item{grid}{show the grid of y-axis or not} - -\item{yt}{indicate the y axis: response rate is "p", number of responses -is "x"} - -\item{add}{add the boundary lines or not} - -\item{cols}{specific the color of \verb{[1]} efficacy area \verb{[2]} futility area -\verb{[3]} efficacy boundary \verb{[4]} futility boundary} - -\item{lwds}{line width (a two dimensional vector)} - -\item{ltype}{line type} - -\item{lpch}{a value of plotting characters or symbols} - -\item{lcex}{a value giving the amount by which plotting characters and -symbols should be scaled relative to the default.} - -\item{gy}{a value to adjust the gray level of the plot (default 20), -applies when \code{grid==TRUE}} +\item{}{(\if{html}{\out{}}):\cr \if{html}{\out{}}} } \value{ nothing, only produces the plot as side effect } \description{ This function will plot the response rate on the futility and efficacy -boundaries, and is used together with \code{\link{boundsPredprob}} -and \code{\link{boundsPostprob}} +boundaries, and is used together with \code{\link[=boundsPredprob]{boundsPredprob()}} +and \code{\link[=boundsPostprob]{boundsPostprob()}} for Decision 1. See \code{boundsPredprob()} for rules. } \examples{ # examples diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 5cc1ae5e..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -27,3 +27,14 @@ along with the \code{go} and \code{stop} probabilities. A function to summarize the characters of a betadiff distribution \code{\link[=dbetadiff]{dbetadiff()}}. May require use of random sample generator to calculate, use \code{\link[=set.seed]{set.seed()}} to reproduce results. } +\examples{ +parX <- c(1, 52) # Control group's parameters +parY <- c(5.5, 20.5) # Treatment group's parameters +sumBetaDiff( + parX = parX, + parY = parY, + ci_level = 0.9, + go_cut = 0.6, + stop_cut = 0.2 +) +} From 9c0c4d2720f9977d0ae1e070754c512baa4d8a5a Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 10 Oct 2025 15:11:21 +0200 Subject: [PATCH 02/17] clean --- R/plotBounds.R | 4 +- design/design_doc_plotBounds.qmd | 328 +++++++++++++++++++++++++++++++ examples/plotBounds.R | 38 ++-- 3 files changed, 357 insertions(+), 13 deletions(-) create mode 100644 design/design_doc_plotBounds.qmd diff --git a/R/plotBounds.R b/R/plotBounds.R index 2b0bdbd8..a7a0c09d 100644 --- a/R/plotBounds.R +++ b/R/plotBounds.R @@ -2,7 +2,7 @@ #' #' This function will plot the response rate on the futility and efficacy #' boundaries, and is used together with [boundsPredprob()] -#' and [boundsPostprob()] for Decision 1. See `boundsPredprob()` for rules. +#' and [boundsPostprob()] for Decision 1. See `boundsPredprob()` for. #' #' @typed z an output of [boundsPredprob()] and #' [boundsPostprob()] @@ -33,7 +33,7 @@ plotBounds <- function( grid = TRUE, yt = "x", add = FALSE, - cols = c("green", "red", "darkgreen", "orange"), + cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), lwds = c(3, 3), ltype = "l", lpch = 16, diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd new file mode 100644 index 00000000..f36dbf83 --- /dev/null +++ b/design/design_doc_plotBounds.qmd @@ -0,0 +1,328 @@ +--- +title: "Design Doc for plotBounds" +format: revealjs +editor: visual +--- + +Statisticians can display boundaries of Go, Stop and GreyZone decisions graphically in terms of response rates required by desired samples sizes or looks. This is such purpose of `plotBounds`. Note that for the predictive probability case, decision 1 rules are chosen. See `ocPredprob` for rules. + +# packages that aid + +```{r} +library(flextable) +library(ggplot2) +``` + +# input + +```{r} +boundsPostprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tL = 0.10, + tU = 0.90, + parE = c(1, 1) + ) +``` + +```{r} +boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ) +``` + +# vintage function + +```{r} +vintage_plotBounds <- function( + z, + area = TRUE, + grid = TRUE, + yt = "x", + add = FALSE, + cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), + lwds = c(3, 3), + ltype = "l", + lpch = 16, + lcex = 1, + gy = 20 +) { + n <- nrow(z) + nmin <- min(z$looks) + nmax <- max(z$looks) + if (yt == "x") { + z1 <- z$xL + z2 <- z$xU + yU <- nmax + yU2 <- nmin + ylabel <- "Number of Responses" + gridy <- seq(0, yU, by = floor(yU / gy)) + } else if (yt == "p") { + z1 <- z$pL + z2 <- z$pU + yU <- 1 + yU2 <- 1 + ylabel <- "Response Rate" + gridy <- seq(0, yU, by = yU / gy) + } else { + stop("yt can only be x or p") + } + if (add) { + graphics::lines( + z$looks, + z2, + lwd = lwds[1], + col = cols[3], + type = ltype, + pch = lpch, + cex = lcex + ) + graphics::lines( + z$looks, + z1, + lwd = lwds[2], + col = cols[4], + type = ltype, + pch = lpch, + cex = lcex + ) + return(invisible()) + } + graphics::plot( + z$looks, + rep(0, n), + xlim = c(0, max(z$looks)), + ylim = c(0, yU), + type = "n", + xlab = "n", + ylab = ylabel + ) + if (grid) { + graphics::abline(h = gridy, col = "gray") + } + if (area) { + graphics::polygon( + c(z$looks, nmax, nmin), + c(z2, yU, yU2), + lwd = lwds[1], + col = cols[1], + border = cols[1] + ) + graphics::polygon( + c(z$looks, nmax, nmin), + c(z1, 0, 0), + lwd = lwds[2], + col = cols[2], + border = cols[2] + ) + } else { + graphics::lines( + z$looks, + z2, + lwd = lwds[1], + col = cols[1], + type = ltype, + pch = lpch, + cex = lcex + ) + graphics::lines( + z$looks, + z1, + lwd = lwds[2], + col = cols[2], + type = ltype, + pch = lpch, + cex = lcex + ) + } + return(invisible()) +} + +``` + +# vintage example that should work with new function +```{r} +plotBounds( + boundsPostprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tL = 0.10, + tU = 0.90, + parE = c(1, 1) + ), + yt = "p", + add = TRUE +) + +``` + +# creating polygons with new function + +The following output show that important coordinates needed as input to create these polygons. + +As a premise, we establish the criteria: +Interim +Go : P(success) > 90 % +Stop : P(success) > 10 % +Final +Go : P(RR > 0.20 | data) > 80 % +Stop : P(RR > 0.20 | data) < 10 % + +The criteria for interim analyses are from predictive probability calculation. + +The criteria for final analyses are from posterior probability calculation. + +which translates to boundaries : +When n = 10, 4 responders and above is a Go, 0 responders and below is a stop. +When n = 20, 7 responders and above is a Go, 2 responders and below is a stop +When n = 30, 9 responders and above is a Go, 5 responders and below is a stop +When n = 40, 10 responders and above is a Go, 9 responders and below is a stop + +```{r} +vintage_plotBounds( + boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ), + yt = "x" +) +``` + +```{r} +coords <- boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ) +``` + +```{r} +new_plotBounds <- function(coords, + postprob = TRUE, + go_colour = "#1B9E77", + stop_colour = "#E41A1C", + alpha = 1) { + go_data <- data.frame( + n = coords$looks, + ymin_go = coords$xU, + ymax_go = coords$looks + ) + stop_data <- data.frame( + n = coords$looks, + ymin_stop = c(0, 0, 0, 0), + ymax_stop = coords$xL + ) + plot <- ggplot2::ggplot() + + ggplot2::geom_ribbon( + data = stop_data, + ggplot2::aes(x = n, ymin = ymin_stop, ymax = ymax_stop), + fill = stop_colour, alpha = alpha + ) + + ggplot2::geom_ribbon( + data = go_data, + ggplot2::aes(x = n, ymin = ymin_go, ymax = ymax_go), + fill = go_colour , alpha = alpha + ) + + ggplot2::scale_x_continuous( + name = "n", + breaks = go_data$n + ) + + ggplot2::scale_y_continuous( + breaks = seq(from = 0, to = max(go_data$n), by = 2) + ) + + ggplot2::geom_point( + data = go_data, + ggplot2::aes(x = n, y = ymin_go), + size = 3, + shape = 16, + colour = "#16C47F", + ) + + ggplot2::geom_point( + data = stop_data, + ggplot2::aes(x = n, y = ymax_stop), + size = 3, + shape = 16, + colour = "#FF748B", #"#DC3C22",FF748B + ) + + ggplot2::xlab("Sample Size (n)") + + ggplot2::ylab("Number of Responders") + + ggplot2::theme_minimal() + + if (postprob) { + plot + ggplot2::ggtitle( + "Boundaries of responder numbers per sample size" + ) + } else { + plot + ggplot2::ggtitle( + "Boundaries of responder rates per sample size" + ) + } +} +``` +```{r} +coords <- boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ) +new_plotBounds(coords) +``` + + + +# creating polygons with new function + +The following output show that important coordinates needed as input to create these polygons. + +As a premise, we establish the criteria: +Go : P(RR > 0.20 | data) > 90 % +Stop : P(RR > 0.20 | data) > 10 % +which translates to boundaries : +When n = 10, 4 responders and above is a Go, 3 responders and below is a stop. +When n = 20, 7 responders and above is a Go, 6 responders and below is a stop +When n = 30, 9 responders and above is a Go, 8 responders and below is a stop +When n = 40, 12 responders and above is a Go, 11 responders and below is a stop + + +```{r} +coords1 <- boundsPostprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tL = 0.10, + tU = 0.90, + parE = c(1, 1) + ) +new_plotBounds(coords1) +``` + +We extract these coordinates but carefully assign which are Go, Stop and GreyZones. + +```{r} + +``` + + + + + + + + + + + + + + + diff --git a/examples/plotBounds.R b/examples/plotBounds.R index c39fc05b..4c84dbd5 100644 --- a/examples/plotBounds.R +++ b/examples/plotBounds.R @@ -1,16 +1,32 @@ # examples plotBounds( boundsPostprob( - looks = c(10, 20, 30, 40), p0 = 0.20, - tL = 0.10, tU = 0.90, parE = c(1, 1) + looks = c(10, 20, 30, 40), + p0 = 0.20, + tL = 0.10, + tU = 0.90, + parE = c(1, 1) ), - yt = "p", add = TRUE + yt = "p", + add = TRUE +) +plotBounds( + boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ), + yt = "x" +) +plotBounds( + boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ), + yt = "p" ) -plotBounds(boundsPredprob( - looks = c(10, 20, 30, 40), p0 = 0.20, tT = 0.80, - phiL = 0.10, phiU = 0.90, -), yt = "x") -plotBounds(boundsPredprob( - looks = c(10, 20, 30, 40), p0 = 0.20, tT = 0.80, - phiL = 0.10, phiU = 0.90, -), yt = "p") From 13a8dbf51cfa5eecffbdd394a0f4df9c4c69e0fe Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 10 Oct 2025 15:17:50 +0200 Subject: [PATCH 03/17] clean --- design/design_doc_plotBounds.qmd | 85 +++++++++++++++----------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index f36dbf83..67dd4f16 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -145,6 +145,7 @@ vintage_plotBounds <- function( ``` # vintage example that should work with new function + ```{r} plotBounds( boundsPostprob( @@ -160,27 +161,7 @@ plotBounds( ``` -# creating polygons with new function - -The following output show that important coordinates needed as input to create these polygons. - -As a premise, we establish the criteria: -Interim -Go : P(success) > 90 % -Stop : P(success) > 10 % -Final -Go : P(RR > 0.20 | data) > 80 % -Stop : P(RR > 0.20 | data) < 10 % - -The criteria for interim analyses are from predictive probability calculation. - -The criteria for final analyses are from posterior probability calculation. - -which translates to boundaries : -When n = 10, 4 responders and above is a Go, 0 responders and below is a stop. -When n = 20, 7 responders and above is a Go, 2 responders and below is a stop -When n = 30, 9 responders and above is a Go, 5 responders and below is a stop -When n = 40, 10 responders and above is a Go, 9 responders and below is a stop +# vintage function ```{r} vintage_plotBounds( @@ -195,15 +176,6 @@ vintage_plotBounds( ) ``` -```{r} -coords <- boundsPredprob( - looks = c(10, 20, 30, 40), - p0 = 0.20, - tT = 0.80, - phiL = 0.10, - phiU = 0.90, - ) -``` ```{r} new_plotBounds <- function(coords, @@ -257,17 +229,35 @@ new_plotBounds <- function(coords, ggplot2::ylab("Number of Responders") + ggplot2::theme_minimal() - if (postprob) { - plot + ggplot2::ggtitle( - "Boundaries of responder numbers per sample size" - ) - } else { plot + ggplot2::ggtitle( - "Boundaries of responder rates per sample size" - ) - } + "Boundaries of Go and Stop Responders per sample size") } ``` + +# creating polygons with new function with `boundsPredprob()` + +The following output show that important coordinates needed as input to create these polygons. + +As a premise, we establish the criteria: + +Interim +Go : P(success) > 90 % +Stop : P(success) > 10 % + +Final +Go : P(RR > 0.20 | data) > 80 % +Stop : P(RR > 0.20 | data) < 10 % + +The criteria for interim analyses are from predictive probability calculation. + +The criteria for final analyses are from posterior probability calculation. + +which translates to boundaries : +When n = 10, 4 responders and above is a Go, 0 responders and below is a stop. +When n = 20, 7 responders and above is a Go, 2 responders and below is a stop +When n = 30, 9 responders and above is a Go, 5 responders and below is a stop +When n = 40, 10 responders and above is a Go, 9 responders and below is a stop + ```{r} coords <- boundsPredprob( looks = c(10, 20, 30, 40), @@ -276,12 +266,22 @@ coords <- boundsPredprob( phiL = 0.10, phiU = 0.90, ) -new_plotBounds(coords) +print(coords) ``` +```{r} +coords <- boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ) +new_plotBounds(coords) +``` -# creating polygons with new function +# creating polygons with new function with `boundsPostprob()` The following output show that important coordinates needed as input to create these polygons. @@ -306,11 +306,6 @@ coords1 <- boundsPostprob( new_plotBounds(coords1) ``` -We extract these coordinates but carefully assign which are Go, Stop and GreyZones. - -```{r} - -``` From 459b7c920ff816603cae4d818b2c144a1840f8f4 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 10 Oct 2025 15:27:59 +0200 Subject: [PATCH 04/17] clean --- design/design_doc_plotBounds.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 67dd4f16..34c6034c 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -190,7 +190,7 @@ new_plotBounds <- function(coords, ) stop_data <- data.frame( n = coords$looks, - ymin_stop = c(0, 0, 0, 0), + ymin_stop = c(rep(0, length(coords$looks))), ymax_stop = coords$xL ) plot <- ggplot2::ggplot() + From 4ff49b735e886d4ddda25e2dc0956b08ed0c56bd Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sat, 11 Oct 2025 10:17:29 +0200 Subject: [PATCH 05/17] clean --- R/plotBounds.R | 30 +++++++------- design/design_doc_plotBounds.qmd | 43 +++++++------------- man/plotBounds.Rd | 69 +++++++++++++++++++++++++------- 3 files changed, 84 insertions(+), 58 deletions(-) diff --git a/R/plotBounds.R b/R/plotBounds.R index a7a0c09d..082a55b6 100644 --- a/R/plotBounds.R +++ b/R/plotBounds.R @@ -1,24 +1,24 @@ #' Plot the boundary decision cutpoints #' #' This function will plot the response rate on the futility and efficacy -#' boundaries, and is used together with [boundsPredprob()] -#' and [boundsPostprob()] for Decision 1. See `boundsPredprob()` for. +#' boundaries, and is used together with \code{\link{boundsPredprob}} +#' and \code{\link{boundsPostprob}} #' -#' @typed z an output of [boundsPredprob()] and -#' [boundsPostprob()] -#' @typed area color the futility/efficacy stop area -#' @typed grid show the grid of y-axis or not -#' @typed yt indicate the y axis: response rate is "p", number of responses +#' @param z an output of \code{\link{boundsPredprob}} and +#' \code{\link{boundsPostprob}} +#' @param area color the futility/efficacy stop area +#' @param grid show the grid of y-axis or not +#' @param yt indicate the y axis: response rate is "p", number of responses #' is "x" -#' @typed add add the boundary lines or not -#' @typed cols specific the color of `[1]` efficacy area `[2]` futility area +#' @param add add the boundary lines or not +#' @param cols specific the color of `[1]` efficacy area `[2]` futility area #' `[3]` efficacy boundary `[4]` futility boundary -#' @typed lwds line width (a two dimensional vector) -#' @typed ltype line type -#' @typed lpch a value of plotting characters or symbols -#' @typed lcex a value giving the amount by which plotting characters and +#' @param lwds line width (a two dimensional vector) +#' @param ltype line type +#' @param lpch a value of plotting characters or symbols +#' @param lcex a value giving the amount by which plotting characters and #' symbols should be scaled relative to the default. -#' @typed gy a value to adjust the gray level of the plot (default 20), +#' @param gy a value to adjust the gray level of the plot (default 20), #' applies when \code{grid==TRUE} #' @return nothing, only produces the plot as side effect #' @@ -33,7 +33,7 @@ plotBounds <- function( grid = TRUE, yt = "x", add = FALSE, - cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), + cols = c("green", "red", "darkgreen", "orange"), lwds = c(3, 3), ltype = "l", lpch = 16, diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 34c6034c..17537ca0 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -4,7 +4,7 @@ format: revealjs editor: visual --- -Statisticians can display boundaries of Go, Stop and GreyZone decisions graphically in terms of response rates required by desired samples sizes or looks. This is such purpose of `plotBounds`. Note that for the predictive probability case, decision 1 rules are chosen. See `ocPredprob` for rules. +Statisticians can display boundaries of Go, Stop and GreyZone decisions graphically in terms of response rates required by desired samples sizes or looks. This is such purpose of `plotBounds`. Note that for the predictive probability case, decision 1 rules are chosen. See `ocPredprob` for rules. Design document aims to translate previous call function to use of more common packages such as `ggplot2` and reduce number of lines. # packages that aid @@ -13,28 +13,6 @@ library(flextable) library(ggplot2) ``` -# input - -```{r} -boundsPostprob( - looks = c(10, 20, 30, 40), - p0 = 0.20, - tL = 0.10, - tU = 0.90, - parE = c(1, 1) - ) -``` - -```{r} -boundsPredprob( - looks = c(10, 20, 30, 40), - p0 = 0.20, - tT = 0.80, - phiL = 0.10, - phiU = 0.90, - ) -``` - # vintage function ```{r} @@ -161,7 +139,7 @@ plotBounds( ``` -# vintage function +# vintage function output ```{r} vintage_plotBounds( @@ -176,6 +154,7 @@ vintage_plotBounds( ) ``` +# new call function ```{r} new_plotBounds <- function(coords, @@ -183,6 +162,12 @@ new_plotBounds <- function(coords, go_colour = "#1B9E77", stop_colour = "#E41A1C", alpha = 1) { + assert_data_frame(coords, any.missing = FALSE, types = "numeric") + assert_flag(postprob) + assert_character(go_colour) + assert_character(stop_colour) + assert_number(alpha, lower = 0, upper = 1) + go_data <- data.frame( n = coords$looks, ymin_go = coords$xU, @@ -234,9 +219,9 @@ new_plotBounds <- function(coords, } ``` -# creating polygons with new function with `boundsPredprob()` +# creating plot using new function with output from `boundsPredprob()` -The following output show that important coordinates needed as input to create these polygons. +The following output show that important coordinates needed as input to create these plots. As a premise, we establish the criteria: @@ -278,10 +263,12 @@ coords <- boundsPredprob( phiL = 0.10, phiU = 0.90, ) -new_plotBounds(coords) +new_plotBounds(coords = coords, + go_colour = "blue", + alpha = 1) ``` -# creating polygons with new function with `boundsPostprob()` +# creating plots with new function with output from `boundsPostprob()` The following output show that important coordinates needed as input to create these polygons. diff --git a/man/plotBounds.Rd b/man/plotBounds.Rd index 9511770f..5b6ab385 100644 --- a/man/plotBounds.Rd +++ b/man/plotBounds.Rd @@ -19,34 +19,73 @@ plotBounds( ) } \arguments{ -\item{yt indicate the y axis}{(\verb{response rate is "p", number of responses}):\cr is "x"} +\item{z}{an output of \code{\link{boundsPredprob}} and +\code{\link{boundsPostprob}}} -\item{}{(\if{html}{\out{}}):\cr \if{html}{\out{}}} +\item{area}{color the futility/efficacy stop area} + +\item{grid}{show the grid of y-axis or not} + +\item{yt}{indicate the y axis: response rate is "p", number of responses +is "x"} + +\item{add}{add the boundary lines or not} + +\item{cols}{specific the color of \verb{[1]} efficacy area \verb{[2]} futility area +\verb{[3]} efficacy boundary \verb{[4]} futility boundary} + +\item{lwds}{line width (a two dimensional vector)} + +\item{ltype}{line type} + +\item{lpch}{a value of plotting characters or symbols} + +\item{lcex}{a value giving the amount by which plotting characters and +symbols should be scaled relative to the default.} + +\item{gy}{a value to adjust the gray level of the plot (default 20), +applies when \code{grid==TRUE}} } \value{ nothing, only produces the plot as side effect } \description{ This function will plot the response rate on the futility and efficacy -boundaries, and is used together with \code{\link[=boundsPredprob]{boundsPredprob()}} -and \code{\link[=boundsPostprob]{boundsPostprob()}} for Decision 1. See \code{boundsPredprob()} for rules. +boundaries, and is used together with \code{\link{boundsPredprob}} +and \code{\link{boundsPostprob}} } \examples{ # examples plotBounds( boundsPostprob( - looks = c(10, 20, 30, 40), p0 = 0.20, - tL = 0.10, tU = 0.90, parE = c(1, 1) + looks = c(10, 20, 30, 40), + p0 = 0.20, + tL = 0.10, + tU = 0.90, + parE = c(1, 1) + ), + yt = "p", + add = TRUE +) +plotBounds( + boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, + ), + yt = "x" +) +plotBounds( + boundsPredprob( + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, ), - yt = "p", add = TRUE + yt = "p" ) -plotBounds(boundsPredprob( - looks = c(10, 20, 30, 40), p0 = 0.20, tT = 0.80, - phiL = 0.10, phiU = 0.90, -), yt = "x") -plotBounds(boundsPredprob( - looks = c(10, 20, 30, 40), p0 = 0.20, tT = 0.80, - phiL = 0.10, phiU = 0.90, -), yt = "p") } \keyword{graphics} From dbe99e2f19cce929b5e2fa7f73771f9396962703 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sat, 11 Oct 2025 10:19:41 +0200 Subject: [PATCH 06/17] clean --- design/design_doc_plotBounds.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 17537ca0..2c9fac37 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -270,7 +270,7 @@ new_plotBounds(coords = coords, # creating plots with new function with output from `boundsPostprob()` -The following output show that important coordinates needed as input to create these polygons. +The following output show that important coordinates needed as input to create these plots. Coordinates are the points where the polygon should be drawn and reflect the possible values for a go and stop decision respectively. As a premise, we establish the criteria: Go : P(RR > 0.20 | data) > 90 % From 2770b1687115e7a611a8e9715af1cfa9f8a8d51d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 11 Oct 2025 11:39:42 +0000 Subject: [PATCH 07/17] [skip style] [skip vbump] Restyle files --- R/plotBounds.R | 23 +++--- design/design_doc_plotBounds.qmd | 122 +++++++++++++++---------------- 2 files changed, 72 insertions(+), 73 deletions(-) diff --git a/R/plotBounds.R b/R/plotBounds.R index 082a55b6..4b5e9794 100644 --- a/R/plotBounds.R +++ b/R/plotBounds.R @@ -28,18 +28,17 @@ #' @export #' @keywords graphics plotBounds <- function( - z, - area = TRUE, - grid = TRUE, - yt = "x", - add = FALSE, - cols = c("green", "red", "darkgreen", "orange"), - lwds = c(3, 3), - ltype = "l", - lpch = 16, - lcex = 1, - gy = 20 -) { + z, + area = TRUE, + grid = TRUE, + yt = "x", + add = FALSE, + cols = c("green", "red", "darkgreen", "orange"), + lwds = c(3, 3), + ltype = "l", + lpch = 16, + lcex = 1, + gy = 20) { n <- nrow(z) nmin <- min(z$looks) nmax <- max(z$looks) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 2c9fac37..16febfff 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -17,18 +17,17 @@ library(ggplot2) ```{r} vintage_plotBounds <- function( - z, - area = TRUE, - grid = TRUE, - yt = "x", - add = FALSE, - cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), - lwds = c(3, 3), - ltype = "l", - lpch = 16, - lcex = 1, - gy = 20 -) { + z, + area = TRUE, + grid = TRUE, + yt = "x", + add = FALSE, + cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), + lwds = c(3, 3), + ltype = "l", + lpch = 16, + lcex = 1, + gy = 20) { n <- nrow(z) nmin <- min(z$looks) nmax <- max(z$looks) @@ -119,7 +118,6 @@ vintage_plotBounds <- function( } return(invisible()) } - ``` # vintage example that should work with new function @@ -136,7 +134,6 @@ plotBounds( yt = "p", add = TRUE ) - ``` # vintage function output @@ -157,8 +154,8 @@ vintage_plotBounds( # new call function ```{r} -new_plotBounds <- function(coords, - postprob = TRUE, +new_plotBounds <- function(coords, + postprob = TRUE, go_colour = "#1B9E77", stop_colour = "#E41A1C", alpha = 1) { @@ -167,16 +164,16 @@ new_plotBounds <- function(coords, assert_character(go_colour) assert_character(stop_colour) assert_number(alpha, lower = 0, upper = 1) - + go_data <- data.frame( n = coords$looks, - ymin_go = coords$xU, - ymax_go = coords$looks + ymin_go = coords$xU, + ymax_go = coords$looks ) stop_data <- data.frame( n = coords$looks, - ymin_stop = c(rep(0, length(coords$looks))), - ymax_stop = coords$xL + ymin_stop = c(rep(0, length(coords$looks))), + ymax_stop = coords$xL ) plot <- ggplot2::ggplot() + ggplot2::geom_ribbon( @@ -187,7 +184,7 @@ new_plotBounds <- function(coords, ggplot2::geom_ribbon( data = go_data, ggplot2::aes(x = n, ymin = ymin_go, ymax = ymax_go), - fill = go_colour , alpha = alpha + fill = go_colour, alpha = alpha ) + ggplot2::scale_x_continuous( name = "n", @@ -196,26 +193,27 @@ new_plotBounds <- function(coords, ggplot2::scale_y_continuous( breaks = seq(from = 0, to = max(go_data$n), by = 2) ) + - ggplot2::geom_point( - data = go_data, - ggplot2::aes(x = n, y = ymin_go), - size = 3, - shape = 16, - colour = "#16C47F", - ) + - ggplot2::geom_point( - data = stop_data, - ggplot2::aes(x = n, y = ymax_stop), - size = 3, - shape = 16, - colour = "#FF748B", #"#DC3C22",FF748B - ) + + ggplot2::geom_point( + data = go_data, + ggplot2::aes(x = n, y = ymin_go), + size = 3, + shape = 16, + colour = "#16C47F", + ) + + ggplot2::geom_point( + data = stop_data, + ggplot2::aes(x = n, y = ymax_stop), + size = 3, + shape = 16, + colour = "#FF748B", # "#DC3C22",FF748B + ) + ggplot2::xlab("Sample Size (n)") + ggplot2::ylab("Number of Responders") + - ggplot2::theme_minimal() - - plot + ggplot2::ggtitle( - "Boundaries of Go and Stop Responders per sample size") + ggplot2::theme_minimal() + + plot + ggplot2::ggtitle( + "Boundaries of Go and Stop Responders per sample size" + ) } ``` @@ -245,27 +243,29 @@ When n = 40, 10 responders and above is a Go, 9 responders and below is a stop ```{r} coords <- boundsPredprob( - looks = c(10, 20, 30, 40), - p0 = 0.20, - tT = 0.80, - phiL = 0.10, - phiU = 0.90, - ) + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, +) print(coords) ``` ```{r} coords <- boundsPredprob( - looks = c(10, 20, 30, 40), - p0 = 0.20, - tT = 0.80, - phiL = 0.10, - phiU = 0.90, - ) -new_plotBounds(coords = coords, - go_colour = "blue", - alpha = 1) + looks = c(10, 20, 30, 40), + p0 = 0.20, + tT = 0.80, + phiL = 0.10, + phiU = 0.90, +) +new_plotBounds( + coords = coords, + go_colour = "blue", + alpha = 1 +) ``` # creating plots with new function with output from `boundsPostprob()` @@ -284,12 +284,12 @@ When n = 40, 12 responders and above is a Go, 11 responders and below is a stop ```{r} coords1 <- boundsPostprob( - looks = c(10, 20, 30, 40), - p0 = 0.20, - tL = 0.10, - tU = 0.90, - parE = c(1, 1) - ) + looks = c(10, 20, 30, 40), + p0 = 0.20, + tL = 0.10, + tU = 0.90, + parE = c(1, 1) +) new_plotBounds(coords1) ``` From e2398b8127f14d8ca7c5f444e262bf6f142671f8 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: Sat, 11 Oct 2025 11:40:08 +0000 Subject: [PATCH 08/17] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/sumBetaDiff.Rd | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..5cc1ae5e 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -27,14 +27,3 @@ along with the \code{go} and \code{stop} probabilities. A function to summarize the characters of a betadiff distribution \code{\link[=dbetadiff]{dbetadiff()}}. May require use of random sample generator to calculate, use \code{\link[=set.seed]{set.seed()}} to reproduce results. } -\examples{ -parX <- c(1, 52) # Control group's parameters -parY <- c(5.5, 20.5) # Treatment group's parameters -sumBetaDiff( - parX = parX, - parY = parY, - ci_level = 0.9, - go_cut = 0.6, - stop_cut = 0.2 -) -} From 6593aec23ba7463885a47b7461de008df28d71bb Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sat, 11 Oct 2025 13:41:23 +0200 Subject: [PATCH 09/17] empty commit From 3d3055dd8cc5e497f0585d442695e4938263ff54 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sat, 11 Oct 2025 19:22:05 +0200 Subject: [PATCH 10/17] remove flag --- design/design_doc_plotBounds.qmd | 2 -- 1 file changed, 2 deletions(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 16febfff..524ed18e 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -155,12 +155,10 @@ vintage_plotBounds( ```{r} new_plotBounds <- function(coords, - postprob = TRUE, go_colour = "#1B9E77", stop_colour = "#E41A1C", alpha = 1) { assert_data_frame(coords, any.missing = FALSE, types = "numeric") - assert_flag(postprob) assert_character(go_colour) assert_character(stop_colour) assert_number(alpha, lower = 0, upper = 1) From 3a5eb921795c63128aee0e18a6441a8f9fae026c Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 12 Oct 2025 16:13:02 +0200 Subject: [PATCH 11/17] Update design/design_doc_plotBounds.qmd Co-authored-by: Daniel Sabanes Bove --- design/design_doc_plotBounds.qmd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 524ed18e..f4a4f982 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -4,7 +4,9 @@ format: revealjs editor: visual --- -Statisticians can display boundaries of Go, Stop and GreyZone decisions graphically in terms of response rates required by desired samples sizes or looks. This is such purpose of `plotBounds`. Note that for the predictive probability case, decision 1 rules are chosen. See `ocPredprob` for rules. Design document aims to translate previous call function to use of more common packages such as `ggplot2` and reduce number of lines. +Statisticians can display boundaries of Go, Stop and GreyZone decisions graphically in terms of response rates required by desired samples sizes or looks. This is the purpose of the `plotBounds` function. Coordinates are the points where the polygon should be drawn and reflect the possible values for a go and stop decision respectively. + + Note that for the predictive probability case, decision 1 rules are chosen. See `ocPredprob` for rules. This design document aims to refactor the previous function, in particular to use `ggplot2` and reduce the length of the function. # packages that aid From e01e036f1c2fc41f7fde81854d5f8ec3680836c1 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 12 Oct 2025 16:13:28 +0200 Subject: [PATCH 12/17] Update design/design_doc_plotBounds.qmd Co-authored-by: Daniel Sabanes Bove --- design/design_doc_plotBounds.qmd | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index f4a4f982..713b8392 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -236,10 +236,11 @@ The criteria for interim analyses are from predictive probability calculation. The criteria for final analyses are from posterior probability calculation. which translates to boundaries : -When n = 10, 4 responders and above is a Go, 0 responders and below is a stop. -When n = 20, 7 responders and above is a Go, 2 responders and below is a stop -When n = 30, 9 responders and above is a Go, 5 responders and below is a stop -When n = 40, 10 responders and above is a Go, 9 responders and below is a stop + +- When n = 10, 4 responders and above is a Go, 0 responders and below is a stop. +- When n = 20, 7 responders and above is a Go, 2 responders and below is a stop +- When n = 30, 9 responders and above is a Go, 5 responders and below is a stop +- When n = 40, 10 responders and above is a Go, 9 responders and below is a stop ```{r} coords <- boundsPredprob( From b3a0255d6275fbe0e51381b14fe3a5077a7009d9 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 12 Oct 2025 16:13:41 +0200 Subject: [PATCH 13/17] Update design/design_doc_plotBounds.qmd Co-authored-by: Daniel Sabanes Bove --- design/design_doc_plotBounds.qmd | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 713b8392..7c200b8f 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -277,10 +277,11 @@ As a premise, we establish the criteria: Go : P(RR > 0.20 | data) > 90 % Stop : P(RR > 0.20 | data) > 10 % which translates to boundaries : -When n = 10, 4 responders and above is a Go, 3 responders and below is a stop. -When n = 20, 7 responders and above is a Go, 6 responders and below is a stop -When n = 30, 9 responders and above is a Go, 8 responders and below is a stop -When n = 40, 12 responders and above is a Go, 11 responders and below is a stop + +- When n = 10, 4 responders and above is a Go, 3 responders and below is a stop. +- When n = 20, 7 responders and above is a Go, 6 responders and below is a stop +- When n = 30, 9 responders and above is a Go, 8 responders and below is a stop +- When n = 40, 12 responders and above is a Go, 11 responders and below is a stop ```{r} From 16aafbdd59b6024fe16b7d722cd43777abb37b37 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 12 Oct 2025 16:31:48 +0200 Subject: [PATCH 14/17] Update design/design_doc_plotBounds.qmd Co-authored-by: Daniel Sabanes Bove --- design/design_doc_plotBounds.qmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 7c200b8f..2794058e 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -271,7 +271,7 @@ new_plotBounds( # creating plots with new function with output from `boundsPostprob()` -The following output show that important coordinates needed as input to create these plots. Coordinates are the points where the polygon should be drawn and reflect the possible values for a go and stop decision respectively. +The following output show which inputs from a posterior probability design are needed to create these plots. As a premise, we establish the criteria: Go : P(RR > 0.20 | data) > 90 % From 155d3effa47eeecd1d2f07a2406e8fdbd1d20604 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sun, 12 Oct 2025 19:55:21 +0200 Subject: [PATCH 15/17] clean --- design/design_doc_plotBounds.qmd | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 2794058e..6cc2a0eb 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -8,14 +8,14 @@ Statisticians can display boundaries of Go, Stop and GreyZone decisions graphica Note that for the predictive probability case, decision 1 rules are chosen. See `ocPredprob` for rules. This design document aims to refactor the previous function, in particular to use `ggplot2` and reduce the length of the function. -# packages that aid +# Packages that aid ```{r} library(flextable) library(ggplot2) ``` -# vintage function +# Vintage function ```{r} vintage_plotBounds <- function( @@ -122,7 +122,7 @@ vintage_plotBounds <- function( } ``` -# vintage example that should work with new function +# Vintage example that should work with new function ```{r} plotBounds( @@ -138,7 +138,7 @@ plotBounds( ) ``` -# vintage function output +# Vintage function output ```{r} vintage_plotBounds( @@ -153,7 +153,9 @@ vintage_plotBounds( ) ``` -# new call function +# New call function + +There are two good options to graph polygons to reflect the purpose of this function. The use of base r's `polygon()` is slightly more laborious; once minimum and maximum coordinates are established, approximation of these points are then required to draw the borders of this polygon. This step can be removed using the `geom_ribbon` call from the package `ggplot2`. Furthermore, the base r approach require the initial plot area to be created, and axes, axes labels, and points to be overlayed. There are additional steps that are also taken in the `ggplot2` approach, however done within a code chunk rather than separated calls. While it can be argued that these additional calls from the base r approach would anyway be encapsulated in one function, that is `plotbound`, the number of code lines is substantially reduced using the `ggplot` approach. ```{r} new_plotBounds <- function(coords, @@ -295,7 +297,8 @@ coords1 <- boundsPostprob( new_plotBounds(coords1) ``` - ++ggplot2 vs base R ++https://r-graphics.org/CHAPTER-GGPLOT2.html From 6a8d1c71c5b179d4f043325a6d1eaac33900e989 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 10 Dec 2025 12:28:53 +0100 Subject: [PATCH 16/17] fix error --- R/ocPredprob.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/ocPredprob.R b/R/ocPredprob.R index a436ac59..1ceb08c3 100644 --- a/R/ocPredprob.R +++ b/R/ocPredprob.R @@ -58,7 +58,7 @@ h_get_decision_one_predprob <- function(nnr, truep, p0, parE = c(1, 1), nnE, nnF thetaT = tT, parE = parE )$result - decision <- ifelse(interim_qU > phiU, FALSE, decision) + decision <- ifelse(interim_qU > phiU, TRUE, decision) all_looks <- orig_nnr[index_look] } if (size_look %in% nnF) { From fdaad5bf5ace5caea963ef68004131a05641c02e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 06:16:02 +0000 Subject: [PATCH 17/17] [skip style] [skip vbump] Restyle files --- R/plotBounds.R | 23 ++++++++++++----------- design/design_doc_plotBounds.qmd | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/R/plotBounds.R b/R/plotBounds.R index 4b5e9794..082a55b6 100644 --- a/R/plotBounds.R +++ b/R/plotBounds.R @@ -28,17 +28,18 @@ #' @export #' @keywords graphics plotBounds <- function( - z, - area = TRUE, - grid = TRUE, - yt = "x", - add = FALSE, - cols = c("green", "red", "darkgreen", "orange"), - lwds = c(3, 3), - ltype = "l", - lpch = 16, - lcex = 1, - gy = 20) { + z, + area = TRUE, + grid = TRUE, + yt = "x", + add = FALSE, + cols = c("green", "red", "darkgreen", "orange"), + lwds = c(3, 3), + ltype = "l", + lpch = 16, + lcex = 1, + gy = 20 +) { n <- nrow(z) nmin <- min(z$looks) nmax <- max(z$looks) diff --git a/design/design_doc_plotBounds.qmd b/design/design_doc_plotBounds.qmd index 6cc2a0eb..6f8a73a3 100644 --- a/design/design_doc_plotBounds.qmd +++ b/design/design_doc_plotBounds.qmd @@ -19,17 +19,18 @@ library(ggplot2) ```{r} vintage_plotBounds <- function( - z, - area = TRUE, - grid = TRUE, - yt = "x", - add = FALSE, - cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), - lwds = c(3, 3), - ltype = "l", - lpch = 16, - lcex = 1, - gy = 20) { + z, + area = TRUE, + grid = TRUE, + yt = "x", + add = FALSE, + cols = c("#009E73", "#FF0046", "#7F55B1", "#F0A04B"), + lwds = c(3, 3), + ltype = "l", + lpch = 16, + lcex = 1, + gy = 20 +) { n <- nrow(z) nmin <- min(z$looks) nmax <- max(z$looks)