From e9033c026e081fb54555bd38cd6c425a92ad37f9 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 8 May 2025 12:48:10 +0200 Subject: [PATCH 01/67] clean --- examples/ocPredprobDist.R | 8 ++++---- man/ocPredprobDist.Rd | 8 ++++---- tests/testthat/test-ocPredprobDist.R | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/ocPredprobDist.R b/examples/ocPredprobDist.R index 7ebee7e1..11066779 100644 --- a/examples/ocPredprobDist.R +++ b/examples/ocPredprobDist.R @@ -23,7 +23,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, wiggle = FALSE, decision1 = TRUE ) @@ -57,7 +57,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, nnF = c(20, 30), wiggle = TRUE, decision1 = TRUE @@ -91,7 +91,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, nnF = c(10, 20, 30), wiggle = TRUE, decision1 = FALSE @@ -124,7 +124,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, nnF = c(10, 20, 30), wiggle = TRUE, decision1 = FALSE diff --git a/man/ocPredprobDist.Rd b/man/ocPredprobDist.Rd index 85eef12a..2da1b9a9 100644 --- a/man/ocPredprobDist.Rd +++ b/man/ocPredprobDist.Rd @@ -157,7 +157,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, wiggle = FALSE, decision1 = TRUE ) @@ -191,7 +191,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, nnF = c(20, 30), wiggle = TRUE, decision1 = TRUE @@ -225,7 +225,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, nnF = c(10, 20, 30), wiggle = TRUE, decision1 = FALSE @@ -258,7 +258,7 @@ result <- ocPredprobDist( parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 15, nnF = c(10, 20, 30), wiggle = TRUE, decision1 = FALSE diff --git a/tests/testthat/test-ocPredprobDist.R b/tests/testthat/test-ocPredprobDist.R index bfed99fc..4a7a5e44 100644 --- a/tests/testthat/test-ocPredprobDist.R +++ b/tests/testthat/test-ocPredprobDist.R @@ -85,7 +85,7 @@ test_that("ocPredprobDist gives correct result and list when relativeDelta = FAL parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 5, nnF = c(10, 20, 30), wiggle = TRUE, decision1 = FALSE @@ -112,7 +112,7 @@ test_that("ocPredprobDist gives correct result and list when relativeDelta = TRU parS = c(5, 25), weights = 1, weightsS = 1, - sim = 50, + sim = 5, nnF = c(10, 20, 30), wiggle = TRUE, decision1 = FALSE From 68d43b3c8c6ad69eb9002e9650c898c20c807b70 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 12 May 2025 18:28:35 +0200 Subject: [PATCH 02/67] clean --- R/plotDecision.R | 54 ++++++++++++++++++++++++++++------------- examples/plotDecision.R | 17 +++++++++++-- man/plotDecision.Rd | 12 ++++----- 3 files changed, 58 insertions(+), 25 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index 1a3a9594..5512b7d6 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -2,9 +2,10 @@ #' #' This function will return a plot showing a curve of the prob of a meaningful improvement over estunated diff #' and a curve of the prob of a poor improvement over estunated diff -#' @param data the output object of \code{\link{sumTable}} -#' @param Pos_cut a cut off for the prob of a meaningful improvement -#' @param Neg_cut a cut off for the prob of a poor improvement +#' +#' @inheritParams plotBetaDiff +#' @typed data : data.frame +#' sourced [`data.frame`] from [(sumTable)] #' @return the \code{data} item which was imputed to the function #' #' @importFrom graphics lines abline polygon plot par grid mtext box axis @@ -12,7 +13,17 @@ #' @example examples/plotDecision.R #' @export #' @keywords graphics -plotDecision <- function(data, Pos_cut, Neg_cut) { +plotDecision <- function(data, go_cut, stop_cut) { + assert_data_frame(data, any.missing = FALSE) + assert_number(go_cut, finite = TRUE) + assert_number(stop_cut, finite = TRUE) +# +# diff <- seq(from = -1, to = 1, length = 1000) +# data <- data.frame( +# grid = diff, +# density = dbetadiff(z = diff, parY = parY, parX = parX) +# ) + xticks <- seq(from = -50, to = 100, by = 10) x <- as.numeric(data[1, ]) # number of response; @@ -29,16 +40,25 @@ plotDecision <- function(data, Pos_cut, Neg_cut) { colnames(ShadeData) # Green area; - G_area <- ShadeData[ShadeData[, "prob.go [%]"] > Pos_cut, ] + G_area <- ShadeData[ShadeData[, "prob.go [%]"] > go_cut, ] # Red ares; - R_area <- ShadeData[ShadeData[, "prob.nogo [%]"] > Neg_cut, ] + R_area <- ShadeData[ShadeData[, "prob.nogo [%]"] > stop_cut, ] graphics::par(mar = c(5, 4, 4, 1) + .1) - graphics::plot(x.mode, y, - type = "n", xlim = range(x.mode), bty = "n", ylab = "Probability (%)", xaxt = "n", xaxs = "i", yaxs = "i", - xlab = expression(paste("Estimated diff.", sep = "")), ylim = c(0, 100), panel.first = grid() + graphics::plot(x.mode, + y, + type = "n", + xlim = range(x.mode), + bty = "n", + ylab = "Probability (%)", + xaxt = "n", + xaxs = "i", + yaxs = "i", + xlab = expression(paste("Estimated diff.", sep = "")), + ylim = c(0, 100), + panel.first = grid() ) @@ -47,9 +67,9 @@ plotDecision <- function(data, Pos_cut, Neg_cut) { # Green area; - aboveG <- ShadeData[, "prob.go [%]"] > Pos_cut + aboveG <- ShadeData[, "prob.go [%]"] > go_cut # Red ares; - aboveR <- ShadeData[, "prob.nogo [%]"] > Neg_cut + aboveR <- ShadeData[, "prob.nogo [%]"] > stop_cut # Points always intersect when above=TRUE, then FALSE or reverse intersect.pointsG <- which(diff(aboveG) != 0) @@ -63,12 +83,12 @@ plotDecision <- function(data, Pos_cut, Neg_cut) { x2.slopes <- 0 # Find the intersection for each segment. x.pointsG <- ShadeData[intersect.pointsG, "mode [%]"] + - ((Pos_cut - ShadeData[intersect.pointsG, "prob.go [%]"]) / (x1.slopesG)) - y.pointsG <- Pos_cut + ((go_cut - ShadeData[intersect.pointsG, "prob.go [%]"]) / (x1.slopesG)) + y.pointsG <- go_cut x.pointsR <- ShadeData[intersect.pointsR, "mode [%]"] + - ((Neg_cut - ShadeData[intersect.pointsR, "prob.nogo [%]"]) / (x1.slopesR)) - y.pointsR <- Neg_cut + ((stop_cut - ShadeData[intersect.pointsR, "prob.nogo [%]"]) / (x1.slopesR)) + y.pointsR <- stop_cut graphics::polygon(c(R_area[, "mode [%]"], x.pointsR, x.pointsR, rev(R_area[, "mode [%]"])), @@ -120,8 +140,8 @@ plotDecision <- function(data, Pos_cut, Neg_cut) { - if (Pos_cut == Neg_cut) { - graphics::abline(h = Pos_cut, col = "black", lwd = 2) + if (go_cut == stop_cut) { + graphics::abline(h = go_cut, col = "black", lwd = 2) } graphics::box() diff --git a/examples/plotDecision.R b/examples/plotDecision.R index 7966baeb..4f6770f3 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -7,6 +7,19 @@ sumTable( stop_cut = 0.4 ) +summaries <- do.call( + cbind, + lapply(c(0:8), + sumTable, + TotalSample = 25, + parX = c(1, 52), + go_cut = 0.2, + stop_cut = 0.05 + ) +) + +plotDecision(summaries, go_cut = 60, stop_cut = 60) + # plotting more results summaries <- do.call( cbind, @@ -14,9 +27,9 @@ summaries <- do.call( sumTable, TotalSample = 25, parX = c(1, 52), - go_cut = 0.6, + go_cut = 0.5, stop_cut = 0.2 ) ) -# plotDecision(summaries, Pos_cut = 60, Neg_cut = 60) +plotDecision(summaries, go_cut = 10, stop_cut = 2) diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index da2acdae..6b1f20da 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -4,14 +4,14 @@ \alias{plotDecision} \title{Plot a summary plot corresponding to the sumTable output} \usage{ -plotDecision(data, Pos_cut, Neg_cut) +plotDecision(data, go_cut, stop_cut) } \arguments{ -\item{data}{the output object of \code{\link{sumTable}}} +\item{data}{(\code{data.frame}):\cr sourced \code{\link{data.frame}} from \link{(sumTable)}} -\item{Pos_cut}{a cut off for the prob of a meaningful improvement} +\item{go_cut}{(\code{number}):\cr a meaningful improvement threshold, the lower boundary of a meaningfully improvement in response rate} -\item{Neg_cut}{a cut off for the prob of a poor improvement} +\item{stop_cut}{(\code{number}):\cr a poor improvement threshold, the upper boundary of a meaningfully poor improvement in response rate} } \value{ the \code{data} item which was imputed to the function @@ -37,11 +37,11 @@ summaries <- do.call( sumTable, TotalSample = 25, parX = c(1, 52), - go_cut = 0.6, + go_cut = 0.5, stop_cut = 0.2 ) ) -# plotDecision(summaries, Pos_cut = 60, Neg_cut = 60) +plotDecision(summaries, go_cut = 10, stop_cut = 2) } \keyword{graphics} From 85ddbe850da537b64607f190bed2dc6b583d763e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 12 May 2025 16:31:00 +0000 Subject: [PATCH 03/67] [skip style] [skip vbump] Restyle files --- R/plotDecision.R | 34 +++++++++++++++++----------------- examples/plotDecision.R | 10 +++++----- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index 5512b7d6..be2921f7 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -17,12 +17,12 @@ plotDecision <- function(data, go_cut, stop_cut) { assert_data_frame(data, any.missing = FALSE) assert_number(go_cut, finite = TRUE) assert_number(stop_cut, finite = TRUE) -# -# diff <- seq(from = -1, to = 1, length = 1000) -# data <- data.frame( -# grid = diff, -# density = dbetadiff(z = diff, parY = parY, parX = parX) -# ) + # + # diff <- seq(from = -1, to = 1, length = 1000) + # data <- data.frame( + # grid = diff, + # density = dbetadiff(z = diff, parY = parY, parX = parX) + # ) xticks <- seq(from = -50, to = 100, by = 10) @@ -48,17 +48,17 @@ plotDecision <- function(data, go_cut, stop_cut) { graphics::plot(x.mode, - y, - type = "n", - xlim = range(x.mode), - bty = "n", - ylab = "Probability (%)", - xaxt = "n", - xaxs = "i", - yaxs = "i", - xlab = expression(paste("Estimated diff.", sep = "")), - ylim = c(0, 100), - panel.first = grid() + y, + type = "n", + xlim = range(x.mode), + bty = "n", + ylab = "Probability (%)", + xaxt = "n", + xaxs = "i", + yaxs = "i", + xlab = expression(paste("Estimated diff.", sep = "")), + ylim = c(0, 100), + panel.first = grid() ) diff --git a/examples/plotDecision.R b/examples/plotDecision.R index 4f6770f3..30319694 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -10,11 +10,11 @@ sumTable( summaries <- do.call( cbind, lapply(c(0:8), - sumTable, - TotalSample = 25, - parX = c(1, 52), - go_cut = 0.2, - stop_cut = 0.05 + sumTable, + TotalSample = 25, + parX = c(1, 52), + go_cut = 0.2, + stop_cut = 0.05 ) ) From 4a28e601b2aee9556766e20bdd951b4054852bee 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, 12 May 2025 16:31:28 +0000 Subject: [PATCH 04/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/plotDecision.Rd | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 6b1f20da..a7f63600 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -30,6 +30,19 @@ sumTable( stop_cut = 0.4 ) +summaries <- do.call( + cbind, + lapply(c(0:8), + sumTable, + TotalSample = 25, + parX = c(1, 52), + go_cut = 0.2, + stop_cut = 0.05 + ) +) + +plotDecision(summaries, go_cut = 60, stop_cut = 60) + # plotting more results summaries <- do.call( cbind, From c743510f5b69f5e9d0f01ecb18ea058d943bb9b6 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 7 May 2025 17:31:07 +0200 Subject: [PATCH 05/67] 101 sum table (#133) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Daniel Sabanes Bove Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> --- R/sumTable.R | 56 +++++++++++---------- R/sumbetadiff.R | 38 +++++++-------- examples/plotDecision.R | 6 +-- examples/sumTable.R | 11 ++++- man/plotDecision.Rd | 6 +-- man/sumTable.Rd | 29 ++++++----- tests/testthat/test-sumTable.R | 89 ++++++++++++++++++++++++++++++++++ 7 files changed, 168 insertions(+), 67 deletions(-) create mode 100644 tests/testthat/test-sumTable.R diff --git a/R/sumTable.R b/R/sumTable.R index 0bbec8c1..24fd35dd 100644 --- a/R/sumTable.R +++ b/R/sumTable.R @@ -3,53 +3,59 @@ #' This function will calculate the summary statistics for a specific response #' outcome scenario. #' +#' @inheritParams postprob #' @inheritParams sumBetaDiff -#' @typed thisResp : number -#' number of responses -#' @typed TotalSample : number -#' sample size -#' @typed YPri : numeric -#' non-negative parameters of the beta prior of the treatment, default Beta(0.5,0.5) -#' @typed Round : number -#' Rounding of the output statistics +#' @typed round : number +#' Digit rounding of the output statistics #' #' @return A vector with the results. #' #' @example examples/sumTable.R #' @export -sumTable <- function(thisResp, # number of responses; - TotalSample, # Sample size; - go_cut, # meaningful improvement: at least cut_B (say 15\%) improvement; - stop_cut, # poor improvement: at most cut_W (say 5\%) improvement; - parX, # Two typedeters of the beta distribution of the control (posterior); - YPri = c(0.5, 0.5), # Prior of phase Ib trial, default Beta(0.5,0.5) - Round = 2) { +sumTable <- function(x, + n, + go_cut, + stop_cut, + parX, + parY = c(0.5, 0.5), + round = 2) { + assert_numeric(x, lower = 0, upper = n, finite = TRUE) + assert_number(n, lower = 0, finite = TRUE) + assert_number(go_cut, finite = TRUE) + assert_number(stop_cut, finite = TRUE) + assert_numeric(parY, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) + assert_numeric(parX, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) + assert_count(round) + tmp <- sumBetaDiff( parX = parX, parY = c( - thisResp + YPri[1], - TotalSample - thisResp + YPri[2] + x + parY[1], + n - x + parY[2] ), go_cut = go_cut, stop_cut = stop_cut ) - summaries <- round(c( - thisResp, - thisResp / TotalSample * 100, + x, + x / n * 100, tmp$mode * 100, tmp$ci * 100, tmp$go * 100, tmp$stop * 100 - ), Round) + ), round) summaries <- as.data.frame(summaries) rownames(summaries) <- c( - "# resp", "obs ORR [%]", "mode [%]", - "CI lower [%]", "CI upper [%]", "prob.go [%]", "prob.nogo [%]" + "responders", + "obs ORR [%]", + "mode [%]", + "CI lower [%]", + "CI upper [%]", + "prob.go [%]", + "prob.nogo [%]" ) - - return(summaries) + summaries } diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index c89939e6..e1899d84 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -1,22 +1,22 @@ -##' Mode and Credible Interval Calculation for The Difference between Two Beta Distributions -##' -##' @description `r lifecycle::badge("experimental")` -##' -##' A function to summarize the characters of a betadiff distribution [dbetadiff()]. -##' May require use of random sample generator to calculate, use [set.seed()] to reproduce results. -##' -##' @inheritParams dbetadiff -##' @inheritParams plotBetaDiff -##' @typed ci_level : numeric -##' level for credible interval -##' -##' @return List with the mode, credible interval for the difference, -##' along with the `go` and `stop` probabilities. -##' -##' @importFrom stats optimize integrate -##' -##' @example examples/sumbetadiff.R -##' @export +#' Mode and Credible Interval Calculation for The Difference between Two Beta Distributions +#' +#' @description `r lifecycle::badge("experimental")` +#' +#' A function to summarize the characters of a betadiff distribution [dbetadiff()]. +#' May require use of random sample generator to calculate, use [set.seed()] to reproduce results. +#' +#' @inheritParams dbetadiff +#' @inheritParams plotBetaDiff +#' @typed ci_level : numeric +#' level for credible interval +#' +#' @return List with the mode, credible interval for the difference, +#' along with the `go` and `stop` probabilities. +#' +#' @importFrom stats optimize integrate +#' +#' @example examples/sumbetadiff.R +#' @export sumBetaDiff <- function(parX, # Treatment group's parameters parY, # Control group's parameters ci_level = 0.9, diff --git a/examples/plotDecision.R b/examples/plotDecision.R index 30319694..cf2a74bd 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -1,7 +1,7 @@ # sumTable ---- sumTable( - thisResp = 10, - TotalSample = 20, + x = 10, + n = 20, parX = c(1, 1), go_cut = 0.8, stop_cut = 0.4 @@ -25,7 +25,7 @@ summaries <- do.call( cbind, lapply(c(0:8), sumTable, - TotalSample = 25, + n = 25, parX = c(1, 52), go_cut = 0.5, stop_cut = 0.2 diff --git a/examples/sumTable.R b/examples/sumTable.R index 18f7eee9..64e9b5c4 100644 --- a/examples/sumTable.R +++ b/examples/sumTable.R @@ -1,11 +1,18 @@ -sumTable(2, 25, parX = c(1, 52), go_cut = 0.2, stop_cut = 0.05, YPri = c(1, 1)) +sumTable( + x = 2, + n = 25, + parX = c(1, 52), + parY = c(1, 1), + go_cut = 0.2, + stop_cut = 0.05 +) # for multiple response scenarios (e.g. 0 to 8 responses out of 25) summaries <- do.call( cbind, lapply(c(0:8), sumTable, - TotalSample = 25, + n = 25, parX = c(1, 52), go_cut = 0.2, stop_cut = 0.05 diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index a7f63600..1ee7f5ee 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -23,8 +23,8 @@ and a curve of the prob of a poor improvement over estunated diff \examples{ # sumTable ---- sumTable( - thisResp = 10, - TotalSample = 20, + x = 10, + n = 20, parX = c(1, 1), go_cut = 0.8, stop_cut = 0.4 @@ -48,7 +48,7 @@ summaries <- do.call( cbind, lapply(c(0:8), sumTable, - TotalSample = 25, + n = 25, parX = c(1, 52), go_cut = 0.5, stop_cut = 0.2 diff --git a/man/sumTable.Rd b/man/sumTable.Rd index e7f5e6e2..483f9179 100644 --- a/man/sumTable.Rd +++ b/man/sumTable.Rd @@ -4,20 +4,12 @@ \alias{sumTable} \title{Return summary statistics under one response scenario} \usage{ -sumTable( - thisResp, - TotalSample, - go_cut, - stop_cut, - parX, - YPri = c(0.5, 0.5), - Round = 2 -) +sumTable(x, n, go_cut, stop_cut, parX, parY = c(0.5, 0.5), round = 2) } \arguments{ -\item{thisResp}{(\code{number}):\cr number of responses} +\item{x}{(\code{numeric}):\cr number of successes.} -\item{TotalSample}{(\code{number}):\cr sample size} +\item{n}{(\code{number}):\cr number of patients.} \item{go_cut}{(\code{number}):\cr a meaningful improvement threshold, the lower boundary of a meaningfully improvement in response rate} @@ -25,9 +17,9 @@ sumTable( \item{parX}{(\code{numeric}):\cr two parameters of \code{X}'s Beta distribution (Control)} -\item{YPri}{(\code{numeric}):\cr non-negative parameters of the beta prior of the treatment, default Beta(0.5,0.5)} +\item{parY}{(\code{numeric}):\cr two parameters of \code{Y}'s Beta distribution (Treatment)} -\item{Round}{(\code{number}):\cr Rounding of the output statistics} +\item{round}{(\code{number}):\cr Digit rounding of the output statistics} } \value{ A vector with the results. @@ -37,14 +29,21 @@ This function will calculate the summary statistics for a specific response outcome scenario. } \examples{ -sumTable(2, 25, parX = c(1, 52), go_cut = 0.2, stop_cut = 0.05, YPri = c(1, 1)) +sumTable( + x = 2, + n = 25, + parX = c(1, 52), + parY = c(1, 1), + go_cut = 0.2, + stop_cut = 0.05 +) # for multiple response scenarios (e.g. 0 to 8 responses out of 25) summaries <- do.call( cbind, lapply(c(0:8), sumTable, - TotalSample = 25, + n = 25, parX = c(1, 52), go_cut = 0.2, stop_cut = 0.05 diff --git a/tests/testthat/test-sumTable.R b/tests/testthat/test-sumTable.R new file mode 100644 index 00000000..02966572 --- /dev/null +++ b/tests/testthat/test-sumTable.R @@ -0,0 +1,89 @@ +# sumTable ---- +test_that("sumTable works as expected", { + result <- sumTable( + x = 2, + n = 40, + parX = c(1, 52), # Control group's parameters + parY = c(1, 1), # Treatment group's parameters + go_cut = 0.2, + stop_cut = 0.05 + ) + expected <- data.frame( + list( + summaries = c( + 2, + 5, + 3.66, + -0.92, + 13.07, + 0.37, + 52.26 + ) + ), + row.names = c( + "responders", + "obs ORR [%]", + "mode [%]", + "CI lower [%]", + "CI upper [%]", + "prob.go [%]", + "prob.nogo [%]" + ) + ) + expect_identical(result, expected) +}) + +test_that("sumTable gives a error when at least one beta prior parameter is 0", { + expect_error( + sumTable( + x = 2, + n = 40, + parX = c(0, 10), # Control group's parameters + parY = c(1, 1), # Treatment group's parameters + go_cut = 0.2, + stop_cut = 0.05 + ), + label = "Assertion on parX failed Element 1 is not >=" + ) +}) + +test_that("sumTable works as expected when x = 0", { + result <- sumTable( + x = 0, + n = 40, + parX = c(2, 10), # Control group's parameters + parY = c(1, 1), # Treatment group's parameters + go_cut = 0.2, + stop_cut = 0.05 + ) + expected <- data.frame( + list( + summaries = c(0, 0, -8.03, -34.32, -0.44, 0, 99.53) + ), + row.names = + c( + "responders", + "obs ORR [%]", + "mode [%]", + "CI lower [%]", + "CI upper [%]", + "prob.go [%]", + "prob.nogo [%]" + ) + ) + expect_equal(result, expected) +}) + +test_that("sumTable gives an error as expected when n = 0", { + expect_error( + sumTable( + x = 5, + n = 0, + parX = c(2, 10), # Control group's parameters + parY = c(1, 1), # Treatment group's parameters + go_cut = 0.2, + stop_cut = 0.05 + ), + label = "Assertion on x failed Element 1 is not <= 0" + ) +}) From 622b58383b8b3d07232ced84421fc18a21cb933d 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, 12 May 2025 18:21:49 +0000 Subject: [PATCH 06/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- man/plotDecision.Rd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 1ee7f5ee..4cb74217 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -33,11 +33,11 @@ sumTable( summaries <- do.call( cbind, lapply(c(0:8), - sumTable, - TotalSample = 25, - parX = c(1, 52), - go_cut = 0.2, - stop_cut = 0.05 + sumTable, + TotalSample = 25, + parX = c(1, 52), + go_cut = 0.2, + stop_cut = 0.05 ) ) From 3e4f0a9d18ce87b45dc54958e3739cb3cf4d22da Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 10:45:29 +0200 Subject: [PATCH 07/67] clean --- R/plotDecision.R | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index be2921f7..f0884448 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -17,12 +17,7 @@ plotDecision <- function(data, go_cut, stop_cut) { assert_data_frame(data, any.missing = FALSE) assert_number(go_cut, finite = TRUE) assert_number(stop_cut, finite = TRUE) - # - # diff <- seq(from = -1, to = 1, length = 1000) - # data <- data.frame( - # grid = diff, - # density = dbetadiff(z = diff, parY = parY, parX = parX) - # ) + xticks <- seq(from = -50, to = 100, by = 10) @@ -48,17 +43,17 @@ plotDecision <- function(data, go_cut, stop_cut) { graphics::plot(x.mode, - y, - type = "n", - xlim = range(x.mode), - bty = "n", - ylab = "Probability (%)", - xaxt = "n", - xaxs = "i", - yaxs = "i", - xlab = expression(paste("Estimated diff.", sep = "")), - ylim = c(0, 100), - panel.first = grid() + y, + type = "n", + xlim = range(x.mode), + bty = "n", + ylab = "Probability (%)", + xaxt = "n", + xaxs = "i", + yaxs = "i", + xlab = expression(paste("Estimated diff.", sep = "")), + ylim = c(0, 100), + panel.first = grid() ) From 74619fc1e3d78b40102ae8d2204a71cd4e1f8a74 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 7 May 2025 17:31:07 +0200 Subject: [PATCH 08/67] 101 sum table (#133) Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Daniel Sabanes Bove Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> --- examples/plotDecision.R | 2 +- man/plotDecision.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/plotDecision.R b/examples/plotDecision.R index cf2a74bd..d5096c45 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -11,7 +11,7 @@ summaries <- do.call( cbind, lapply(c(0:8), sumTable, - TotalSample = 25, + n = 25, parX = c(1, 52), go_cut = 0.2, stop_cut = 0.05 diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 4cb74217..92e13f68 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -34,7 +34,7 @@ summaries <- do.call( cbind, lapply(c(0:8), sumTable, - TotalSample = 25, + n = 25, parX = c(1, 52), go_cut = 0.2, stop_cut = 0.05 From 7d6592f1d77d56dad7c241154e820a9dffa7fd8f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 11:56:33 +0200 Subject: [PATCH 09/67] clean --- R/plotDecision.R | 146 +++++++---------------------------------------- 1 file changed, 22 insertions(+), 124 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index f0884448..6b796eb9 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -18,135 +18,33 @@ plotDecision <- function(data, go_cut, stop_cut) { assert_number(go_cut, finite = TRUE) assert_number(stop_cut, finite = TRUE) + data <- data.frame(t(data)) - xticks <- seq(from = -50, to = 100, by = 10) + data <- tibble::remove_rownames(data) - x <- as.numeric(data[1, ]) # number of response; + colnames(data) <- c("responders", + "obs", + "mode", + "ci_lower", + "ci_upper", + "prob_go", + "prob_stop") - x.mode <- as.numeric(data[3, ]) # the response diff mode + go_shade <- data[data$prob_go > go_cut,] - y <- as.numeric(data[6, ]) # The Prob of a meaningful improvement + stop_shade <- data[data$prob_stop > stop_cut,] - z <- as.numeric(data[7, ]) # The Prob of a not meaningful improvement + ggplot2::ggplot(go_shade) + + geom_area(ggplot2::aes(x = mode, y = prob_go)) - # Look up decision area; - ShadeData <- t(data) + ggplot2::ggplot(data) + + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + + ggplot2::theme_light() + + ggplot2::geom_area(data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), fill = "#009E73") + + ggplot2::geom_line(data = data, ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + + ggplot2::geom_area(data = stop_shade, mapping = ggplot2::aes(x = mode, y = prob_stop), fill = "#FF0046") + + ggplot2::ggtitle("Prob") + + ggplot2::xlab("") + + ggplot2::ylab("") - colnames(ShadeData) - - # Green area; - G_area <- ShadeData[ShadeData[, "prob.go [%]"] > go_cut, ] - # Red ares; - R_area <- ShadeData[ShadeData[, "prob.nogo [%]"] > stop_cut, ] - - graphics::par(mar = c(5, 4, 4, 1) + .1) - - - graphics::plot(x.mode, - y, - type = "n", - xlim = range(x.mode), - bty = "n", - ylab = "Probability (%)", - xaxt = "n", - xaxs = "i", - yaxs = "i", - xlab = expression(paste("Estimated diff.", sep = "")), - ylim = c(0, 100), - panel.first = grid() - ) - - - - # find the interaction; - - - # Green area; - aboveG <- ShadeData[, "prob.go [%]"] > go_cut - # Red ares; - aboveR <- ShadeData[, "prob.nogo [%]"] > stop_cut - - # Points always intersect when above=TRUE, then FALSE or reverse - intersect.pointsG <- which(diff(aboveG) != 0) - intersect.pointsR <- which(diff(aboveR) != 0) - # Find the slopes for each line segment. - x1.slopesG <- (ShadeData[intersect.pointsG + 1, "prob.go [%]"] - ShadeData[intersect.pointsG, "prob.go [%]"]) / - (ShadeData[intersect.pointsG + 1, "mode [%]"] - ShadeData[intersect.pointsG, "mode [%]"]) - x1.slopesR <- (ShadeData[intersect.pointsR + 1, "prob.nogo [%]"] - ShadeData[intersect.pointsR, "prob.nogo [%]"]) / - (ShadeData[intersect.pointsR + 1, "mode [%]"] - ShadeData[intersect.pointsR, "mode [%]"]) - - x2.slopes <- 0 - # Find the intersection for each segment. - x.pointsG <- ShadeData[intersect.pointsG, "mode [%]"] + - ((go_cut - ShadeData[intersect.pointsG, "prob.go [%]"]) / (x1.slopesG)) - y.pointsG <- go_cut - - x.pointsR <- ShadeData[intersect.pointsR, "mode [%]"] + - ((stop_cut - ShadeData[intersect.pointsR, "prob.nogo [%]"]) / (x1.slopesR)) - y.pointsR <- stop_cut - - - graphics::polygon(c(R_area[, "mode [%]"], x.pointsR, x.pointsR, rev(R_area[, "mode [%]"])), - c(rep(0, dim(R_area)[1] + 1), y.pointsR, rev(R_area[, "prob.nogo [%]"])), - col = "red" - ) - - graphics::mtext( - paste( - "Est. Diff=", - round(x.pointsR), - "%, Prob.nogo=", - round(y.pointsR), - "%", - sep = "" - ), - side = 3, - line = 2 - ) - - graphics::polygon( - c( - x.pointsG, G_area[, "mode [%]"], - rev(G_area[, "mode [%]"]), x.pointsG - ), - c( - rep(0, dim(G_area)[1] + 1), - rev(G_area[, "prob.go [%]"]), y.pointsG - ), - col = "green" - ) # meaningful part; - - graphics::mtext( - paste( - "Est. Diff=", - round(x.pointsG), - "%,Prob. go=", - round(y.pointsG), - "%", - sep = "" - ), - side = 3, - line = 1 - ) - - graphics::lines(x.mode, y, col = "green", lwd = 3, type = "l") # Plot PDF of beta(R,NR); - - graphics::lines(x.mode, z, col = "red", lwd = 3, type = "l") - - - - if (go_cut == stop_cut) { - graphics::abline(h = go_cut, col = "black", lwd = 2) - } - - graphics::box() - - LablePoint2 <- unique(sort(c( - ceiling(min(x.mode) * 10) / 10, - xticks, floor(max(x.mode) * 10) / 10 - ))) ## Can be modified - - graphics::axis(1, at = LablePoint2, labels = paste(LablePoint2, "%", sep = ""), las = 1, lwd = 2, cex.axis = 1) - - data } From 74b3682cbe7b5ca20a4f7db46ba565e2e861ec48 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 12:24:31 +0200 Subject: [PATCH 10/67] annotation done --- R/plotDecision.R | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index 6b796eb9..2628f72c 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -37,14 +37,19 @@ plotDecision <- function(data, go_cut, stop_cut) { ggplot2::ggplot(go_shade) + geom_area(ggplot2::aes(x = mode, y = prob_go)) + annotation_go <- paste0("Probability of Go is ", go_cut ," when difference is ", min(data$mode[data$prob_go > go_cut]), "%") + annotation_stop <- paste0("Probability of Stop is ", stop_cut ," when difference is ", max(data$mode[data$prob_stop > stop_cut]), "%") + ggplot2::ggplot(data) + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + ggplot2::theme_light() + + ggplot2::scale_x_continuous(breaks = seq(from = 0, to = round(max(data$mode), digits = 1), by = 5)) + ggplot2::geom_area(data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), fill = "#009E73") + ggplot2::geom_line(data = data, ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + ggplot2::geom_area(data = stop_shade, mapping = ggplot2::aes(x = mode, y = prob_stop), fill = "#FF0046") + - ggplot2::ggtitle("Prob") + - ggplot2::xlab("") + - ggplot2::ylab("") - + ggplot2::ggtitle("Probability of Difference and respective Go and Stop probabilities") + + ggplot2::xlab("Estimated difference in Response Rate (%)") + + ggplot2::ylab("Probability (%)") + + ggplot2::annotate("text", x = mean(data$mode), y = 70, label = annotation_go ) + + ggplot2::annotate("text", x = mean(data$mode), y = 65, label = annotation_stop ) } From a31aafcb8a86442823201c1bc6983f94b0dda98e Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 12:33:30 +0200 Subject: [PATCH 11/67] clean up documentation --- DESCRIPTION | 1 + NAMESPACE | 4 ---- R/plotDecision.R | 8 ++++---- R/test-plotDecision.R | 2 ++ examples/plotDecision.R | 11 +---------- man/plotDecision.Rd | 17 ++++------------- 6 files changed, 12 insertions(+), 31 deletions(-) create mode 100644 R/test-plotDecision.R diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -89,4 +89,5 @@ Collate: 'runShinyPhase1b.R' 'sumTable.R' 'sumbetadiff.R' + 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 66cd55ab..f8376c0e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,12 +38,8 @@ importFrom(ggplot2,geom_line) importFrom(ggplot2,ggtitle) importFrom(graphics,abline) importFrom(graphics,axis) -importFrom(graphics,box) -importFrom(graphics,grid) importFrom(graphics,hist) importFrom(graphics,lines) -importFrom(graphics,mtext) -importFrom(graphics,par) importFrom(graphics,plot) importFrom(graphics,polygon) importFrom(lifecycle,deprecated) diff --git a/R/plotDecision.R b/R/plotDecision.R index 2628f72c..dc87f49b 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -1,14 +1,14 @@ #' Plot a summary plot corresponding to the sumTable output #' -#' This function will return a plot showing a curve of the prob of a meaningful improvement over estunated diff -#' and a curve of the prob of a poor improvement over estunated diff +#' This function will return a plot showing a curve of the prob of a meaningful improvement over estimated diff +#' and a curve of the prob of a poor improvement over estimated diff #' #' @inheritParams plotBetaDiff #' @typed data : data.frame #' sourced [`data.frame`] from [(sumTable)] -#' @return the \code{data} item which was imputed to the function +#' @return the [`data`] item which was imputed to the function #' -#' @importFrom graphics lines abline polygon plot par grid mtext box axis +#' @importFrom tibble ggplot2 #' #' @example examples/plotDecision.R #' @export diff --git a/R/test-plotDecision.R b/R/test-plotDecision.R new file mode 100644 index 00000000..f97509ae --- /dev/null +++ b/R/test-plotDecision.R @@ -0,0 +1,2 @@ +#plotDecision ---- + diff --git a/examples/plotDecision.R b/examples/plotDecision.R index d5096c45..86647e5e 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -1,12 +1,3 @@ -# sumTable ---- -sumTable( - x = 10, - n = 20, - parX = c(1, 1), - go_cut = 0.8, - stop_cut = 0.4 -) - summaries <- do.call( cbind, lapply(c(0:8), @@ -20,7 +11,7 @@ summaries <- do.call( plotDecision(summaries, go_cut = 60, stop_cut = 60) -# plotting more results +# plotting different criteria summaries <- do.call( cbind, lapply(c(0:8), diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 92e13f68..54ad5b40 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -14,22 +14,13 @@ plotDecision(data, go_cut, stop_cut) \item{stop_cut}{(\code{number}):\cr a poor improvement threshold, the upper boundary of a meaningfully poor improvement in response rate} } \value{ -the \code{data} item which was imputed to the function +the \code{\link{data}} item which was imputed to the function } \description{ -This function will return a plot showing a curve of the prob of a meaningful improvement over estunated diff -and a curve of the prob of a poor improvement over estunated diff +This function will return a plot showing a curve of the prob of a meaningful improvement over estimated diff +and a curve of the prob of a poor improvement over estimated diff } \examples{ -# sumTable ---- -sumTable( - x = 10, - n = 20, - parX = c(1, 1), - go_cut = 0.8, - stop_cut = 0.4 -) - summaries <- do.call( cbind, lapply(c(0:8), @@ -43,7 +34,7 @@ summaries <- do.call( plotDecision(summaries, go_cut = 60, stop_cut = 60) -# plotting more results +# plotting different criteria summaries <- do.call( cbind, lapply(c(0:8), From 594fe54419ed06ddd2a0548b6f817c7ffd7972c2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 10:37:36 +0000 Subject: [PATCH 12/67] [skip style] [skip vbump] Restyle files --- R/plotDecision.R | 28 +++++++++++++++------------- R/test-plotDecision.R | 3 +-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index dc87f49b..dd320cfe 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -22,23 +22,25 @@ plotDecision <- function(data, go_cut, stop_cut) { data <- tibble::remove_rownames(data) - colnames(data) <- c("responders", - "obs", - "mode", - "ci_lower", - "ci_upper", - "prob_go", - "prob_stop") + colnames(data) <- c( + "responders", + "obs", + "mode", + "ci_lower", + "ci_upper", + "prob_go", + "prob_stop" + ) - go_shade <- data[data$prob_go > go_cut,] + go_shade <- data[data$prob_go > go_cut, ] - stop_shade <- data[data$prob_stop > stop_cut,] + stop_shade <- data[data$prob_stop > stop_cut, ] ggplot2::ggplot(go_shade) + geom_area(ggplot2::aes(x = mode, y = prob_go)) - annotation_go <- paste0("Probability of Go is ", go_cut ," when difference is ", min(data$mode[data$prob_go > go_cut]), "%") - annotation_stop <- paste0("Probability of Stop is ", stop_cut ," when difference is ", max(data$mode[data$prob_stop > stop_cut]), "%") + annotation_go <- paste0("Probability of Go is ", go_cut, " when difference is ", min(data$mode[data$prob_go > go_cut]), "%") + annotation_stop <- paste0("Probability of Stop is ", stop_cut, " when difference is ", max(data$mode[data$prob_stop > stop_cut]), "%") ggplot2::ggplot(data) + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + @@ -50,6 +52,6 @@ plotDecision <- function(data, go_cut, stop_cut) { ggplot2::ggtitle("Probability of Difference and respective Go and Stop probabilities") + ggplot2::xlab("Estimated difference in Response Rate (%)") + ggplot2::ylab("Probability (%)") + - ggplot2::annotate("text", x = mean(data$mode), y = 70, label = annotation_go ) + - ggplot2::annotate("text", x = mean(data$mode), y = 65, label = annotation_stop ) + ggplot2::annotate("text", x = mean(data$mode), y = 70, label = annotation_go) + + ggplot2::annotate("text", x = mean(data$mode), y = 65, label = annotation_stop) } diff --git a/R/test-plotDecision.R b/R/test-plotDecision.R index f97509ae..b165d3c3 100644 --- a/R/test-plotDecision.R +++ b/R/test-plotDecision.R @@ -1,2 +1 @@ -#plotDecision ---- - +# plotDecision ---- From 4ba090e60841dc408df7d5b7ce23b6f96811b557 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 12:43:25 +0200 Subject: [PATCH 13/67] clean up --- R/plotDecision.R | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index dd320cfe..84da4ec0 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -36,11 +36,8 @@ plotDecision <- function(data, go_cut, stop_cut) { stop_shade <- data[data$prob_stop > stop_cut, ] - ggplot2::ggplot(go_shade) + - geom_area(ggplot2::aes(x = mode, y = prob_go)) - - annotation_go <- paste0("Probability of Go is ", go_cut, " when difference is ", min(data$mode[data$prob_go > go_cut]), "%") - annotation_stop <- paste0("Probability of Stop is ", stop_cut, " when difference is ", max(data$mode[data$prob_stop > stop_cut]), "%") + annotation_go <- paste0("Probability of Go is ", go_cut, "% when difference is ", min(data$mode[data$prob_go > go_cut]), "%") + annotation_stop <- paste0("Probability of Stop is ", stop_cut, "% when difference is ", max(data$mode[data$prob_stop > stop_cut]), "%") ggplot2::ggplot(data) + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + From eed5b3f3068105c90fb381d4118309c340a787fa Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 16:49:13 +0200 Subject: [PATCH 14/67] clean --- DESCRIPTION | 2 +- NAMESPACE | 5 ++ ...d-respective-go-and-stop-probabilities.svg | 86 ++++++++++++++++++ R/plotBeta.R | 4 +- R/plotDecision.R | 30 ++++--- R/sumbetadiff.R | 5 +- R/test-plotDecision.R | 24 +++++ examples/plotDecision.R | 10 ++- examples/sumTable.R | 3 + man/plotDecision.Rd | 16 ++-- man/sumBetaDiff.Rd | 2 +- man/sumTable.Rd | 3 + ...d-respective-Go-and-Stop-probabilities.svg | 89 +++++++++++++++++++ 13 files changed, 249 insertions(+), 30 deletions(-) create mode 100644 R/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg create mode 100644 tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..450496ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index f8376c0e..1253a03a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,10 +32,14 @@ export(runShinyPhase1b) export(sumBetaDiff) export(sumTable) import(checkmate) +importFrom(ggplot2,annotate) importFrom(ggplot2,geom_area) importFrom(ggplot2,geom_bar) importFrom(ggplot2,geom_line) importFrom(ggplot2,ggtitle) +importFrom(ggplot2,theme_light) +importFrom(ggplot2,xlab) +importFrom(ggplot2,ylab) importFrom(graphics,abline) importFrom(graphics,axis) importFrom(graphics,hist) @@ -52,3 +56,4 @@ importFrom(stats,optimize) importFrom(stats,pbeta) importFrom(stats,rbinom) importFrom(stats,uniroot) +importFrom(tibble,remove_rownames) diff --git a/R/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg b/R/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg new file mode 100644 index 00000000..a0582785 --- /dev/null +++ b/R/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Probability of Go is 60% when difference is at least 29.47% +Probability of Stop is 60% when difference is at most 1.02% + + + +0 +25 +50 +75 + + + + + + + + + + +0 +5 +10 +15 +20 +25 +Difference between treatment in Response Rate (%) +Probability (%) +Probability of Difference and respective Go and Stop probabilities. + + diff --git a/R/plotBeta.R b/R/plotBeta.R index 24f3bde6..a4415aeb 100644 --- a/R/plotBeta.R +++ b/R/plotBeta.R @@ -80,8 +80,8 @@ plotBetaDiff <- function(parX, # parameters of control or SOC temp <- sumBetaDiff( parX = parX, parY = parY, - go_cut = go_cut, - stop_cut = stop_cut + go_cut = go_cut, # in response rate + stop_cut = stop_cut # in response rate ) go_label <- paste("P(Go) is", round(temp$go * 100, digits = 2), "%") diff --git a/R/plotDecision.R b/R/plotDecision.R index 84da4ec0..472e8847 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -3,20 +3,24 @@ #' This function will return a plot showing a curve of the prob of a meaningful improvement over estimated diff #' and a curve of the prob of a poor improvement over estimated diff #' -#' @inheritParams plotBetaDiff #' @typed data : data.frame #' sourced [`data.frame`] from [(sumTable)] +#' @typed efficacious_prob : number +#' a cut off for the probability of a meaningful improvement +#' @typed futile_prob : number +#' a cut off for the probability of a poor improvement #' @return the [`data`] item which was imputed to the function #' -#' @importFrom tibble ggplot2 +#' @importFrom ggplot2 geom_line geom_area ggtitle theme_light annotate xlab ylab +#' @importFrom tibble remove_rownames #' #' @example examples/plotDecision.R #' @export #' @keywords graphics -plotDecision <- function(data, go_cut, stop_cut) { +plotDecision <- function(data, efficacious_prob, futile_prob) { assert_data_frame(data, any.missing = FALSE) - assert_number(go_cut, finite = TRUE) - assert_number(stop_cut, finite = TRUE) + assert_number(efficacious_prob, finite = TRUE) + assert_number(futile_prob, finite = TRUE) data <- data.frame(t(data)) @@ -32,12 +36,12 @@ plotDecision <- function(data, go_cut, stop_cut) { "prob_stop" ) - go_shade <- data[data$prob_go > go_cut, ] + go_shade <- data[data$prob_go > efficacious_prob, ] - stop_shade <- data[data$prob_stop > stop_cut, ] + stop_shade <- data[data$prob_stop > futile_prob, ] - annotation_go <- paste0("Probability of Go is ", go_cut, "% when difference is ", min(data$mode[data$prob_go > go_cut]), "%") - annotation_stop <- paste0("Probability of Stop is ", stop_cut, "% when difference is ", max(data$mode[data$prob_stop > stop_cut]), "%") + annotation_go <- paste0("Probability of Go is ", efficacious_prob, "% when difference is at least ", max(data$mode[data$prob_go > efficacious_prob]), "%") + annotation_stop <- paste0("Probability of Stop is ", futile_prob, "% when difference is at most ", max(data$mode[data$prob_stop > futile_prob]), "%") ggplot2::ggplot(data) + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + @@ -46,9 +50,9 @@ plotDecision <- function(data, go_cut, stop_cut) { ggplot2::geom_area(data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), fill = "#009E73") + ggplot2::geom_line(data = data, ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + ggplot2::geom_area(data = stop_shade, mapping = ggplot2::aes(x = mode, y = prob_stop), fill = "#FF0046") + - ggplot2::ggtitle("Probability of Difference and respective Go and Stop probabilities") + - ggplot2::xlab("Estimated difference in Response Rate (%)") + + ggplot2::ggtitle("Probability of Difference and respective Go and Stop probabilities.") + + ggplot2::xlab("Difference between treatment in Response Rate (%)") + ggplot2::ylab("Probability (%)") + - ggplot2::annotate("text", x = mean(data$mode), y = 70, label = annotation_go) + - ggplot2::annotate("text", x = mean(data$mode), y = 65, label = annotation_stop) + ggplot2::annotate("text", x = mean(data$mode), y = 90, label = annotation_go) + + ggplot2::annotate("text", x = mean(data$mode), y = 85, label = annotation_stop) } diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index e1899d84..cf7dfd94 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -20,8 +20,8 @@ sumBetaDiff <- function(parX, # Treatment group's parameters parY, # Control group's parameters ci_level = 0.9, - go_cut, - stop_cut) { + go_cut, # a meaningful improvement threshold + stop_cut) { # a poor improvement threshold assert_numeric(parY, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) assert_numeric(parX, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) assert_number(ci_level, finite = TRUE) @@ -49,6 +49,7 @@ sumBetaDiff <- function(parX, # Treatment group's parameters parY = parY, parX = parX ) + # Prob for Go: prob_go <- stats::integrate( f = dbetadiff, diff --git a/R/test-plotDecision.R b/R/test-plotDecision.R index b165d3c3..5319d08a 100644 --- a/R/test-plotDecision.R +++ b/R/test-plotDecision.R @@ -1 +1,25 @@ # plotDecision ---- +testthat::test_that("plotDecision gives a correct result", { + summaries <- do.call( + cbind, + lapply(c(0:8), + sumTable, + n = 25, + parX = c(1, 52), + go_cut = 0.2, + stop_cut = 0.05 + ) + ) + result <- plotDecision(summaries, efficacious_prob = 60, futile_prob = 60) + testthat::expect_equal(result$data$responders, c(0, 1, 2, 3, 4, 5, 6, 7, 8)) + expect_numeric(result$data$obs) + expect_numeric(result$data$mode) + expect_numeric(result$data$ci_lower) + expect_numeric(result$data$ci_upper) + expect_numeric(result$data$prob_go) + expect_numeric(result$data$prob_stop) + testthat::expect_identical(result$labels$title, "Probability of Difference and respective Go and Stop probabilities.") + vdiffr::expect_doppelganger("plot of Probability of Difference and respective Go and Stop probabilities", result) +}) + + diff --git a/examples/plotDecision.R b/examples/plotDecision.R index 86647e5e..e9f2213d 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -9,7 +9,7 @@ summaries <- do.call( ) ) -plotDecision(summaries, go_cut = 60, stop_cut = 60) +plotDecision(summaries, efficacious_prob = 60, futile_prob = 60) # plotting different criteria summaries <- do.call( @@ -18,9 +18,11 @@ summaries <- do.call( sumTable, n = 25, parX = c(1, 52), - go_cut = 0.5, - stop_cut = 0.2 +# density when P( diff > 20% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + go_cut = 0.2, +# density when P( diff < 10% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + stop_cut = 0.1 ) ) -plotDecision(summaries, go_cut = 10, stop_cut = 2) +plotDecision(summaries, efficacious_prob = 60, futile_prob = 80) diff --git a/examples/sumTable.R b/examples/sumTable.R index 64e9b5c4..11b5c0e5 100644 --- a/examples/sumTable.R +++ b/examples/sumTable.R @@ -14,7 +14,10 @@ summaries <- do.call( sumTable, n = 25, parX = c(1, 52), + parY = c(0.5, 0.5), # default +# density when P( diff > 20% | B(1, 52) for control and B(0.5, 0.5) for treatment) : go_cut = 0.2, +# density when P( diff < 5% | B(1, 52) for control and B(0.5, 0.5) for treatment) : stop_cut = 0.05 ) ) diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 54ad5b40..203d0e83 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -4,14 +4,14 @@ \alias{plotDecision} \title{Plot a summary plot corresponding to the sumTable output} \usage{ -plotDecision(data, go_cut, stop_cut) +plotDecision(data, efficacious_prob, futile_prob) } \arguments{ \item{data}{(\code{data.frame}):\cr sourced \code{\link{data.frame}} from \link{(sumTable)}} -\item{go_cut}{(\code{number}):\cr a meaningful improvement threshold, the lower boundary of a meaningfully improvement in response rate} +\item{efficacious_prob}{(\code{number}):\cr a cut off for the probability of a meaningful improvement} -\item{stop_cut}{(\code{number}):\cr a poor improvement threshold, the upper boundary of a meaningfully poor improvement in response rate} +\item{futile_prob}{(\code{number}):\cr a cut off for the probability of a poor improvement} } \value{ the \code{\link{data}} item which was imputed to the function @@ -32,7 +32,7 @@ summaries <- do.call( ) ) -plotDecision(summaries, go_cut = 60, stop_cut = 60) +plotDecision(summaries, efficacious_prob = 60, futile_prob = 60) # plotting different criteria summaries <- do.call( @@ -41,11 +41,13 @@ summaries <- do.call( sumTable, n = 25, parX = c(1, 52), - go_cut = 0.5, - stop_cut = 0.2 +# density when P( diff > 20\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + go_cut = 0.2, +# density when P( diff < 10\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + stop_cut = 0.1 ) ) -plotDecision(summaries, go_cut = 10, stop_cut = 2) +plotDecision(summaries, efficacious_prob = 60, futile_prob = 80) } \keyword{graphics} diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 474bb5ea..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} diff --git a/man/sumTable.Rd b/man/sumTable.Rd index 483f9179..c820de63 100644 --- a/man/sumTable.Rd +++ b/man/sumTable.Rd @@ -45,7 +45,10 @@ summaries <- do.call( sumTable, n = 25, parX = c(1, 52), + parY = c(0.5, 0.5), # default +# density when P( diff > 20\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : go_cut = 0.2, +# density when P( diff < 5\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : stop_cut = 0.05 ) ) diff --git a/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg b/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg new file mode 100644 index 00000000..51cc4d1d --- /dev/null +++ b/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Probability of Go is 60% when difference is at least 29.47% +Probability of Stop is 60% when difference is at most 1.02% + + + +0 +25 +50 +75 + + + + + + + + + + +0 +5 +10 +15 +20 +25 +Difference between treatment in Response Rate (%) +Probability (%) +Probability of Difference and respective Go and Stop probabilities. + + From 6d6963e9b86373537a01a22be80223d834594336 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 13 May 2025 14:51:08 +0000 Subject: [PATCH 15/67] [skip style] [skip vbump] Restyle files --- R/test-plotDecision.R | 12 +++++------- examples/plotDecision.R | 4 ++-- examples/sumTable.R | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/R/test-plotDecision.R b/R/test-plotDecision.R index 5319d08a..11be0036 100644 --- a/R/test-plotDecision.R +++ b/R/test-plotDecision.R @@ -3,11 +3,11 @@ testthat::test_that("plotDecision gives a correct result", { summaries <- do.call( cbind, lapply(c(0:8), - sumTable, - n = 25, - parX = c(1, 52), - go_cut = 0.2, - stop_cut = 0.05 + sumTable, + n = 25, + parX = c(1, 52), + go_cut = 0.2, + stop_cut = 0.05 ) ) result <- plotDecision(summaries, efficacious_prob = 60, futile_prob = 60) @@ -21,5 +21,3 @@ testthat::test_that("plotDecision gives a correct result", { testthat::expect_identical(result$labels$title, "Probability of Difference and respective Go and Stop probabilities.") vdiffr::expect_doppelganger("plot of Probability of Difference and respective Go and Stop probabilities", result) }) - - diff --git a/examples/plotDecision.R b/examples/plotDecision.R index e9f2213d..063da71c 100644 --- a/examples/plotDecision.R +++ b/examples/plotDecision.R @@ -18,9 +18,9 @@ summaries <- do.call( sumTable, n = 25, parX = c(1, 52), -# density when P( diff > 20% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff > 20% | B(1, 52) for control and B(0.5, 0.5) for treatment) : go_cut = 0.2, -# density when P( diff < 10% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff < 10% | B(1, 52) for control and B(0.5, 0.5) for treatment) : stop_cut = 0.1 ) ) diff --git a/examples/sumTable.R b/examples/sumTable.R index 11b5c0e5..9db595bb 100644 --- a/examples/sumTable.R +++ b/examples/sumTable.R @@ -15,9 +15,9 @@ summaries <- do.call( n = 25, parX = c(1, 52), parY = c(0.5, 0.5), # default -# density when P( diff > 20% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff > 20% | B(1, 52) for control and B(0.5, 0.5) for treatment) : go_cut = 0.2, -# density when P( diff < 5% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff < 5% | B(1, 52) for control and B(0.5, 0.5) for treatment) : stop_cut = 0.05 ) ) From 50cf080fc83a8338a29611dcf351c78aa117a41f 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, 13 May 2025 14:51:39 +0000 Subject: [PATCH 16/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 450496ce..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..474bb5ea 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From 0548ad978f906608ff7b5f1aaa7de9e735bdd613 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 13 May 2025 17:00:02 +0200 Subject: [PATCH 17/67] git auto checks --- DESCRIPTION | 2 +- man/plotDecision.Rd | 4 ++-- man/sumBetaDiff.Rd | 2 +- man/sumTable.Rd | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..450496ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 203d0e83..ddccc0a6 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -41,9 +41,9 @@ summaries <- do.call( sumTable, n = 25, parX = c(1, 52), -# density when P( diff > 20\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff > 20\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : go_cut = 0.2, -# density when P( diff < 10\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff < 10\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : stop_cut = 0.1 ) ) diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 474bb5ea..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} diff --git a/man/sumTable.Rd b/man/sumTable.Rd index c820de63..b801bd20 100644 --- a/man/sumTable.Rd +++ b/man/sumTable.Rd @@ -46,9 +46,9 @@ summaries <- do.call( n = 25, parX = c(1, 52), parY = c(0.5, 0.5), # default -# density when P( diff > 20\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff > 20\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : go_cut = 0.2, -# density when P( diff < 5\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : + # density when P( diff < 5\% | B(1, 52) for control and B(0.5, 0.5) for treatment) : stop_cut = 0.05 ) ) From a1042f79a0c313e602c8e97847c16a4eb9473e5c 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, 13 May 2025 15:02:39 +0000 Subject: [PATCH 18/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 450496ce..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..474bb5ea 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From 87593363b3b9fc5e944531e7f34ece06cd447b08 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 14 May 2025 09:24:09 +0200 Subject: [PATCH 19/67] empty trigger From 4808c88669524d2dda7e78ea77aaecd1d6e1157f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 14 May 2025 19:15:28 +0200 Subject: [PATCH 20/67] see if this runs well --- DESCRIPTION | 2 +- R/sumbetadiff.R | 2 +- man/sumBetaDiff.Rd | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..450496ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index cf7dfd94..b4722d68 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -15,7 +15,7 @@ #' #' @importFrom stats optimize integrate #' -#' @example examples/sumbetadiff.R +#' @example examples/sumBetaDiff.R #' @export sumBetaDiff <- function(parX, # Treatment group's parameters parY, # Control group's parameters diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 474bb5ea..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From c4ef49b33492b3290314c13ea38c282f075fa552 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, 14 May 2025 17:18:02 +0000 Subject: [PATCH 21/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 450496ce..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 c25bac8749c1c1ec15578c2d88612468753d0d00 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 14 May 2025 19:22:57 +0200 Subject: [PATCH 22/67] carpe diem --- DESCRIPTION | 2 +- R/plotDecision.R | 6 ++++-- man/sumBetaDiff.Rd | 13 ++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..450496ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/R/plotDecision.R b/R/plotDecision.R index 472e8847..3d342813 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -40,8 +40,10 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { stop_shade <- data[data$prob_stop > futile_prob, ] - annotation_go <- paste0("Probability of Go is ", efficacious_prob, "% when difference is at least ", max(data$mode[data$prob_go > efficacious_prob]), "%") - annotation_stop <- paste0("Probability of Stop is ", futile_prob, "% when difference is at most ", max(data$mode[data$prob_stop > futile_prob]), "%") + annotation_go <- paste0("Probability of Go is ", efficacious_prob, "% when difference is at least ", + max(data$mode[data$prob_go > efficacious_prob]), "%") + annotation_stop <- paste0("Probability of Stop is ", futile_prob, "% when difference is at most ", + max(data$mode[data$prob_stop > futile_prob]), "%") ggplot2::ggplot(data) + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 890862eb249cb7d85ac6a82b398933236bfed41c Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 14 May 2025 17:25:07 +0000 Subject: [PATCH 23/67] [skip style] [skip vbump] Restyle files --- R/plotDecision.R | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index 3d342813..d2f05da0 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -40,10 +40,14 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { stop_shade <- data[data$prob_stop > futile_prob, ] - annotation_go <- paste0("Probability of Go is ", efficacious_prob, "% when difference is at least ", - max(data$mode[data$prob_go > efficacious_prob]), "%") - annotation_stop <- paste0("Probability of Stop is ", futile_prob, "% when difference is at most ", - max(data$mode[data$prob_stop > futile_prob]), "%") + annotation_go <- paste0( + "Probability of Go is ", efficacious_prob, "% when difference is at least ", + max(data$mode[data$prob_go > efficacious_prob]), "%" + ) + annotation_stop <- paste0( + "Probability of Stop is ", futile_prob, "% when difference is at most ", + max(data$mode[data$prob_stop > futile_prob]), "%" + ) ggplot2::ggplot(data) + ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + From 76b1c493681daf1e5e2d7cbd3d6c4e43f7058b00 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, 14 May 2025 17:25:44 +0000 Subject: [PATCH 24/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 450496ce..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 5d2cae1bb415ac1400ca5fe19be758e19daa53d8 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 08:27:24 +0200 Subject: [PATCH 25/67] fix collate DESC --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..450496ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 3fc44c758ee99a6192bcc89f3f70d87e4f4cf2f8 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, 15 May 2025 06:30:08 +0000 Subject: [PATCH 26/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 450496ce..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 227d975ef5107ec9129c5bed74ca9a9e88a89bbf Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 08:39:28 +0200 Subject: [PATCH 27/67] test that buggy --- DESCRIPTION | 2 +- R/plotDecision.R | 2 +- man/plotDecision.Rd | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..450496ce 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/R/plotDecision.R b/R/plotDecision.R index d2f05da0..8a1b7c73 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -9,7 +9,7 @@ #' a cut off for the probability of a meaningful improvement #' @typed futile_prob : number #' a cut off for the probability of a poor improvement -#' @return the [`data`] item which was imputed to the function +#' @return the [`ggplot`] item which was imputed to the function #' #' @importFrom ggplot2 geom_line geom_area ggtitle theme_light annotate xlab ylab #' @importFrom tibble remove_rownames diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index ddccc0a6..83fbeed1 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -14,7 +14,7 @@ plotDecision(data, efficacious_prob, futile_prob) \item{futile_prob}{(\code{number}):\cr a cut off for the probability of a poor improvement} } \value{ -the \code{\link{data}} item which was imputed to the function +the \code{\link{ggplot}} item which was imputed to the function } \description{ This function will return a plot showing a curve of the prob of a meaningful improvement over estimated diff diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 1cb5fa177ad7ee79661535c28e4d97ef8705ed75 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, 15 May 2025 06:42:01 +0000 Subject: [PATCH 28/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 450496ce..9e4946d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,7 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 5fee0de0c163ce62a84be6a2cf4194a2a1c1297c Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 08:54:10 +0200 Subject: [PATCH 29/67] changed test file location --- DESCRIPTION | 3 +-- man/sumBetaDiff.Rd | 13 ++++++++++++- {R => tests/testthat}/test-plotDecision.R | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) rename {R => tests/testthat}/test-plotDecision.R (78%) diff --git a/DESCRIPTION b/DESCRIPTION index 9e4946d5..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,7 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' - 'test-plotDecision.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 +) +} diff --git a/R/test-plotDecision.R b/tests/testthat/test-plotDecision.R similarity index 78% rename from R/test-plotDecision.R rename to tests/testthat/test-plotDecision.R index 11be0036..feac2273 100644 --- a/R/test-plotDecision.R +++ b/tests/testthat/test-plotDecision.R @@ -1,5 +1,5 @@ # plotDecision ---- -testthat::test_that("plotDecision gives a correct result", { +test_that("plotDecision gives a correct result", { summaries <- do.call( cbind, lapply(c(0:8), @@ -18,6 +18,6 @@ testthat::test_that("plotDecision gives a correct result", { expect_numeric(result$data$ci_upper) expect_numeric(result$data$prob_go) expect_numeric(result$data$prob_stop) - testthat::expect_identical(result$labels$title, "Probability of Difference and respective Go and Stop probabilities.") + expect_identical(result$labels$title, "Probability of Difference and respective Go and Stop probabilities.") vdiffr::expect_doppelganger("plot of Probability of Difference and respective Go and Stop probabilities", result) }) From 3322ebda43f6f2572cbb60f40f252faff6868542 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, 15 May 2025 06:56:53 +0000 Subject: [PATCH 30/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 3158b8f76b295e4f6d209b83240a4224f3cd9299 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 09:33:40 +0200 Subject: [PATCH 31/67] small stuff --- DESCRIPTION | 2 +- R/sumbetadiff.R | 4 ++-- man/sumBetaDiff.Rd | 13 ++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index b4722d68..5601d3b2 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -20,8 +20,8 @@ sumBetaDiff <- function(parX, # Treatment group's parameters parY, # Control group's parameters ci_level = 0.9, - go_cut, # a meaningful improvement threshold - stop_cut) { # a poor improvement threshold + go_cut, + stop_cut) { assert_numeric(parY, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) assert_numeric(parX, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) assert_number(ci_level, finite = TRUE) diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 a0d820c79ff81c40a615502e4dd3248ff1467c0a 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, 15 May 2025 07:36:01 +0000 Subject: [PATCH 32/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 34859c0475c4aa29044fa4633e50cbb8ee33f2aa Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 09:53:23 +0200 Subject: [PATCH 33/67] i re-installed to see if it makes a diff --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 d322ab742b5d9d02c6a89cdfa2c09818822fdb94 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, 15 May 2025 07:56:04 +0000 Subject: [PATCH 34/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 091c5d1aff9932a62b5092d4b1087d5f8dd5f051 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 10:01:56 +0200 Subject: [PATCH 35/67] small caps fixes --- inst/WORDLIST | 1 - tests/testthat/test-sumbetadiff.R | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/inst/WORDLIST b/inst/WORDLIST index 79ae2b4f..26553f93 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -218,7 +218,6 @@ simplifiedWeightedBayestwo specialised springer Springer -sumbetadiff summerize summerizes sumTable diff --git a/tests/testthat/test-sumbetadiff.R b/tests/testthat/test-sumbetadiff.R index 1b2e339a..53b17648 100644 --- a/tests/testthat/test-sumbetadiff.R +++ b/tests/testthat/test-sumbetadiff.R @@ -1,5 +1,5 @@ # sumBetaDiff ---- -test_that("sumbetadiff works as expected", { +test_that("sumBetaDiff works as expected", { parX <- c(1, 52) # Control group's parameters parY <- c(5.5, 20.5) # Treatment group's parameters result <- sumBetaDiff( @@ -20,7 +20,7 @@ test_that("sumbetadiff works as expected", { ) }) -test_that("sumbetadiff gives a error when at least one alpha = 0", { +test_that("sumBetaDiff gives a error when at least one alpha = 0", { parX <- c(0, 10) parY <- c(5.5, 20.5) expect_error(sumBetaDiff( From 7b6d1f550b1e8cdf82c6283c5ec537251594336f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 15 May 2025 10:03:32 +0200 Subject: [PATCH 36/67] clean --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 2dec9236f4a6956264d5497798b44f199bb6a38a 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, 15 May 2025 08:05:58 +0000 Subject: [PATCH 37/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 bddfe591a13001c763975a87308f17e774a3a0be Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 16 May 2025 11:37:48 +0200 Subject: [PATCH 38/67] trying this solution for the format of sumBetaDiff --- .lintr | 3 ++- R/plotDecision.R | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.lintr b/.lintr index cbc565cd..cb5964ac 100644 --- a/.lintr +++ b/.lintr @@ -2,5 +2,6 @@ linters: linters_with_defaults( line_length_linter = line_length_linter(120), cyclocomp_linter = NULL, object_usage_linter = NULL, - object_name_linter = NULL + object_name_linter = NULL, + exceptions = c("sumBetaDiff") ) diff --git a/R/plotDecision.R b/R/plotDecision.R index 8a1b7c73..bb081023 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -54,8 +54,10 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { ggplot2::theme_light() + ggplot2::scale_x_continuous(breaks = seq(from = 0, to = round(max(data$mode), digits = 1), by = 5)) + ggplot2::geom_area(data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), fill = "#009E73") + - ggplot2::geom_line(data = data, ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + - ggplot2::geom_area(data = stop_shade, mapping = ggplot2::aes(x = mode, y = prob_stop), fill = "#FF0046") + + ggplot2::geom_line(data = data, mapping = ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + + ggplot2::geom_area(data = stop_shade, + mapping = ggplot2::aes(x = mode, y = prob_stop), + fill = "#FF0046") + ggplot2::ggtitle("Probability of Difference and respective Go and Stop probabilities.") + ggplot2::xlab("Difference between treatment in Response Rate (%)") + ggplot2::ylab("Probability (%)") + From 7691bfccb6e777c8498d09ca699746565eba44cd Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 16 May 2025 09:39:50 +0000 Subject: [PATCH 39/67] [skip style] [skip vbump] Restyle files --- R/plotDecision.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index bb081023..f0f99c3f 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -55,9 +55,11 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { ggplot2::scale_x_continuous(breaks = seq(from = 0, to = round(max(data$mode), digits = 1), by = 5)) + ggplot2::geom_area(data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), fill = "#009E73") + ggplot2::geom_line(data = data, mapping = ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + - ggplot2::geom_area(data = stop_shade, - mapping = ggplot2::aes(x = mode, y = prob_stop), - fill = "#FF0046") + + ggplot2::geom_area( + data = stop_shade, + mapping = ggplot2::aes(x = mode, y = prob_stop), + fill = "#FF0046" + ) + ggplot2::ggtitle("Probability of Difference and respective Go and Stop probabilities.") + ggplot2::xlab("Difference between treatment in Response Rate (%)") + ggplot2::ylab("Probability (%)") + From bcd6ae7f39983a7e73445d36037e1be613fe5563 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 16 May 2025 11:51:11 +0200 Subject: [PATCH 40/67] carpe diem --- .lintr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lintr b/.lintr index cb5964ac..44a1ecfc 100644 --- a/.lintr +++ b/.lintr @@ -1,4 +1,4 @@ -linters: linters_with_defaults( +linters::linters_with_defaults( line_length_linter = line_length_linter(120), cyclocomp_linter = NULL, object_usage_linter = NULL, From 4e07761e30678b591ee3b834c507b4354f7719bc Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 16 May 2025 11:58:52 +0200 Subject: [PATCH 41/67] clean --- .lintr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.lintr b/.lintr index 44a1ecfc..cbc565cd 100644 --- a/.lintr +++ b/.lintr @@ -1,7 +1,6 @@ -linters::linters_with_defaults( +linters: linters_with_defaults( line_length_linter = line_length_linter(120), cyclocomp_linter = NULL, object_usage_linter = NULL, - object_name_linter = NULL, - exceptions = c("sumBetaDiff") + object_name_linter = NULL ) From 4945dc36ac7447ef182da17e397d866eb10fb229 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Sat, 17 May 2025 23:03:57 +0200 Subject: [PATCH 42/67] notice a couple of errors and fixed it --- DESCRIPTION | 2 +- R/plotDecision.R | 16 ++++++++++++---- R/plotOc.R | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/R/plotDecision.R b/R/plotDecision.R index f0f99c3f..c67eadd9 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -42,7 +42,7 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { annotation_go <- paste0( "Probability of Go is ", efficacious_prob, "% when difference is at least ", - max(data$mode[data$prob_go > efficacious_prob]), "%" + min(data$mode[data$prob_go > efficacious_prob]), "%" ) annotation_stop <- paste0( "Probability of Stop is ", futile_prob, "% when difference is at most ", @@ -50,11 +50,19 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { ) ggplot2::ggplot(data) + - ggplot2::geom_line(ggplot2::aes(x = mode, y = prob_go), linewidth = 1.5, colour = "#009E73") + + ggplot2::geom_line( + ggplot2::aes(x = mode, y = prob_go), + linewidth = 1.5, colour = "#009E73") + ggplot2::theme_light() + ggplot2::scale_x_continuous(breaks = seq(from = 0, to = round(max(data$mode), digits = 1), by = 5)) + - ggplot2::geom_area(data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), fill = "#009E73") + - ggplot2::geom_line(data = data, mapping = ggplot2::aes(x = mode, y = prob_stop), linewidth = 1.5, colour = "#FF0046") + + ggplot2::geom_area( + data = go_shade, + mapping = ggplot2::aes(x = mode, y = prob_go), + fill = "#009E73") + + ggplot2::geom_line( + data = data, + mapping = ggplot2::aes(x = mode, y = prob_stop), + linewidth = 1.5, colour = "#FF0046") + ggplot2::geom_area( data = stop_shade, mapping = ggplot2::aes(x = mode, y = prob_stop), diff --git a/R/plotOc.R b/R/plotOc.R index 316b1313..b9abbcfe 100644 --- a/R/plotOc.R +++ b/R/plotOc.R @@ -67,7 +67,7 @@ plotOc <- function(decision, all_sizes, all_looks, wiggle_status) { all_looks = all_looks ) barplot <- - ggplot2::ggplot(df, ggplot2::aes(fill = decision, x = look, y = prop)) + + ggplot2::ggplot(df, ggplot2::aes(fill = decision, x = all_looks, y = prop)) + ggplot2::geom_bar(position = "dodge", stat = "identity") + ggplot2::ggtitle( "Results from simulation : \nProportion of Go/Stop/Grey zone decisions per interim/final analysis" diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 3978c3eb79eb7960b75638f9ddaa8ba9b3d29042 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 17 May 2025 21:05:58 +0000 Subject: [PATCH 43/67] [skip style] [skip vbump] Restyle files --- R/plotDecision.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index c67eadd9..186fe7f2 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -52,17 +52,20 @@ plotDecision <- function(data, efficacious_prob, futile_prob) { ggplot2::ggplot(data) + ggplot2::geom_line( ggplot2::aes(x = mode, y = prob_go), - linewidth = 1.5, colour = "#009E73") + + linewidth = 1.5, colour = "#009E73" + ) + ggplot2::theme_light() + ggplot2::scale_x_continuous(breaks = seq(from = 0, to = round(max(data$mode), digits = 1), by = 5)) + ggplot2::geom_area( data = go_shade, mapping = ggplot2::aes(x = mode, y = prob_go), - fill = "#009E73") + + fill = "#009E73" + ) + ggplot2::geom_line( data = data, mapping = ggplot2::aes(x = mode, y = prob_stop), - linewidth = 1.5, colour = "#FF0046") + + linewidth = 1.5, colour = "#FF0046" + ) + ggplot2::geom_area( data = stop_shade, mapping = ggplot2::aes(x = mode, y = prob_stop), From 8255831b999cafcc1c85dbcd88a4c6f48c057cbb 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, 17 May 2025 21:06:22 +0000 Subject: [PATCH 44/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 3cc7c8f43388acf54079715dcca516e20bde0d52 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Mon, 19 May 2025 18:38:36 +0200 Subject: [PATCH 45/67] clean --- R/plotDecision.R | 2 +- R/plotOc.R | 2 +- man/plotDecision.Rd | 2 +- man/plotOc.Rd | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/plotDecision.R b/R/plotDecision.R index 186fe7f2..b73ed750 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -9,7 +9,7 @@ #' a cut off for the probability of a meaningful improvement #' @typed futile_prob : number #' a cut off for the probability of a poor improvement -#' @return the [`ggplot`] item which was imputed to the function +#' @return [`ggplot`] object #' #' @importFrom ggplot2 geom_line geom_area ggtitle theme_light annotate xlab ylab #' @importFrom tibble remove_rownames diff --git a/R/plotOc.R b/R/plotOc.R index b9abbcfe..05ac1a10 100644 --- a/R/plotOc.R +++ b/R/plotOc.R @@ -48,7 +48,7 @@ h_get_dataframe_oc <- function(decision, all_sizes, all_looks) { #' @inheritParams h_get_dataframe_oc #' @typed wiggle_status : flag #' from `wiggle` flag in object. -#' @return ggplot object +#' @return [`ggplot`] object #' #' @example examples/plotOc.R #' diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 83fbeed1..54f98311 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -14,7 +14,7 @@ plotDecision(data, efficacious_prob, futile_prob) \item{futile_prob}{(\code{number}):\cr a cut off for the probability of a poor improvement} } \value{ -the \code{\link{ggplot}} item which was imputed to the function +\code{\link{ggplot}} object } \description{ This function will return a plot showing a curve of the prob of a meaningful improvement over estimated diff diff --git a/man/plotOc.Rd b/man/plotOc.Rd index b54506e6..ec29e82d 100644 --- a/man/plotOc.Rd +++ b/man/plotOc.Rd @@ -17,7 +17,7 @@ Different to \code{all_sizes} which is after the adjustment, if made.} \item{wiggle_status}{(\code{flag}):\cr from \code{wiggle} flag in object.} } \value{ -ggplot object +\code{\link{ggplot}} object } \description{ Plots results from simulated results of : From afe005b9c744f39037629a492ef99ea4b31a6164 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 20 May 2025 09:46:13 +0200 Subject: [PATCH 46/67] sumTable tag --- DESCRIPTION | 2 +- R/plotDecision.R | 4 ++-- R/sumTable.R | 2 ++ man/plotDecision.Rd | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/R/plotDecision.R b/R/plotDecision.R index b73ed750..3348718f 100644 --- a/R/plotDecision.R +++ b/R/plotDecision.R @@ -4,14 +4,14 @@ #' and a curve of the prob of a poor improvement over estimated diff #' #' @typed data : data.frame -#' sourced [`data.frame`] from [(sumTable)] +#' sourced [`data.frame`] from [(sumTable())] #' @typed efficacious_prob : number #' a cut off for the probability of a meaningful improvement #' @typed futile_prob : number #' a cut off for the probability of a poor improvement #' @return [`ggplot`] object #' -#' @importFrom ggplot2 geom_line geom_area ggtitle theme_light annotate xlab ylab +#' @importFrom ggplot2 geom_line geom_area ggtitle theme_light annotate xlab ylab #' @importFrom tibble remove_rownames #' #' @example examples/plotDecision.R diff --git a/R/sumTable.R b/R/sumTable.R index 24fd35dd..dfa694e6 100644 --- a/R/sumTable.R +++ b/R/sumTable.R @@ -10,6 +10,8 @@ #' #' @return A vector with the results. #' +#' @importFrom phase1b sumBetaDiff +#' #' @example examples/sumTable.R #' @export sumTable <- function(x, diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 54f98311..85e461dd 100644 --- a/man/plotDecision.Rd +++ b/man/plotDecision.Rd @@ -7,7 +7,7 @@ plotDecision(data, efficacious_prob, futile_prob) } \arguments{ -\item{data}{(\code{data.frame}):\cr sourced \code{\link{data.frame}} from \link{(sumTable)}} +\item{data}{(\code{data.frame}):\cr sourced \code{\link{data.frame}} from \link{(sumTable())}} \item{efficacious_prob}{(\code{number}):\cr a cut off for the probability of a meaningful improvement} diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 0489214e79226eca989536ba8f0a74c972650c76 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, 20 May 2025 07:48:42 +0000 Subject: [PATCH 47/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 efff2ef5286f4bed731558cbe670d58c259d535f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 20 May 2025 11:06:07 +0200 Subject: [PATCH 48/67] clean --- DESCRIPTION | 2 +- R/sumbetadiff.R | 2 +- man/sumBetaDiff.Rd | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index 5601d3b2..bde90cc0 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -15,7 +15,7 @@ #' #' @importFrom stats optimize integrate #' -#' @example examples/sumBetaDiff.R +#' @example examples/sumbetadiff.R #' @export sumBetaDiff <- function(parX, # Treatment group's parameters parY, # Control group's parameters diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 9aad2547a2ced89842c8dd6e16ef7f2de626601c 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, 20 May 2025 09:08:30 +0000 Subject: [PATCH 49/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..474bb5ea 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From 961e66cb21d9ec825cb4b4fc22ebc5bd6bd8520c Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Tue, 20 May 2025 11:11:25 +0200 Subject: [PATCH 50/67] clean --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 474bb5ea..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From af169c41d72cc1ae48508b68768da50e08283151 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, 20 May 2025 09:14:00 +0000 Subject: [PATCH 51/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..474bb5ea 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From 6beaf13824be560811c178a569093503f7008a0f Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Wed, 21 May 2025 17:47:39 +0800 Subject: [PATCH 52/67] try to make file names consistent for `sumBetaDiff` --- DESCRIPTION | 2 +- R/sumbetadiff.R | 39 ++++++++++++++++++++++++++++----------- man/sumBetaDiff.Rd | 2 +- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index bde90cc0..d0ff4504 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -15,15 +15,29 @@ #' #' @importFrom stats optimize integrate #' -#' @example examples/sumbetadiff.R +#' @example examples/sumBetaDiff.R #' @export -sumBetaDiff <- function(parX, # Treatment group's parameters - parY, # Control group's parameters - ci_level = 0.9, - go_cut, - stop_cut) { - assert_numeric(parY, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) - assert_numeric(parX, len = 2, lower = .Machine$double.xmin, any.missing = FALSE, finite = TRUE) +sumBetaDiff <- function( + parX, # Treatment group's parameters + parY, # Control group's parameters + ci_level = 0.9, + go_cut, + stop_cut +) { + assert_numeric( + parY, + len = 2, + lower = .Machine$double.xmin, + any.missing = FALSE, + finite = TRUE + ) + assert_numeric( + parX, + len = 2, + lower = .Machine$double.xmin, + any.missing = FALSE, + finite = TRUE + ) assert_number(ci_level, finite = TRUE) assert_number(go_cut, finite = TRUE) assert_number(stop_cut, finite = TRUE) @@ -38,13 +52,15 @@ sumBetaDiff <- function(parX, # Treatment group's parameters maximum = TRUE )$maximum - lower <- qbetadiff( # to recover x when F(x) is at lower percentile + lower <- qbetadiff( + # to recover x when F(x) is at lower percentile p = (1 - ci_level) / 2, parY = parY, parX = parX ) - upper <- qbetadiff( # to recover x when F(x) is at upper percentile + upper <- qbetadiff( + # to recover x when F(x) is at upper percentile p = (1 + ci_level) / 2, parY = parY, parX = parX @@ -82,7 +98,8 @@ sumBetaDiff <- function(parX, # Treatment group's parameters silent = TRUE ) # if there were any errors, fall back to Monte Carlo estimation - if (inherits(result, "try-error")) { # try-error is a class + if (inherits(result, "try-error")) { + # try-error is a class samples <- stats::rbeta(n = 2e6, parY[1], parY[2]) - rbeta(n = 2e6, parX[1], parX[2]) diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 474bb5ea..130dde7c 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From 39b2f3fb0e7faed32670bf1f9386b7f40700239d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 09:50:17 +0000 Subject: [PATCH 53/67] [skip style] [skip vbump] Restyle files --- R/sumbetadiff.R | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/R/sumbetadiff.R b/R/sumbetadiff.R index d0ff4504..4fd931df 100644 --- a/R/sumbetadiff.R +++ b/R/sumbetadiff.R @@ -18,12 +18,11 @@ #' @example examples/sumBetaDiff.R #' @export sumBetaDiff <- function( - parX, # Treatment group's parameters - parY, # Control group's parameters - ci_level = 0.9, - go_cut, - stop_cut -) { + parX, # Treatment group's parameters + parY, # Control group's parameters + ci_level = 0.9, + go_cut, + stop_cut) { assert_numeric( parY, len = 2, From ce4a2b70e38a7f72706f34adbaf2431d63aaf3f2 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, 21 May 2025 09:50:48 +0000 Subject: [PATCH 54/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 13 +------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3d4d3608..15ca5381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' - 'sumBetaDiff.R' 'sumTable.R' + 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index 130dde7c..f3094eaf 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumBetaDiff.R +% Please edit documentation in R/sumbetadiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} @@ -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 419a144943da221e3ec06d2caaa12ce1594fb4f8 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Wed, 21 May 2025 17:54:51 +0800 Subject: [PATCH 55/67] rename again using `git mv` command --- R/{sumbetadiff.R => sumBetaDiff.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename R/{sumbetadiff.R => sumBetaDiff.R} (100%) diff --git a/R/sumbetadiff.R b/R/sumBetaDiff.R similarity index 100% rename from R/sumbetadiff.R rename to R/sumBetaDiff.R From 02119195537474bfa711a49113f788413d4dec1a 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, 21 May 2025 09:57:22 +0000 Subject: [PATCH 56/67] [skip roxygen] [skip vbump] Roxygen Man Pages Auto Update --- DESCRIPTION | 2 +- man/sumBetaDiff.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 15ca5381..3d4d3608 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -87,6 +87,6 @@ Collate: 'predprob.R' 'predprobDist.R' 'runShinyPhase1b.R' + 'sumBetaDiff.R' 'sumTable.R' - 'sumbetadiff.R' Config/testthat/edition: 3 diff --git a/man/sumBetaDiff.Rd b/man/sumBetaDiff.Rd index f3094eaf..5cc1ae5e 100644 --- a/man/sumBetaDiff.Rd +++ b/man/sumBetaDiff.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/sumbetadiff.R +% Please edit documentation in R/sumBetaDiff.R \name{sumBetaDiff} \alias{sumBetaDiff} \title{Mode and Credible Interval Calculation for The Difference between Two Beta Distributions} From 810789ca013cfcbe9e723dde82c176e7d3a439f3 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 12:44:27 +0200 Subject: [PATCH 57/67] clean --- ...fference-of-two-arms-with-beta-mixture.svg | 4 +- ...d-respective-Go-and-Stop-probabilities.svg | 129 +- ...e-arm-posterior-predictive-probability.svg | 32 +- ...t-for-single-arm-posterior-probability.svg | 43 +- ...a-for-posterior-predictive-probability.svg | 33 +- ...a-for-posterior-predictive-probability.svg | 33 +- tests/testthat/test-plotOc.R | 8 +- tests/vdiffr.Rout.fail | 17073 ++++++++++++++++ vignettes/introduction.Rmd | 8 +- 9 files changed, 17237 insertions(+), 126 deletions(-) diff --git a/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg index a9c300df..102bf2b5 100644 --- a/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg +++ b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg @@ -32,7 +32,7 @@ -P(Stop) is 59.5 % +P(Stop) is 59.49 % P(Go) is 24.5 % @@ -60,6 +60,6 @@ ( x ) -According to Beta difference density P(Go) is 24.5 % and P(Stop) is 59.5 % +According to Beta difference density P(Go) is 24.5 % and P(Stop) is 59.49 % diff --git a/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg b/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg index 51cc4d1d..ec7af51f 100644 --- a/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg +++ b/tests/testthat/_snaps/plotDecision/plot-of-Probability-of-Difference-and-respective-Go-and-Stop-probabilities.svg @@ -1,5 +1,5 @@ - + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Probability of Go is 60% when difference is at least 29.47% -Probability of Stop is 60% when difference is at most 1.02% - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Probability of Go is 60% when difference is at least 21.18% +Probability of Stop is 60% when difference is at most 1.02% + - -0 -25 -50 -75 - - - - - - - - - - -0 -5 -10 -15 -20 -25 -Difference between treatment in Response Rate (%) -Probability (%) -Probability of Difference and respective Go and Stop probabilities. + +0 +25 +50 +75 + + + + + + + + + + +0 +5 +10 +15 +20 +25 +Difference between treatment in Response Rate (%) +Probability (%) +Probability of Difference and respective Go and Stop probabilities. diff --git a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg index 482d2b5d..f9a4369a 100644 --- a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg +++ b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg @@ -31,17 +31,23 @@ + + + + - + + - - - - - + + + + + + 0.00 @@ -52,12 +58,16 @@ - + + - -10 -20 -NA + + +5 +10 +15 +20 +25 look (n) percentage diff --git a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg index cfdca283..8874241e 100644 --- a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg +++ b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg @@ -32,24 +32,27 @@ + + + + - - - - - - - - - - - - - + + + + + + + + + + + + 0.0 @@ -62,14 +65,12 @@ - - - - -10 -20 -30 -NA + + + +10 +20 +30 look (n) percentage diff --git a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg index c372bec8..be8037be 100644 --- a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg +++ b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg @@ -31,17 +31,24 @@ + + + + - - - - - - + + + + + + + + + 0.0 @@ -54,10 +61,16 @@ - - -20 -30 + + + + + +15 +20 +25 +30 +35 look (n) percentage diff --git a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg index ae0e813e..55d61b5e 100644 --- a/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg +++ b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg @@ -30,15 +30,22 @@ + + + + - - - - - - + + + + + + + + + 0.0 @@ -47,10 +54,16 @@ - - -20 -30 + + + + + +15 +20 +25 +30 +35 look (n) percentage diff --git a/tests/testthat/test-plotOc.R b/tests/testthat/test-plotOc.R index 15368569..344add1c 100644 --- a/tests/testthat/test-plotOc.R +++ b/tests/testthat/test-plotOc.R @@ -266,11 +266,11 @@ test_that("plotOc gives expected results for `ocPostprob` and `ocPredprob`", { all_looks = res5$Looks, wiggle_status = res5$params$wiggle ) - vdiffr::expect_doppelganger( + vdiffr::expect_doppelganger( ## title = "plot of simulation result for single arm posterior probability", fig = result1 ) - vdiffr::expect_doppelganger( + vdiffr::expect_doppelganger( ## title = "plot of simulation result for single arm posterior predictive probability", fig = result2 ) @@ -325,11 +325,11 @@ test_that("plotOc gives expected results for `ocPredprobDist` with different rel all_looks = res8$Looks, wiggle_status = res8$params$wiggle ) - vdiffr::expect_doppelganger( + vdiffr::expect_doppelganger( ## title = "Plot of simulation result without relativeDelta for posterior predictive probability", fig = result1 ) - vdiffr::expect_doppelganger( + vdiffr::expect_doppelganger( ## title = "Plot of simulation result with relativeDelta for posterior predictive probability", fig = result2 ) diff --git a/tests/vdiffr.Rout.fail b/tests/vdiffr.Rout.fail index 6e982dc9..e700615d 100644 --- a/tests/vdiffr.Rout.fail +++ b/tests/vdiffr.Rout.fail @@ -7765,3 +7765,17076 @@ Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-probabil > > + +Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg) + +< before +> after +@@ 33,4 / 33,8 @@ + + +> +> +> +> + + +@@ 38,17 / 42,16 @@ + + +< +< +< +> +< +> +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> + + +@@ 63,12 / 66,10 @@ + + +< +< +< +> +< +> +> +< 10 +> 10 +< 20 +> 20 +< 30 +> 30 +< NA + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg) + +< before +> after +@@ 32,15 / 32,21 @@ + + +> +> +> +> + + + + +< +> +> + +< +> +> +< +> +< +> +< +> +< +> + + +@@ 53,10 / 59,14 @@ + + +< +> +> + +< +> +< 10 +< 20 +> +> 5 +> 10 +> 15 +> 20 +< NA +> 25 + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg) + +< before +> after +@@ 31,13 / 31,20 @@ + + +> +> +> +> + + + +< +> +< +> +> +> +> +< +> +< +> +< +> +< +> + + +@@ 48,8 / 55,14 @@ + + +< +> +< +< 20 +< 30 +> +> +> +> +> 15 +> 20 +> 25 +> 30 +> 35 + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg) + +< before +> after +@@ 32,4 / 32,8 @@ + + +> +> +> +> + + +@@ 37,10 / 41,13 @@ + + +< +> +< +> +> +> +> +< +> +< +> +< +> +< +> + + +@@ 55,8 / 62,14 @@ + + +< +> +< +< 20 +< 30 +> +> +> +> +> 15 +> 20 +> 25 +> 30 +> 35 + look (n + ) + percentage + + +Failed doppelganger: plot-of-probability-of-difference-and-respective-go-and-stop-probabilities (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + + + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< Prob +: ability of Go is 60% when difference is at least 29.47% +> Probabi +: lity of Go is 60% when difference is at least 21.18% +< Prob +: ability of Stop is 60% when difference is at most 1.02% +> Probabi +: lity of Stop is 60% when difference is at most 1.02% +< +> + +< +> +< 0 +> 0 +< 25 +> 25 +< 50 +> 50 +< 75 +> 75 +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< 0 +> 0 +< 5 +> 5 +< 10 +> 10 +< 15 +> 15 +< 20 +> 20 +< 25 +> 25 +< Dif +: ference between treatment in Response Rate (%) +> Differ +: ence between treatment in Response Rate (%) +< Probability (%) +> Probability (%) +< Probability of Difference +: and respective Go and Stop probabilities. +> Probability of Difference and +: respective Go and Stop probabilities. + + + + +Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg) + +< before +> after +@@ 33,4 / 33,8 @@ + + +> +> +> +> + + +@@ 38,17 / 42,16 @@ + + +< +< +< +> +< +> +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> + + +@@ 63,12 / 66,10 @@ + + +< +< +< +> +< +> +> +< 10 +> 10 +< 20 +> 20 +< 30 +> 30 +< NA + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg) + +< before +> after +@@ 32,15 / 32,21 @@ + + +> +> +> +> + + + + +< +> +> + +< +> +> +< +> +< +> +< +> +< +> + + +@@ 53,10 / 59,14 @@ + + +< +> +> + +< +> +< 10 +< 20 +> +> 5 +> 10 +> 15 +> 20 +< NA +> 25 + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg) + +< before +> after +@@ 31,13 / 31,20 @@ + + +> +> +> +> + + + +< +> +< +> +> +> +> +< +> +< +> +< +> +< +> + + +@@ 48,8 / 55,14 @@ + + +< +> +< +< 20 +< 30 +> +> +> +> +> 15 +> 20 +> 25 +> 30 +> 35 + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg) + +< before +> after +@@ 32,4 / 32,8 @@ + + +> +> +> +> + + +@@ 37,10 / 41,13 @@ + + +< +> +< +> +> +> +> +< +> +< +> +< +> +< +> + + +@@ 55,8 / 62,14 @@ + + +< +> +< +< 20 +< 30 +> +> +> +> +> 15 +> 20 +> 25 +> 30 +> 35 + look (n + ) + percentage + + +Failed doppelganger: plot-of-probability-of-difference-and-respective-go-and-stop-probabilities (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + + + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< Prob +: ability of Go is 60% when difference is at least 29.47% +> Probabi +: lity of Go is 60% when difference is at least 21.18% +< Prob +: ability of Stop is 60% when difference is at most 1.02% +> Probabi +: lity of Stop is 60% when difference is at most 1.02% +< +> + +< +> +< 0 +> 0 +< 25 +> 25 +< 50 +> 50 +< 75 +> 75 +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< 0 +> 0 +< 5 +> 5 +< 10 +> 10 +< 15 +> 15 +< 20 +> 20 +< 25 +> 25 +< Dif +: ference between treatment in Response Rate (%) +> Differ +: ence between treatment in Response Rate (%) +< Probability (%) +> Probability (%) +< Probability of Difference +: and respective Go and Stop probabilities. +> Probability of Difference and +: respective Go and Stop probabilities. + + + + +Failed doppelganger: plot-of-probability-of-difference-and-respective-go-and-stop-probabilities (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotDecision/plot-of-probability-of-difference-and-respective-go-and-stop-probabilities.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + + + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< Prob +: ability of Go is 60% when difference is at least 29.47% +> Probabi +: lity of Go is 60% when difference is at least 21.18% +< Prob +: ability of Stop is 60% when difference is at most 1.02% +> Probabi +: lity of Stop is 60% when difference is at most 1.02% +< +> + +< +> +< 0 +> 0 +< 25 +> 25 +< 50 +> 50 +< 75 +> 75 +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< 0 +> 0 +< 5 +> 5 +< 10 +> 10 +< 15 +> 15 +< 20 +> 20 +< 25 +> 25 +< Dif +: ference between treatment in Response Rate (%) +> Differ +: ence between treatment in Response Rate (%) +< Probability (%) +> Probability (%) +< Probability of Difference +: and respective Go and Stop probabilities. +> Probability of Difference and +: respective Go and Stop probabilities. + + + + +Failed doppelganger: plot-of-distibution-of-difference-of-two-arms-with-beta-mixture (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg) + +< before +> after +@@ 33,5 / 33,5 @@ + + +< P(Stop) is 59.5 % +> P(Stop) is 59.49 % + P(Go) is 24.5 % + +@@ 61,5 / 61,5 @@ + x + ) +< According to Beta difference +: density P(Go) is 24.5 % and P(Stop) is 59.5 % +> According to Beta difference +: density P(Go) is 24.5 % and P(Stop) is 59.49 % + + + + +Failed doppelganger: plot-of-distibution-of-difference-of-two-arms (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + +@@ 17,75 / 14,56 @@ + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> +< P(Stop) is 11.72 % +> P(Stop) is 11.72 % +< P(Go) is 10.12 % +> P(Go) is 10.12 % +> + +< +> +< 0 +> 0 +< 1 +> 1 +< 2 +> 2 +< 3 +> 3 +< 4 +> 4 +< 5 +> 5 +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< -1.0 +> -1.0 +< -0.5 +> -0.5 +< 0.0 +> 0.0 +< 0.5 +> 0.5 +< 1.0 +> 1.0 +< Dif +: ference between treatment +> Differ +: ence between treatment +< +: f +> f +< ( +> ( +< +: x +> x +< ) +> ) +< According to Beta differen +: ce density P(Go) is 10.12 % and P(Stop) is 11.72 % +> According to Beta difference +: density P(Go) is 10.12 % and P(Stop) is 11.72 % + + + + +Failed doppelganger: plot-of-distibution-of-difference-of-two-arms-with-beta-mixture (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + + + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> +< P(Stop) is 11.72 % +> P(Stop) is 59.49 % +< P(Go) is 10.12 % +> P(Go) is 24.5 % +> + +< +> +< 0 +> 0 +< 1 +> 1 +< 2 +> 2 +< 3 +> 3 +< 4 +< 5 +< +< +< +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +> +< -1.0 +> -1.0 +< -0.5 +> -0.5 +< 0.0 +> 0.0 +< 0.5 +> 0.5 +< 1.0 +> 1.0 +< Dif +: ference between treatment +> Differ +: ence between treatment +< +: f +> f +< ( +> ( +< +: x +> x +< ) +> ) +< According to Beta differen +: ce density P(Go) is 10.12 % and P(Stop) is 11.72 % +> According to Beta difference +: density P(Go) is 24.5 % and P(Stop) is 59.49 % + + + + +Failed doppelganger: plot-of-distibution-of-difference-of-two-arms (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + +@@ 17,75 / 14,56 @@ + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> +< P(Stop) is 11.72 % +> P(Stop) is 11.72 % +< P(Go) is 10.12 % +> P(Go) is 10.12 % +> + +< +> +< 0 +> 0 +< 1 +> 1 +< 2 +> 2 +< 3 +> 3 +< 4 +> 4 +< 5 +> 5 +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< -1.0 +> -1.0 +< -0.5 +> -0.5 +< 0.0 +> 0.0 +< 0.5 +> 0.5 +< 1.0 +> 1.0 +< Dif +: ference between treatment +> Differ +: ence between treatment +< +: f +> f +< ( +> ( +< +: x +> x +< ) +> ) +< According to Beta differen +: ce density P(Go) is 10.12 % and P(Stop) is 11.72 % +> According to Beta difference +: density P(Go) is 10.12 % and P(Stop) is 11.72 % + + + + +Failed doppelganger: plot-of-distibution-of-difference-of-two-arms-with-beta-mixture (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotBetaDiff/plot-of-distibution-of-difference-of-two-arms-with-beta-mixture.svg) + +< before +> after +@@ 1,4 / 1,4 @@ + +< +> + + + + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> + + +< +> +< +> +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +< +> +> +> +> +> +< P(Stop) is 11.72 % +> P(Stop) is 59.49 % +< P(Go) is 10.12 % +> P(Go) is 24.5 % +> + +< +> +< 0 +> 0 +< 1 +> 1 +< 2 +> 2 +< 3 +> 3 +< 4 +< 5 +< +< +< +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +> +< -1.0 +> -1.0 +< -0.5 +> -0.5 +< 0.0 +> 0.0 +< 0.5 +> 0.5 +< 1.0 +> 1.0 +< Dif +: ference between treatment +> Differ +: ence between treatment +< +: f +> f +< ( +> ( +< +: x +> x +< ) +> ) +< According to Beta differen +: ce density P(Go) is 10.12 % and P(Stop) is 11.72 % +> According to Beta difference +: density P(Go) is 24.5 % and P(Stop) is 59.49 % + + + + +Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-probability.svg) + +< before +> after +@@ 33,4 / 33,8 @@ + + +> +> +> +> + + +@@ 38,17 / 42,16 @@ + + +< +< +< +> +< +> +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> +< +> + + +@@ 63,12 / 66,10 @@ + + +< +< +< +> +< +> +> +< 10 +> 10 +< 20 +> 20 +< 30 +> 30 +< NA + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-for-single-arm-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-for-single-arm-posterior-predictive-probability.svg) + +< before +> after +@@ 32,15 / 32,21 @@ + + +> +> +> +> + + + + +< +> +> + +< +> +> +< +> +< +> +< +> +< +> + + +@@ 53,10 / 59,14 @@ + + +< +> +> + +< +> +< 10 +< 20 +> +> 5 +> 10 +> 15 +> 20 +< NA +> 25 + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-without-relativedelta-for-posterior-predictive-probability.svg) + +< before +> after +@@ 31,13 / 31,20 @@ + + +> +> +> +> + + + +< +> +< +> +> +> +> +< +> +< +> +< +> +< +> + + +@@ 48,8 / 55,14 @@ + + +< +> +< +< 20 +< 30 +> +> +> +> +> 15 +> 20 +> 25 +> 30 +> 35 + look (n + ) + percentage + + +Failed doppelganger: plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability (/Users/audreyyeo/Documents/phase1b/phase1b/tests/testthat/_snaps/plotOc/plot-of-simulation-result-with-relativedelta-for-posterior-predictive-probability.svg) + +< before +> after +@@ 32,4 / 32,8 @@ + + +> +> +> +> + + +@@ 37,10 / 41,13 @@ + + +< +> +< +> +> +> +> +< +> +< +> +< +> +< +> + + +@@ 55,8 / 62,14 @@ + + +< +> +< +< 20 +< 30 +> +> +> +> +> 15 +> 20 +> 25 +> 30 +> 35 + look (n + ) + percentage + diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index abad3b8d..73f20e8d 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -142,7 +142,9 @@ function. The first time you use `phase1b` on your own computer you will need to download and install it, however, subsequent use will only require calling of the R-package. ```{r install-phase1b, eval=FALSE} -install.packages("phase1b") +library(devtools) +devtools::install_github("https://github.com/Genentech/phase1b") +# install.packages("phase1b") install.packages("ggplot2") ``` @@ -153,7 +155,9 @@ will have to load the R-package (assuming the R-package has been installed following the instructions in the [Installation section](#installation) with the following command: ```{r load} -library(phase1b) +library(devtools) +devtools::install_github("https://github.com/Genentech/phase1b") +# library(phase1b) library(ggplot2) ``` Once loaded, you will have access to all of the functions in the `phase1b` From 98120eb58a47fc7fa5fc368bd610958cf14a1379 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 12:51:05 +0200 Subject: [PATCH 58/67] clean --- vignettes/introduction.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 73f20e8d..7b619661 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -144,7 +144,7 @@ and install it, however, subsequent use will only require calling of the R-packa ```{r install-phase1b, eval=FALSE} library(devtools) devtools::install_github("https://github.com/Genentech/phase1b") -# install.packages("phase1b") +install.packages("phase1b") install.packages("ggplot2") ``` @@ -157,7 +157,7 @@ following command: ```{r load} library(devtools) devtools::install_github("https://github.com/Genentech/phase1b") -# library(phase1b) +library(phase1b) library(ggplot2) ``` Once loaded, you will have access to all of the functions in the `phase1b` From 4dd27137fb1ac43c2f498f664546ca2b6b1d301e Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 12:56:28 +0200 Subject: [PATCH 59/67] clean --- vignettes/introduction.Rmd | 1 - 1 file changed, 1 deletion(-) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 7b619661..6a7a1f13 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -144,7 +144,6 @@ and install it, however, subsequent use will only require calling of the R-packa ```{r install-phase1b, eval=FALSE} library(devtools) devtools::install_github("https://github.com/Genentech/phase1b") -install.packages("phase1b") install.packages("ggplot2") ``` From 8424ac87934882c0811efcf2b4a64dbd1afa0e90 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 13:10:18 +0200 Subject: [PATCH 60/67] clean --- .github/workflows/check.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 5b64fa68..75e22c4e 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -31,7 +31,7 @@ jobs: name: Coverage πŸ“” uses: insightsengineering/r.pkg.template/.github/workflows/test-coverage.yaml@main secrets: - REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO_GITHUB_TOKEN: ${{ secrets.REPO.GITHUB_TOKEN }} linter: if: github.event_name == 'pull_request' name: SuperLinter πŸ¦Έβ€β™€οΈ @@ -66,3 +66,6 @@ jobs: uses: insightsengineering/r.pkg.template/.github/workflows/style.yaml@main with: auto-update: true + - name: Install R dependencies + run: | + Rscript -e 'install.packages(c("devtools", "ggplot2"))' From f0d9a921224af06505b300bbf742518d4e9aa3a9 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 13:16:25 +0200 Subject: [PATCH 61/67] empty From 64db8fab2666fb6b09e8c8777a814236e32b2375 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 13:27:59 +0200 Subject: [PATCH 62/67] packagedown labels --- vignettes/introduction.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 6a7a1f13..db8d7c6a 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -613,7 +613,7 @@ ex1_prior_caption <- paste( ) ``` -```{r ex1-prior, echo=TRUE, fig.cap = ex1_prior_caption} +```{r fig:ex1-prior, echo=TRUE, fig.cap = ex1_prior_caption} xx <- seq(0, 1, .001) dens.control <- dbeta(xx, 75, 75) # Posterior of the control dens.prior <- dbeta(xx, 5.75, 4.25) # Prior of the Phase 1b trial @@ -830,7 +830,7 @@ ex1_betadiff_1_cap <- paste( ) ``` -```{r ex1:betadiff1, echo=TRUE, out.width="4in"} +```{r fig:ex1:betadiff1, echo=TRUE, out.width="4in"} parX <- c(75, 75) parY <- c(5.75 + 55, 4.25 + 80 - 55) xx <- seq(-0.5, 0.75, 0.001) From 6a8e7224854f142e1f86dd383fdcd09ca36af133 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 13:30:21 +0200 Subject: [PATCH 63/67] undo check.yml edits --- .github/workflows/check.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 75e22c4e..27d76546 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -66,6 +66,3 @@ jobs: uses: insightsengineering/r.pkg.template/.github/workflows/style.yaml@main with: auto-update: true - - name: Install R dependencies - run: | - Rscript -e 'install.packages(c("devtools", "ggplot2"))' From 71dcaad7ae1f5032b6aa93083e20354a2f71b6fb Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 15:57:56 +0200 Subject: [PATCH 64/67] empty From 2d98b58405d076f21e2021986ec5da6f0cd374ff Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Wed, 11 Jun 2025 16:12:35 +0200 Subject: [PATCH 65/67] undo check yml changes --- .github/workflows/check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 27d76546..5b64fa68 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -31,7 +31,7 @@ jobs: name: Coverage πŸ“” uses: insightsengineering/r.pkg.template/.github/workflows/test-coverage.yaml@main secrets: - REPO_GITHUB_TOKEN: ${{ secrets.REPO.GITHUB_TOKEN }} + REPO_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} linter: if: github.event_name == 'pull_request' name: SuperLinter πŸ¦Έβ€β™€οΈ From 81f8d33b9467052a9fa4587e4349d9adffc270c1 Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Thu, 12 Jun 2025 15:06:26 +0200 Subject: [PATCH 66/67] empty From de80695215901cb5d0e83dc2e11533e55cf2c82f Mon Sep 17 00:00:00 2001 From: Audrey Yeo Date: Fri, 13 Jun 2025 10:47:27 +0200 Subject: [PATCH 67/67] remove devtools command --- README.rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rmd b/README.rmd index 5f3e30d7..5436758b 100644 --- a/README.rmd +++ b/README.rmd @@ -23,7 +23,7 @@ The intended user is the early clinical trial statistician in the design and int You can install the development version of `phase1b` from [GitHub](https://github.com/) with: ``` r -devtools::install_github("https://github.com/Genentech/phase1b/", force = TRUE) +# devtools::install_github("https://github.com/Genentech/phase1b/", force = TRUE) library(phase1b) ```