Skip to content
Merged
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
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# BayesERtools 0.2.5 (in development)

## Major changes


* Updated compatibility with upcoming changes to `loo_compare()` output
structure in the `loo` package (> 2.9.0), which now returns a data frame
instead of a matrix and includes additional diagnostic columns.

## Minor changes

* Allow manual breaks in `plot_er()` to control the position of the probability
Expand Down
6 changes: 5 additions & 1 deletion R/dev_ermod_lin.R
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,11 @@ dev_ermod_lin_cov_sel <- function(
function(.x) loo(.x)
)
comp_exposures <- loo::loo_compare(l_loo_exposures)
var_exposure <- rownames(comp_exposures)[[1]]
if ("model" %in% colnames(comp_exposures)) {
var_exposure <- comp_exposures$model[[1]]
} else {
var_exposure <- rownames(comp_exposures)[[1]]
}

if (verbosity_level >= 1) {
cli::cli_alert_info("The exposure metric selected was: {var_exposure}")
Expand Down
15 changes: 11 additions & 4 deletions tests/testthat/test-dev_ermod_lin.R
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,17 @@ mod_mtcars <- dev_ermod_bin(

test_that("Exposure metrics selection", {
expect_equal(extract_var_exposure(ermod_bin_exp_sel), "AUCss_1000")
expect_equal(
extract_exp_sel_comp(ermod_bin_exp_sel)[, 1],
c(AUCss_1000 = 0.000000, Cmaxss = -0.6490312, Cminss = -2.7563957)
)
if ("model" %in% colnames(extract_exp_sel_comp(ermod_bin_exp_sel))) {
expect_equal(
extract_exp_sel_comp(ermod_bin_exp_sel)[, 2],
c(0.000000, -0.6490312, -2.7563957)
)
} else {
expect_equal(
extract_exp_sel_comp(ermod_bin_exp_sel)[, 1],
c(AUCss_1000 = 0.000000, Cmaxss = -0.6490312, Cminss = -2.7563957)
)
}

priors <- prior_summary(ermod_bin_exp_sel$l_mod_exposures[[2]])
expect_equal(priors$prior$scale, 5)
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-loo_kfold.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ if (.if_run_ex_eval_mod()) {
})

test_that("kfold", {
expect_gt(comp[[2, 1]], -0.5)
if ("model" %in% colnames(comp)) {
expect_gt(comp[[2, 2]], -0.5)
} else {
expect_gt(comp[[2, 1]], -0.5)
}
expect_equal(
kfold_ermod_bin$estimates[, 1],
c(elpd_kfold = -38.242947, p_kfold = 3.040264, kfoldic = 76.485893)
Expand Down
Loading