tidymodels / multilevelmod

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

Default prediction mode for lmer - re.form = NA #59

Closed Jeffrothschild closed 1 year ago

Jeffrothschild commented 1 year ago

When using the lmer engine, would it make more sense for the default predictions to be the same as the lmer default (re.form = NULL)? Currently the default uses re.form = NA

Perhaps there's a good reason I'm not aware of, but when adapting a lmer model into the tidymodels framework, I'd imagine most people would expect the predictions to default to the same as lmer.

Thanks

hfrick commented 1 year ago

Hey @Jeffrothschild, thanks for the issue!

In general, we try to make the models and predictions work the same via tidymodels as they do via the engine implementation directly. So your intuition is not wrong. However, the goal of tidymodels is also to standardize across various implementations to reduce friction when going from one model (implementation) to another so sometimes that means we deviate from the default of the engine implementation.

For random effects models, a second tidymodels principle kicks in: it deliberately constrains predictions for new data to not use the training set or other data (to prevent information leakage). Thus, tidymodels uses only the “population effects”, i.e., no-subject specific random effects.

See also: http://multilevelmod.tidymodels.org/articles/multilevelmod.html#linear-mixed-effects-via-lme https://parsnip.tidymodels.org/reference/details_linear_reg_lmer.html#predicting-new-samples

Jeffrothschild commented 1 year ago

Makes sense, thanks Hannah!

github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.