Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jan 25, 2025
1 parent 8f059bb commit 3aaa54f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions R/get_marginalcontrasts.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ get_marginalcontrasts <- function(model,
# ---------------------------------------------------------------------------

## TODO: just experimental! Must wait for decision on marginaleffects
if (utils::packageVersion("marginaleffects") > "0.24.0" && "Parameter" %in% names(out)) {
redundant_rows <- duplicated(lapply(out$Parameter, function(i) sort(.split_at_minus_outside_parentheses(i))))
if (any(redundant_rows)) {
out <- out[redundant_rows, ]
}
}
# if (utils::packageVersion("marginaleffects") > "0.24.0" && "Parameter" %in% names(out)) {
# redundant_rows <- duplicated(lapply(out$Parameter, function(i) sort(.split_at_minus_outside_parentheses(i))))
# if (any(redundant_rows)) {
# out <- out[redundant_rows, ]
# }
# }

# adjust p-values
if (!insight::model_info(model)$is_bayesian) {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-attributes_estimatefun.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ test_that("attributes_means, contrasts", {


test_that("attributes_means, slopes", {
skip_if(utils::packageVersion("marginaleffects") <= "0.24.0")
data(iris)
model <- lm(Sepal.Length ~ Species + Sepal.Width, data = iris)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-mgcv.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ test_that("estimate_contrasts - mgcv gam", {
estim2 <- suppressMessages(estimate_contrasts(model, backend = "marginaleffects"))
expect_identical(dim(estim2), c(3L, 9L))
expect_named(estim2, c("Level1", "Level2", "Difference", "SE", "CI_low", "CI_high", "t", "df", "p"))
expect_equal(estim$Difference, estim2$Difference, tolerance = 1e-4)
expect_equal(estim$Difference, estim2$Difference * -1, tolerance = 1e-4) # switched signs
})


Expand Down

0 comments on commit 3aaa54f

Please sign in to comment.