Most package authors design functions to take in the traditional R model objects like is there anyway to feed them a model object created by parsnip package and tidymodels?
an example:
model <- lm(mpg ~ am + cyl + wt + hp, data = mtcars)
car::avPlots(model, terms = . ~ am + cyl + wt + hp)
but if you create the model through tidymodels it won't work since the output object is different#fit_ex5_1 <-
model_pars <-
linear_reg() %>%
set_engine("lm") %>%
fit(mpg ~ am + cyl + wt + hp, data = mtcar)
#this doesn't work:
car::avPlots(model_pars, terms = . ~ am + cyl + wt + hp)
I imagine there may be various methods depending on the type of model. In the case of
lm()you can extractparsnip_model$fit, which is an object of classlm, like the output oflm():Note: I did not include the
termsargument to thecar::avPlots()call as the plot includes all the terms by default, but the code runs if you include them.