diff --git a/R/marginal_means.R b/R/marginal_means.R index 75c043466..235bf3062 100644 --- a/R/marginal_means.R +++ b/R/marginal_means.R @@ -191,7 +191,7 @@ marginal_means <- function(model, } # if type is NULL, we backtransform if relevant - type_string <- sanitize_type(model = model, type = type, calling_function = "predictions") + type_string <- sanitize_type(model = model, type = type, calling_function = "marginal_means") if (type_string == "invlink(link)") { type_call <- "link" } else { diff --git a/R/sanitize_type.R b/R/sanitize_type.R index bb39bf745..6c1baa59c 100644 --- a/R/sanitize_type.R +++ b/R/sanitize_type.R @@ -3,14 +3,16 @@ #' @param model model object #' @param type character vector #' @noRd -sanitize_type <- function(model, type, calling_function = NULL) { +sanitize_type <- function(model, type, calling_function = "raw") { checkmate::assert_character(type, len = 1, null.ok = TRUE) cl <- class(model)[1] if (!cl %in% type_dictionary$class) { cl <- "other" } dict <- type_dictionary - if (calling_function %in% c("slopes", "comparisons")) { + # raw is often invoked by `get_predict()`, which is required for {clarify} and others. + # we only allow invlink(link) in predictions() and marginal_means(), which are handled by {marginaleffects} + if (!calling_function %in% c("predictions", "marginal_means")) { dict <- dict[dict$type != "invlink(link)", , drop = FALSE] }