Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Language: en-US
LazyData: true
Roxygen:
list(markdown = TRUE, packages = "roxytypes")
RoxygenNote: 7.3.3
Config/Needs/documentation:
roxytypes
Remotes:
Expand Down Expand Up @@ -86,3 +85,4 @@ Collate:
'sumBetaDiff.R'
'sumTable.R'
Config/testthat/edition: 3
Config/roxygen2/version: 8.1.1
52 changes: 29 additions & 23 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
7 changes: 0 additions & 7 deletions R/dbetabinom.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions man/Phase1b-package.Rd

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

2 changes: 1 addition & 1 deletion man/plotDecision.Rd

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

2 changes: 1 addition & 1 deletion man/plotOc.Rd

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 10 additions & 16 deletions tests/testthat/test-dbetabinom.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand All @@ -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,
Expand Down
28 changes: 0 additions & 28 deletions tests/testthat/test-predprob.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion vignettes/introduction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
35 changes: 0 additions & 35 deletions vignettes/test.Rmd

This file was deleted.

Loading