Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: estimate_contrasts failing with basic example #425

Closed
dfalster opened this issue Feb 27, 2025 · 3 comments · Fixed by #426
Closed

Bug: estimate_contrasts failing with basic example #425

dfalster opened this issue Feb 27, 2025 · 3 comments · Fixed by #426
Assignees

Comments

@dfalster
Copy link

Hi team, thanks for the great work. I love how your packages make it easier to process the outputs of models. I use these teaching a large 2nd year university course with 170 students. :)

I'm encountering a strange error and not sure how to solve or diagnose this. When I run estimate_contrasts with the basic example I get a cryptic error. I'm running the latest version on max OSX, R and packages. Moreover it used to work, so this behaviour has appeared in the last few days. Not sure how or why.

I've also included the stack call below. I'm a reasonably advanced user and a bit perplexed

The below was run in a clean R session. It occurs whether running in rstduio or terminal,

> library(modelbased)
>   model <- lm(Sepal.Width ~ Species, data = iris)
>    estimate_contrasts(model)
We selected `contrast=c("Species")`.
Error: Sorry, calculating marginal contrasts failed with following error:
Assertion failed. One of the following must apply: * checkmate::check_character(hypothesis): Must be of type
  'character', not 'formula' * checkmate::check_choice(hypothesis): Must be element of set
  {'pairwise','reference','sequential','meandev','meanotherdev','revpairwise','revreference','revsequential'}, but is * not atomic scalar * checkmate::check_numeric(hypothesis): Must
  be of type 'numeric', not 'formula' * checkmate::check_matrix(hypothesis): Must be of type 'matrix', not 'formula' * checkmate::check_function(hypothesis): Must be a function, not
  'formula' * checkmate::check_null(hypothesis): Must be NULL

> sessionInfo()
R version 4.4.2 (2024-10-31)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.3.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_AU.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base

other attached packages:
[1] modelbased_0.9.0 datapasta_3.1.0

loaded via a namespace (and not attached):
 [1] marginaleffects_0.20.1 compiler_4.4.2         backports_1.5.0        generics_0.1.3         cli_3.6.3.9002         datawizard_1.0.0       Rcpp_1.0.14            crayon_1.5.3.9000
 [9] data.table_1.16.4      checkmate_2.3.2        insight_1.0.2          rlang_1.1.5            rdoc_0.1.0.9000

Stack


> options(error=recover)
> estimate_contrasts(model)
We selected `contrast=c("Species")`.
Error: Sorry, calculating marginal contrasts failed with following error:
Assertion failed. One of the following must apply: * checkmate::check_character(hypothesis): Must be of type
  'character', not 'formula' * checkmate::check_choice(hypothesis): Must be element of set
  {'pairwise','reference','sequential','meandev','meanotherdev','revpairwise','revreference','revsequential'}, but is * not atomic scalar * checkmate::check_numeric(hypothesis): Must
  be of type 'numeric', not 'formula' * checkmate::check_matrix(hypothesis): Must be of type 'matrix', not 'formula' * checkmate::check_function(hypothesis): Must be a function, not
  'formula' * checkmate::check_null(hypothesis): Must be NULL

Enter a frame number, or 0 to exit

1: estimate_contrasts(model)
2: estimate_contrasts.default(model)
3: get_marginalcontrasts(model, contrast = contrast, by = by, predict = predict, comparison = comparison, p_adjust = p_adjust, ci = ci, estimate = estimate, transform = transform, verbose = verbose,
4: estimate_means(model = model, by = unique(c(my_args$contrast, my_args$by)), ci = ci, hypothesis = my_args$comparison, predict = predict, backend = "marginaleffects", estimate = estimate, transfor
5: get_marginalmeans(model, by = by, predict = predict, ci = ci, estimate = estimate, transform = transform, verbose = verbose, ...)
6: .call_marginaleffects(fun_args)
7: insight::format_error(msg)
8: format_alert(..., type = "error")
@strengejacke
Copy link
Member

We should check is the correct version of marginaleffects is installed. In your case, you need to update to version 0.20.5, then it should work.

@strengejacke
Copy link
Member

No, sorry, you need marginaleffects 0.25.0
Anyway, I recommend updating packages, and after that, run easystats::install_latest().

@dfalster
Copy link
Author

Thanks for the rapid response. confirming that updating to marginaleffects 0.25.0 fixed it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants