tidymodels / multilevelmod

Parsnip wrappers for mixed-level and hierarchical models
https://multilevelmod.tidymodels.org/
Other
74 stars 3 forks source link

Engine 'glmer' is not supported for `logistic_reg()`... why? #69

Closed kyleGrealis closed 1 month ago

kyleGrealis commented 1 month ago

I was hoping to implement glmer into a project workflow where we're comparing multiple models. I believe our data would best be applied to a mixed effects model, but was disappointed (and confused) when checking the error message output against the table listed on the multilevelmod site. I see that logistic_reg using the glmer engine should be available for classification tasks

image

...But my error message states otherwise:

> mixed_spec <- 
+   logistic_reg() |>
+   set_engine(engine = "glmer") |> 
+   fit(formula = mixed_formula, data = a_train)
Error in `fit()`:
! Engine 'glmer' is not supported for `logistic_reg()`. See `show_engines('logistic_reg')`.
Hide Traceback
    ▆
 1. ├─generics::fit(...)
 2. └─parsnip::fit.model_spec(...)
 3.   └─parsnip:::add_methods(object, engine = object$engine)
 4.     └─parsnip:::check_spec_mode_engine_val(...)
 5.       └─rlang::abort(...)
> show_engines('logistic_reg')
# A tibble: 7 × 2
  engine    mode          
  <chr>     <chr>         
1 glm       classification
2 glmnet    classification
3 LiblineaR classification
4 spark     classification
5 keras     classification
6 stan      classification
7 brulee    classification

Can someone be so kind as to clarify for me?

Thank you so much and I appreciate the hard work of this team!

Kyle

hfrick commented 1 month ago

Hi @kyleGrealis, is it possible that you haven't loaded multilevelmod in that example?

library(parsnip)

show_engines('logistic_reg')
#> # A tibble: 7 × 2
#>   engine    mode          
#>   <chr>     <chr>         
#> 1 glm       classification
#> 2 glmnet    classification
#> 3 LiblineaR classification
#> 4 spark     classification
#> 5 keras     classification
#> 6 stan      classification
#> 7 brulee    classification

library(multilevelmod) 

show_engines('logistic_reg')
#> # A tibble: 10 × 2
#>    engine     mode          
#>    <chr>      <chr>         
#>  1 glm        classification
#>  2 glmnet     classification
#>  3 LiblineaR  classification
#>  4 spark      classification
#>  5 keras      classification
#>  6 stan       classification
#>  7 brulee     classification
#>  8 gee        classification
#>  9 glmer      classification
#> 10 stan_glmer classification

Created on 2024-09-23 with reprex v2.1.0

kyleGrealis commented 1 month ago

🥴 yup! 100% the case. thank you for reminding me of using the basics. sheesh! lol

hfrick commented 1 month ago

No worries! Glad it was easy to solve!