Closed EmilHvitfeldt closed 2 years ago
It looks like to me, that the only way to make an lmer model predict on new factor levels is to specify allow.new.levels = TRUE
in the predict()
call. However, this is not possible when calling predict()
on a Workflow object.
# This also works; see ?lme4::predict.merMod
predict(lmm_fit %>% extract_fit_engine(), newdata = mpg, allow.new.levels = TRUE)
predict(lmm_fit, new_data = mpg, allow.new.levels = TRUE)
#> Error: The ellipses are not used to pass args to the model function's predict function. These arguments cannot be used: `allow.new.levels`
I think my last message was wrong: I have just now seen that allow.new.levels = TRUE
is set by default in the definition of the make_lme4_linear_reg()
function, so I guess that it is not actually the source of the error.
closed in #41
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.
I found this problem in https://stackoverflow.com/questions/72349462/r-using-a-lmer-model-in-fit-resamples-fails-with-error-assigned-data-facto and condensed it further down, to this:
@hfrick: