Skip to content

Commit

Permalink
Formatting probability of direction objects fails
Browse files Browse the repository at this point in the history
Fixes #603
  • Loading branch information
strengejacke committed Jun 29, 2023
1 parent efb0cab commit 8c06119
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
12 changes: 8 additions & 4 deletions R/equivalence_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,17 @@ equivalence_test.numeric <- function(x, range = "default", ci = 0.95, verbose =
out <- as.data.frame(rope_data)

if (all(ci < 1)) {
out$ROPE_Equivalence <- ifelse(out$ROPE_Percentage == 0, "Rejected",
ifelse(out$ROPE_Percentage == 1, "Accepted", "Undecided")
out$ROPE_Equivalence <- datawizard::recode_into(
out$ROPE_Percentage == 0 ~ "Rejected",
out$ROPE_Percentage == 1 ~ "Accepted",
default = "Undecided"
)
} else {
# Related to guidelines for full rope (https://easystats.github.io/bayestestR/articles/4_Guidelines.html)
out$ROPE_Equivalence <- ifelse(out$ROPE_Percentage < 0.025, "Rejected",
ifelse(out$ROPE_Percentage > 0.975, "Accepted", "Undecided")
out$ROPE_Equivalence <- datawizard::recode_into(
out$ROPE_Percentage < 0.025 ~ "Rejected",
out$ROPE_Percentage > 0.975 ~ "Accepted",
default = "Undecided"
)
}

Expand Down
46 changes: 46 additions & 0 deletions tests/testthat/test-format.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
test_that("p_significance", {
set.seed(333)
x <- rnorm(100)
expect_equal(
format(point_estimate(x)),
data.frame(Median = "0.05", Mean = "-0.02", MAP = "0.13", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(ci(x)),
data.frame(`95% CI` = "[-1.93, 1.77]", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(p_rope(x)),
data.frame(ROPE = "[-0.10, 0.10]", `p (ROPE)` = "0.100", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(bayesfactor_parameters(x, verbose = FALSE)),
data.frame(BF = "1.00", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(map_estimate(x)),
data.frame(x = "0.13", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(p_direction(x)),
data.frame(x = "0.51", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(p_map(x)),
data.frame(x = "0.97", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
expect_equal(
format(p_significance(x)),
data.frame(x = "0.46", stringsAsFactors = FALSE),
ignore_attr = TRUE
)
# format(rope(x))
# format(equivalence_test(x))
})

0 comments on commit 8c06119

Please sign in to comment.