Error in varimp() function of party package in R with conditional=TRUE

I am running a random forest model with cforest function, as you can see the below is result of the model that runs fine. After this, I ran the varimp() function setting default conditional= FALSE which runs, however when I try to run the same function with parameter conditional =TRUE. I am getting the following error:

> caret:::cforestStats(RF1)
      RMSE   Rsquared        MAE 
19.0656593  0.2217984 15.7459980 
> RF1.coef <- varimp(RF1, conditional = TRUE, threshold = .3)
Error in terms.formula(formula, data = data) : 
  invalid model formula in ExtractVars

Please suggest what can I do to fix this issue.

caret (and parsnip) may have used an internal formula when calling cforest(). This depends on how you called it (so a reprex would help).

For some models, they expect the formula and data in the call to be available in the same environment as the one that you called varimp().

In this case, you might need to do one more model fit using the optimized parameters from caret and call cforest() directly on the training set.

Thank you Max, for the suggestion. I was able to figure out the issue. It was mainly with the way some variables were named "Cas-45". I replace all "-" with "_" and the issue was resolved.

However it makes me wonder, why the same function worked with those same variables without having any issue when the conditional parameter was set to False and it did not worked when it was set to True.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.