diff --git a/NEWS.md b/NEWS.md index 4aaf810..aa429e2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ - Re-submission of the 'BayesianMCPMod' package - Removed a test that occasionally failed on the fedora CRAN test system -- Fixed a bug that would return wrong bootstrapped quantiles in getBootstrappedQuantiles() +- Fixed a bug that would return wrong bootstrapped quantiles in getBootstrapQuantiles() - Added getBootstrapSamples(), a separate function for bootstrapping samples ## BayesianMCPMod 1.0.0 (31-Dec-2023) diff --git a/R/BMCPMod.R b/R/BMCPMod.R index 8d1c161..10c5ecc 100644 --- a/R/BMCPMod.R +++ b/R/BMCPMod.R @@ -409,7 +409,7 @@ performBayesianMCPMod <- function ( if (b_mcp[i, 1]) { - sign_models <- b_mcp[i, -c(1, 2)] > attr(b_mcp, "crit_prob_adj") + sign_models <- b_mcp[i, -c(1, 2)] > attr(b_mcp, "critProbAdj") model_fits <- getModelFits( models = model_shapes, @@ -530,10 +530,10 @@ performBayesianMCP <- function( } - class(b_mcp) <- "BayesianMCP" - attr(b_mcp, "crit_prob_adj") <- crit_prob_adj - attr(b_mcp, "successRate") <- mean(b_mcp[, 1]) - attr(b_mcp, "ess_avg") <- ifelse( + class(b_mcp) <- "BayesianMCP" + attr(b_mcp, "critProbAdj") <- crit_prob_adj + attr(b_mcp, "successRate") <- mean(b_mcp[, 1]) + attr(b_mcp, "essAvg") <- ifelse( test = is.na(attr(posterior_list[[1]], "ess")), yes = numeric(0), no = rowMeans(sapply(posterior_list, function (posteriors) { diff --git a/R/s3methods.R b/R/s3methods.R index 272183c..e9dca86 100644 --- a/R/s3methods.R +++ b/R/s3methods.R @@ -24,33 +24,33 @@ print.BayesianMCP <- function ( n_sim <- nrow(x) - model_successes <- getModelSuccesses(x) - cat("Bayesian Multiple Comparison Procedure\n") if (n_sim == 1L) { - attr(x, "crit_prob_adj") <- NULL - attr(x, "success_rate") <- NULL - class(x) <- NULL + attr(x, "critProbAdj") <- NULL + attr(x, "successRate") <- NULL + class(x) <- NULL print.default(x, ...) + # if (any(!is.na(attr(x, "essAvg")))) { + # + # cat("Average Posterior ESS\n") + # print(attr(x, "essAvg"), ...) + # + # } + } else { + model_successes <- getModelSuccesses(x) + cat(" Estimated Success Rate: ", attr(x, "successRate"), "\n") cat(" N Simulations: ", n_sim) - } - - cat("\n") - cat("Model Significance Frequencies\n") - print(model_successes, ...) - - if (any(!is.na(attr(x, "ess_avg")))) { - - cat("Average Posterior ESS\n") - print(attr(x, "ess_avg"), ...) + cat("\n") + cat("Model Significance Frequencies\n") + print(model_successes, ...) } diff --git a/man/performBayesianMCPMod.Rd b/man/performBayesianMCPMod.Rd index ea69c93..bac1a7f 100644 --- a/man/performBayesianMCPMod.Rd +++ b/man/performBayesianMCPMod.Rd @@ -19,7 +19,7 @@ performBayesianMCPMod(posterior_list, contr, crit_prob_adj, simple = FALSE) Bayesian MCP test result as well as modelling result. } \description{ -Performs Bayesian MCP Test step and modeling in a combined fashion. See performBayesianMCP() function for MCP Test step and getModelFits() for the modelling step +Performs Bayesian MCP Test step and modeling in a combined fashion. See performBayesianMCP() function for MCP Test step and getModelFits() for the modeling step } \examples{ mods <- DoseFinding::Mods(linear = NULL, diff --git a/tests/testthat/test-BMCPMod.R b/tests/testthat/test-BMCPMod.R index 7389525..23fa99b 100644 --- a/tests/testthat/test-BMCPMod.R +++ b/tests/testthat/test-BMCPMod.R @@ -29,7 +29,7 @@ test_that("base case input throws no error and has correct properties", { # assessDesign result (in this base case) should have crit_prob = 1 - alpha_crit_val expect_equal( - attr(eval_design$linear$BayesianMCP, "crit_prob"), + attr(eval_design$linear$BayesianMCP, "critProb"), 1 - alpha_crit_val ) @@ -180,11 +180,11 @@ test_that("performBayesianMCP returns the right type of object under normal case ) expect_true( - attr(b_mcp, "crit_prob_adj") == crit_pval + attr(b_mcp, "critProbAdj") == crit_pval ) expect_type( - attr(b_mcp, "ess_avg"), "logical" + attr(b_mcp, "essAvg"), "logical" ) expect_type(