Skip to content

Commit

Permalink
Don't use the bbmle::profile() try_harder option in calc_MinDose().
Browse files Browse the repository at this point in the history
This makes it fail much faster when a converging fit for the profile
log-likelihood cannot be found.
  • Loading branch information
mcol committed Sep 13, 2024
1 parent ee736cb commit 0a4e193
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/calc_MinDose.R
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ calc_MinDose <- function(
bbmle::profile(ests,
which = which,
std.err = as.vector(coef_err),
try_harder = TRUE,
# try_harder = TRUE,
quietly = TRUE,
maxsteps = maxsteps,
tol.newmin = Inf,
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test_calc_MinDose.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ test_that("check class and length of output", {
data.na[1, 1] <- NA
expect_message(calc_MinDose(data.na, sigmab = 0.1, verbose = FALSE),
"Input data contained NA/NaN values, which were removed")

set.seed(1)
data.nofit <- data.frame(rep(4, 5), rnorm(5, 5))
SW({
expect_error(calc_MinDose(data.nofit, sigmab = 0.9, par=4),
"Couldn't find a converging fit for the profile log-likelihood")
})
})

test_that("check values from output example", {
Expand Down

0 comments on commit 0a4e193

Please sign in to comment.