I'm trying to run a multinomial logistic regression in R using tidymodels but I can't convert my results to a tidy object. Here's a sample using the iris data set.
# Multinomial -----------------------------------------------------------------
# recipe
multinom_recipe <-
recipe(Species ~ Sepal.Length + Sepal.Width + Sepal.Length + Petal.Width, data = iris) %>%
step_relevel(Species, ref_level = "setosa")
# model
multinom_model <- multinom_reg() %>%
set_engine("nnet")
# make workflow
multinom_wf <-
workflow() %>%
add_model(multinom_model) %>%
add_recipe(multinom_recipe) %>%
fit(data = iris) %>%
tidy()
multinom_wf
The last step throws the following error:
Error in eval(predvars, data, env) : object '..y' not found
I thought it was bc the output of the fit(data = iris)
is a workflow object, but this code seems to work fine when I don't use workflow
(which is the whole point of using tidymodels
) or if I fit a linear model.
# recipe
linear_recipe <-
recipe(Sepal.Length ~ Sepal.Width + Sepal.Length + Petal.Width, data = iris)
# model
linear_model <- linear_reg() %>%
set_engine("lm")
# make workflow
linear_wf <-
workflow() %>%
add_model(linear_model) %>%
add_recipe(linear_recipe) %>%
fit(data = iris) %>%
tidy()
linear_wf
Anyone have an idea as to what I'm missing or is this a bug?