Skip to content

Commit

Permalink
Merge branch 'main' into revdep0
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Sep 11, 2023
2 parents 1b31540 + 87dd2cc commit 438d74e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/marginal_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions R/sanitize_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}

Expand Down

0 comments on commit 438d74e

Please sign in to comment.