diff --git a/DESCRIPTION b/DESCRIPTION index aba92d1e..36392e3f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -53,7 +53,6 @@ Language: en-US LazyData: true Roxygen: list(markdown = TRUE, packages = "roxytypes") -RoxygenNote: 7.3.3 Config/Needs/documentation: roxytypes Remotes: @@ -86,3 +85,4 @@ Collate: 'sumBetaDiff.R' 'sumTable.R' Config/testthat/edition: 3 +Config/roxygen2/version: 8.1.1 diff --git a/NAMESPACE b/NAMESPACE index 1253a03a..025ee2d7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,28 +32,34 @@ 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) -importFrom(graphics,lines) -importFrom(graphics,plot) -importFrom(graphics,polygon) +importFrom(ggplot2, + annotate, + geom_area, + geom_bar, + geom_line, + ggtitle, + theme_light, + xlab, + ylab +) +importFrom(graphics, + abline, + axis, + hist, + lines, + plot, + polygon +) importFrom(lifecycle,deprecated) -importFrom(stats,acf) -importFrom(stats,binom.test) -importFrom(stats,dbeta) -importFrom(stats,dbinom) -importFrom(stats,integrate) -importFrom(stats,optimize) -importFrom(stats,pbeta) -importFrom(stats,rbinom) -importFrom(stats,uniroot) +importFrom(stats, + acf, + binom.test, + dbeta, + dbinom, + integrate, + optimize, + pbeta, + rbinom, + uniroot +) importFrom(tibble,remove_rownames) diff --git a/R/dbetabinom.R b/R/dbetabinom.R index 840631b0..411dee23 100644 --- a/R/dbetabinom.R +++ b/R/dbetabinom.R @@ -90,13 +90,6 @@ h_getBetamixPost <- function(x, n, par, weights) { finite = TRUE ) assert_true(all(weights >= 0)) - # Correcting weights that do not sum to 1 - if (sum(weights) != 1) { - warning("Weights have been corrected. Advise to review allocated weights") - # We renormalize weights. - weights <- weights / sum(weights) - } - # We now compute updated parameters. postPar <- par postPar[, 1] <- postPar[, 1] + x diff --git a/man/Phase1b-package.Rd b/man/Phase1b-package.Rd index b31c037f..755383b6 100644 --- a/man/Phase1b-package.Rd +++ b/man/Phase1b-package.Rd @@ -23,6 +23,7 @@ Useful links: Authors: \itemize{ + \item Daniel Sabanes Bove \email{daniel@rconis.com} \item Markus Elze \email{markus.elze@roche.com} \item Tony Pourmohamad \email{pourmoht@gene.com} \item Jiawen Zhu \email{zhu.jiawen@gene.com} diff --git a/man/plotDecision.Rd b/man/plotDecision.Rd index 434cee7a..c63149eb 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{ -\code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} object +\code{\link[ggplot2:ggplot]{ggplot()}} object } \description{ This function will return a plot showing a curve of the probability of a meaningful improvement over estimated diff diff --git a/man/plotOc.Rd b/man/plotOc.Rd index 526944c4..0cedde4b 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{ -\code{\link[ggplot2:ggplot]{ggplot2::ggplot()}} object +\code{\link[ggplot2:ggplot]{ggplot()}} object } \description{ Plots results from simulated results of : diff --git a/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-with-beta-mixture.svg b/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-with-beta-mixture.svg index b6d75bda..19eb0a37 100644 --- a/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-with-beta-mixture.svg +++ b/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-with-beta-mixture.svg @@ -1,5 +1,5 @@ - + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - -P(Stop) is 11.72 % -P(Go) is 10.12 % + + + + + + + +P(Stop) is 11.72 % +P(Go) is 10.12 % + - -0 -1 -2 -3 -4 -5 - - - - - - - - - - - --1.0 --0.5 -0.0 -0.5 -1.0 -Difference between treatment -f -( -x -) -According to Beta difference density P(Go) is 10.12 % and P(Stop) is 11.72 % + +0 +1 +2 +3 +4 +5 + + + + + + + + + + + +-1.0 +-0.5 +0.0 +0.5 +1.0 +Difference between treatment +f +( +x +) +According to Beta difference density P(Go) is 10.12 % and P(Stop) is 11.72 % diff --git a/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-without-beta-mixture.svg b/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-without-beta-mixture.svg index 4328b13e..a7ac4be9 100644 --- a/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-without-beta-mixture.svg +++ b/tests/testthat/_snaps/plotBetaDiff/Plot-of-plotBetaDiff-without-beta-mixture.svg @@ -1,5 +1,5 @@ - + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - -P(Stop) is 59.49 % -P(Go) is 24.5 % + + + + + + + +P(Stop) is 59.49 % +P(Go) is 24.5 % + - -0 -1 -2 -3 - - - - - - - - - --1.0 --0.5 -0.0 -0.5 -1.0 -Difference between treatment -f -( -x -) -According to Beta difference density P(Go) is 24.5 % and P(Stop) is 59.49 % + +0 +1 +2 +3 + + + + + + + + + +-1.0 +-0.5 +0.0 +0.5 +1.0 +Difference between treatment +f +( +x +) +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 ec7af51f..e64ca08c 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 @@ -32,30 +32,30 @@ - - - - - - + + + + + + - - - - - - - - - - - - -Probability of Go is 60% when difference is at least 21.18% -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% @@ -67,18 +67,18 @@ - - - - - - -0 -5 -10 -15 -20 -25 + + + + + + +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/test-dbetabinom.R b/tests/testthat/test-dbetabinom.R index 60b3e547..ff7eb9e6 100644 --- a/tests/testthat/test-dbetabinom.R +++ b/tests/testthat/test-dbetabinom.R @@ -257,14 +257,11 @@ test_that("h_getBetamixPost gives the correct beta-mixture parameters", { }) test_that("h_getBetamixPost gives weight of 1 for a single beta distribution", { - expect_warning( - results <- h_getBetamixPost( - x = 16, - n = 23, - par = rbind(c(1, 2)), - weights = 0.1 - ), - "Weights have been corrected" + results <- h_getBetamixPost( + x = 16, + n = 23, + par = rbind(c(1, 2)), + weights = 0.1 ) expected <- list( par = rbind(c(17, 9)), @@ -285,14 +282,11 @@ test_that("h_getBetamixPost gives correct weights with 2 beta-mixture component" }) test_that("h_getBetamixPost gives the correct weights when sum of weights is not 1 in beta-mixture", { - expect_warning( - result <- h_getBetamixPost( - x = 16, - n = 23, - par = rbind(c(1, 2), c(3, 4), c(10, 10)), - weights = c(0.6, 0.4, 0.5) - ), - "Weights have been corrected" + result <- h_getBetamixPost( + x = 16, + n = 23, + par = rbind(c(1, 2), c(3, 4), c(10, 10)), + weights = c(0.6, 0.4, 0.5) ) expect_equal( result$weights, diff --git a/tests/testthat/test-predprob.R b/tests/testthat/test-predprob.R index 6137a9dd..fd6bb744 100644 --- a/tests/testthat/test-predprob.R +++ b/tests/testthat/test-predprob.R @@ -118,34 +118,6 @@ test_that("predprob gives an error when x exceeds interim n", { ) }) -test_that("Warning length equal to length of x", { - captured_warnings <- capture_warnings({ - result <- predprob( - x = 16, - n = 20, - Nmax = 22, - p = 0.6, - thetaT = 0.9, - parE = rbind(c(1, 1), c(25, 15)), - weights = c(3, 1) - ) - }) - expected <- data.frame( - counts = 0:2, - cumul_counts = c(20, 21, 22), - density = c(0.0738, 0.3651, 0.5611), - posterior = c(0.862329474749815, 0.928990451842824, 0.969938389163636), - success = c(FALSE, TRUE, TRUE) - ) - expect_equal( - length(captured_warnings), - 4, - info = "Should have generated one warning for each element in 'x' in the loop." - ) - expect_equal(result$result, 0.9262315, tolerance = 1e-4) - expect_equal(result$table, expected, tolerance = 1e-4) -}) - test_that("predprob gives an error when Nmax is less than n", { expect_error( predprob( diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 06e7d793..45231548 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -172,7 +172,7 @@ help(package = "phase1b") A list of functions will be displayed and you can learn more about each function, and see examples of its use, by clicking on its corresponding link. -Note that this will easiest work in [R-Studio](https://posit.co/download/rstudio-desktop/), which +Note that this will easiest work in [R-Studio](https://docs.posit.co/ide/user/#rstudio-ide-oss-downloads?ref=rstudio-legacy), which is the recommended software for editing and using R. # Methods and Models {#methods} diff --git a/vignettes/test.Rmd b/vignettes/test.Rmd deleted file mode 100644 index d5b056d6..00000000 --- a/vignettes/test.Rmd +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: "test" -package: phase1b -bibliography: '`r system.file("REFERENCES.bib", package = "phase1b")`' -author: - - name: Daniel Sabanes Bove - email: daniel.sabanes_bove@roche.com -output: - bookdown::html_document2: - theme: "spacelab" - highlight: "kate" - toc: true - toc_float: true -vignette: | - %\VignetteEncoding{UTF-8} - %\VignetteIndexEntry{test} - %\VignetteEngine{knitr::rmarkdown} -editor_options: - chunk_output_type: console ---- - -```{r, include = FALSE} -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - -```{r, echo = FALSE} -cap <- "blo" -``` - -```{r bla, echo=FALSE, fig.cap = cap} -plot(cars) -```