suppressWarnings(suppressMessages({
library(brms)
library(dplyr)
library(magrittr)
}))
test_that("compare_groups() throws expected errors", {
fit <- readRDS(test_path('models/fit_gaussian_dummy.rds'))
expect_error(compare_groups(fit, hdi = '0.89'), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = NULL), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = NA), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = c(0.8, 0.95)), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = 0), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = -0.5), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = 1), "Argument 'hdi' must be a single value between 0 and 1.")
expect_error(compare_groups(fit, hdi = 1.5), "Argument 'hdi' must be a single value between 0 and 1.")
})
test_that("compare_groups() returns correct output", {
fit <- readRDS(test_path('models/fit_gaussian_dummy.rds'))
expect_equal(inherits(compare_groups(fit), "faintCompare"), TRUE)
expect_equal(compare_groups(fit, congruency == "con", hdi = 0.89)$hdi, 0.89)
expect_equal(compare_groups(fit, color == "red", congruency != "con")$higher, "color == \"red\"")
expect_equal(compare_groups(fit, color == "red", congruency != "con")$lower, "congruency != \"con\"")
expect_equal(compare_groups(fit, lower = color == "green")$higher, "grand mean")
expect_equal(compare_groups(fit, lower = congruency != "con" | color == "red")$lower,
"congruency != \"con\" | color == \"red\"")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.