r descr_models("linear_reg", "glmer")
This model has no tuning parameters.
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
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.
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)
J Pinheiro, and D Bates. 2000. Mixed-effects models in S and S-PLUS. Springer, New York, NY
West, K, Band Welch, and A Galecki. 2014. Linear Mixed Models: A Practical Guide Using Statistical Software. CRC Press.
Thorson, J, Minto, C. 2015, Mixed effects: a unifying framework for statistical modelling in fisheries biology. ICES Journal of Marine Science, Volume 72, Issue 5, Pages 1245–1256.
Harrison, XA, Donaldson, L, Correa-Cano, ME, Evans, J, Fisher, DN, Goodwin, CED, Robinson, BS, Hodgson, DJ, Inger, R. 2018. A brief introduction to mixed effects modelling and multi-model inference in ecology. PeerJ 6:e4794.
DeBruine LM, Barr DJ. Understanding Mixed-Effects Models Through Data Simulation. 2021. Advances in Methods and Practices in Psychological Science.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.