How can I fit a model using this tidymodels
workflow?
library(tidymodels)
workflow() %>%
add_model(linear_reg() %>% set_engine("lm")) %>%
add_formula(mpg ~ 0 + cyl + wt) %>%
fit(mtcars)
#> Error: `formula` must not contain the intercept removal term: `+ 0` or `0 +`.
You can use the
formula
argument toadd_model()
to override the terms of the model. This is typically used for survival and Bayesian models, so be extra careful that you know what you are doing here, because you are circumventing some of the guardrails of tidymodels by doing this:Created on 2021-09-01 by the reprex package (v2.0.1)