Skip to content

Commit cc1e795

Browse files
Copilotrempsyc
andcommitted
Improve validation to also error when es_type used with effectsize=NULL
Co-authored-by: rempsyc <13123390+rempsyc@users.noreply.github.com>
1 parent cafab50 commit cc1e795

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

R/estimate_contrasts.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,12 @@ estimate_contrasts.default <- function(
320320

321321
# Validate es_type usage
322322
call_args <- match.call()
323-
if ("es_type" %in% names(call_args) && !is.null(effectsize) && effectsize != "boot") {
324-
insight::format_error("`es_type` can only be used when `effectsize = \"boot\"`.")
323+
if ("es_type" %in% names(call_args)) {
324+
if (is.null(effectsize)) {
325+
insight::format_error("`es_type` can only be used when `effectsize` is specified. Currently `effectsize = NULL`.")
326+
} else if (effectsize != "boot") {
327+
insight::format_error("`es_type` can only be used when `effectsize = \"boot\"`.")
328+
}
325329
}
326330

327331
if (backend == "emmeans") {

tests/testthat/test-estimate_contrasts_effectsize.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ test_that("estimate_contrasts - es_type only with effectsize='boot'", {
8383
"can only be used when"
8484
)
8585

86+
# Should error when es_type is used with effectsize = NULL
87+
expect_error(
88+
estimate_contrasts(model, es_type = "hedges.g", backend = "emmeans"),
89+
"can only be used when"
90+
)
91+
8692
# Should work when es_type is used with effectsize = "boot"
8793
set.seed(100)
8894
result <- estimate_contrasts(model, effectsize = "boot", es_type = "hedges.g", backend = "emmeans")

0 commit comments

Comments
 (0)