Skip to content

Commit

Permalink
- Updated fix for print.BayesianMCP() error
Browse files Browse the repository at this point in the history
- Harmonized attributes naming convention
- Fixed typo
  • Loading branch information
wojcieko committed Apr 10, 2024
1 parent a17f3e6 commit 3dd0d2d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions R/BMCPMod.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
30 changes: 15 additions & 15 deletions R/s3methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)

}

Expand Down
2 changes: 1 addition & 1 deletion man/performBayesianMCPMod.Rd

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

6 changes: 3 additions & 3 deletions tests/testthat/test-BMCPMod.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3dd0d2d

Please sign in to comment.