r descr_models("linear_reg", "glmer")

Tuning Parameters

This model has no tuning parameters.

Translation from parsnip to the original package

r uses_extension("linear_reg", "glmer", "regression")

library(multilevelmod)

linear_reg() %>% 
  set_engine("glmer") %>% 
  set_mode("regression") %>% 
  translate()

Note that using this engine with a linear link function will result in a warning:

calling glmer() with family=gaussian (identity link) as a shortcut 
to lmer() is deprecated; please call lmer() directly

Preprocessing requirements

There are no specific preprocessing needs. However, it is helpful to keep the clustering/subject identifier column as factor or character (instead of making them into dummy variables). See the examples in the next section.

Other details

The model can accept case weights.

With parsnip, we suggest using the formula method when fitting:

library(tidymodels)
data("riesby")

linear_reg() %>% 
  set_engine("glmer") %>% 
  fit(depr_score ~ week + (1|subject), data = riesby)

When using tidymodels infrastructure, it may be better to use a workflow. In this case, you can add the appropriate columns using add_variables() then supply the typical formula when adding the model:

library(tidymodels)

glmer_spec <- 
  linear_reg() %>% 
  set_engine("glmer")

glmer_wflow <- 
  workflow() %>% 
  # The data are included as-is using:
  add_variables(outcomes = depr_score, predictors = c(week, subject)) %>% 
  add_model(glmer_spec, formula = depr_score ~ week + (1|subject))

fit(glmer_wflow, data = riesby)

Case weights


References



topepo/parsnip documentation built on April 16, 2024, 3:23 a.m.