test_that("estimate_means - mgcv gam", {
model <- mgcv::gam(Sepal.Length ~ Species + s(Sepal.Width, by = Species), data = iris)
estim <- suppressMessages(estimate_means(model, backend = "emmeans"))
estim2 <- suppressMessages(estimate_means(model, backend = "marginaleffects"))
expect_named(estim2, c("Species", "Mean", "SE", "CI_low", "CI_high", "t", "df"))
expect_equal(estim$Mean, estim2$Mean, tolerance = 1e-4)
test_that("estimate_contrasts - mgcv gam", {
estim <- suppressMessages(estimate_contrasts(model, backend = "emmeans"))
estim2 <- suppressMessages(estimate_contrasts(model, backend = "marginaleffects"))
expect_named(estim2, c("Level1", "Level2", "Difference", "SE", "CI_low", "CI_high", "t", "df", "p"))
expect_equal(estim$Difference, estim2$Difference * -1, tolerance = 1e-4) # switched signs
test_that("estimate_expectation - mgcv gam", {
estim <- suppressMessages(estimate_link(model, preserve_range = FALSE))
# model <- mgcv::gam(Sepal.Length ~ Petal.Length + s(Sepal.Width) + s(Species, bs = "fs"), data = iris)
test_that("estimate_expectation - mgcv gamm", {
model <- mgcv::gamm(Sepal.Length ~ Petal.Length + s(Sepal.Width), random = list(Species = ~1), data = iris)
test_that("estimate_link - mgcv gamm", {
estim <- estimate_link(model, length = 4, verbose = FALSE)
# model <- gamm4::gamm4(Sepal.Length ~ Petal.Length + s(Sepal.Width), random=~(1|Species), data = iris)
# test_that("estimate_expectation - gamm4", {
#   estim <- estimate_link(model, length=4)

"estimate_contrasts - by with special character"
"estimate_epectation - don't print empty RE columns"

estimate_contrasts - by with special character

skip_if_not_installed("marginaleffects")
skip_if_not_installed("emmeans")
test_that("verbose", {
data(iris)
model <- lm(Sepal.Width ~ Species, data = iris)
expect_message(estimate_contrasts(model, backend = "emmeans"), regex = "No variable was specified")
expect_silent(estimate_contrasts(model, backend = "emmeans", verbose = FALSE))
expect_message(estimate_means(model, backend = "emmeans"), regex = "We selected")
expect_silent(estimate_means(model, backend = "emmeans", verbose = FALSE))
expect_silent(estimate_contrasts(model, backend = "marginaleffects", verbose = FALSE))
expect_message(estimate_means(model, backend = "marginaleffects"), regex = "We selected")
expect_silent(estimate_means(model, backend = "marginaleffects", verbose = FALSE))
})