Type 3 Anova on parsnip models

33 Views Asked by At

Lets say I create an lm model with 2 predictors at least one which is categorical and there is also an interaction term involved. Now I would like to also get the significance level for the overall interaction term. for this I would simply use a type 3 Anova in this example I want to get the significance level for Petal.Length:Species

lm(Sepal.Length ~ Petal.Length + Species + Petal.Length:Species, data = iris) %>% 
  car::Anova(type = 3)

However, this approach doesn't seem to work for parsnip models:

rec <- 
  recipe(Sepal.Length ~ Petal.Length + Species, data = iris) %>% 
  step_interact(terms = ~ Species:Petal.Length)

lm_spec <- 
  linear_reg() %>% 
  set_engine("lm")

wf_2p_int <- 
  workflow() %>% 
  add_recipe(rec) %>% 
  add_model(lm_spec) %>% 
  fit(iris)

wf_2p_int %>% 
  extract_fit_engine() %>%  
  car::Anova(type = 3)

Is there any straight-forward way to get the same results for models created via the tidymodels approach?

0

There are 0 best solutions below