Skip to content

Commit afa437d

Browse files
committed
fix
1 parent 62a2e4e commit afa437d

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

R/get_contexteffects.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
} else {
1313
dots <- list(...)
1414
fun_args <- list(model, variables = my_args$contrast, hypothesis = my_args$comparison)
15+
# set default for "type" argument, if not provided
1516
if (is.null(dots$type)) {
1617
fun_args$type <- "link"
17-
}
18-
if (is.null(dots$transform)) {
19-
fun_args$transform <- "exp"
18+
# if "type" was not provided, also change transform argument. we do
19+
# this only when user did not provide "type", else - if user provided
20+
# "type" - we keep the default NULL
21+
if (is.null(dots$transform)) {
22+
fun_args$transform <- "exp"
23+
}
2024
}
2125
out <- do.call(marginaleffects::avg_comparisons, c(fun_args, dots))
2226
}

tests/testthat/test-estimate_contrasts_context.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ test_that("estimate_contrast, context effects, glm", {
3636
comparison = "context"
3737
)
3838
expect_equal(out$Estimate, exp(b[1] - b[2]), tolerance = 1e-4, ignore_attr = TRUE)
39+
out <- modelbased::estimate_contrasts(
40+
m,
41+
c("bill_len_between", "bill_len_within"),
42+
comparison = "context",
43+
type = "response"
44+
)
45+
expect_equal(out$Estimate, exp(b[1] - b[2]), tolerance = 1e-4, ignore_attr = TRUE)
3946
})

0 commit comments

Comments
 (0)