title: How to compute importance from a LM using Tidymodels in R?
body: <p>I am trying to compute variable importance on a linear model using <code>tidymodels</code>. As far as I can tell, the <code>vip</code> package is used to extract the importance when using <code>tidymodels</code>. For example, If I wanted to extract importance from a random forest <code>tidymodels</code> model, I would do the following:</p>
  <pre><code>library(tidymodels)
  
  aq &lt;- na.omit(airquality)
  
  model_rf &lt;-
    rand_forest(
      mode = &quot;regression&quot;
    ) %&gt;%
    set_engine(&quot;ranger&quot;,
               importance = &quot;permutation&quot;
    ) %&gt;%
    fit(Ozone ~ ., data = aq)
  
  # variable importance
  vip:::vi(model_rf)
  </code></pre>
  <p>And this will return the importance. However, if I try something similar using a linear model, it throws back an error. For example:</p>
  <pre><code># create model fit
  lm_aq_model &lt;- linear_reg() %&gt;%
    set_engine(&quot;lm&quot;)
  
  lm_fit &lt;- lm_aq_model %&gt;%
    fit(Ozone ~ ., data = aq)
  
  
  vip:::vi(lm_aq_model, method = &quot;permute&quot;, target = &quot;Ozone&quot;,
      metric = &quot;rsquared&quot;,  pred_wrapper = predict)
  &gt; Error in match.call(f, call = mcall) : invalid 'call' argument
  </code></pre>
  <p>What am I doing wrong here? If I try:</p>
  <pre><code>aqLM &lt;- lm(Ozone~., data = aq)
  vip::vi(aqLM, method = &quot;permute&quot;, target = &quot;Ozone&quot;,
      metric = &quot;rsquared&quot;,  pred_wrapper = predict)
  </code></pre>
  <p>This works... why cant I get it to work with <code>tidymodels</code>?</p>
  <p>Also, is this the preferred way to actually extract importance when using <code>tidymodels</code>? Is there a generic tidy models function that I could use instead of using <code>vip::vi(model_fit)</code>?</p>
  <p>Thanks</p>