diff --git a/DESCRIPTION b/DESCRIPTION index 00206d29..94f1de34 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rbmi Title: Reference Based Multiple Imputation -Version: 1.1.2 +Version: 1.1.3 Authors@R: c( person("Craig", "Gower-Page", email = "craig.gower-page@roche.com", role = c("aut", "cre")), person("Alessandro", "Noci", email = "alessandro.noci@roche.com", role = c("aut")), diff --git a/R/mcmc.R b/R/mcmc.R index 109e125f..5924df9c 100644 --- a/R/mcmc.R +++ b/R/mcmc.R @@ -115,6 +115,12 @@ fit_mcmc <- function( ) ) + assert_that( + !is.na(seed), + !is.null(seed), + is.numeric(seed), + msg = "mcmc seed is invalid" + ) sampling_args$seed <- seed stan_fit <- record({ diff --git a/R/methods.R b/R/methods.R index c5bfd959..c652cdf9 100644 --- a/R/methods.R +++ b/R/methods.R @@ -93,7 +93,7 @@ method_bayes <- function( burn_between = 50, same_cov = TRUE, n_samples = 20, - seed = NA + seed = sample.int(.Machine$integer.max, 1) ) { x <- list( burn_in = burn_in, diff --git a/cran-comments.md b/cran-comments.md index 6aea0b6d..f7398558 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,10 +1,7 @@ ## Resubmission This is a resubmission. In this version I have: -* Stabilised some of our unit tests to reduce the occurrence of false-positive failures due to random variations from different CPU's/OS's. -* Added a bug report URL and a support site URL to our DESCRIPTION file -* Updated STAN code to hopefully fix the clang-UBSAN error. Please note though we were not able -to reproduce this CRAN error locally so are not 100% if this fix will work. +* Fixed the clang-UBSAN error ## R CMD check results diff --git a/man/method.Rd b/man/method.Rd index 960fc824..0ba22c87 100644 --- a/man/method.Rd +++ b/man/method.Rd @@ -13,7 +13,7 @@ method_bayes( burn_between = 50, same_cov = TRUE, n_samples = 20, - seed = NA + seed = sample.int(.Machine$integer.max, 1) ) method_approxbayes( diff --git a/tests/testthat/test-mcmc.R b/tests/testthat/test-mcmc.R index 16ecbad2..581a5763 100644 --- a/tests/testthat/test-mcmc.R +++ b/tests/testthat/test-mcmc.R @@ -421,7 +421,8 @@ test_that("fit_mcmc can recover known values with same_cov = TRUE", { group = dat2$group, subjid = dat2$id, visit = dat2$visit, - method = method + method = method, + quiet = TRUE ) beta_within <- get_within(fit$samples$beta, c(10, 6, 3, 7, 0, 0, 7, 14)) @@ -602,3 +603,38 @@ test_that("fit_mcmc can recover known values with same_cov = FALSE", { }) + + +test_that("invalid seed throws an error", { + + set.seed(301) + sigma <- as_vcov(c(6, 4, 4), c(0.5, 0.2, 0.3)) + dat <- get_sim_data(50, sigma) + + dat_ice <- dat %>% + group_by(id) %>% + arrange(desc(visit)) %>% + slice(1) %>% + ungroup() %>% + mutate(strategy = "MAR") + + vars <- set_vars( + visit = "visit", + subjid = "id", + group = "group", + covariates = "sex", + strategy = "strategy", + outcome = "outcome" + ) + + expect_error( + draws( + dat, + dat_ice, + vars, + method_bayes(n_samples = 2, seed = NA), + quiet = TRUE + ), + regexp = "mcmc seed is invalid" + ) +}) diff --git a/vignettes/advanced.html b/vignettes/advanced.html index be8903d3..3b4a85ca 100644 --- a/vignettes/advanced.html +++ b/vignettes/advanced.html @@ -15,19 +15,6 @@