How can I create a Partial Dependence plot for a categorical variable in R?

Viewed 6650

I am working with the r-package randomForest and have successfully made a random forest model and an importance plot. I am working with a dichotomous response and several categorical predictors.

However, I can't figure out how to make partial dependence plots for my categorical variables. I have tried using the randomForest command partialPLot. But I get the following error:

> partialPlot(rf.5, rf.train.1, religion)
Error in is.finite(x) : default method not implemented for type 'list'

.

So my question is: Can anyone explain in a simple way how you would make a random forest partial dependence plot for a categorical variable?

This is the kind of plot I want to make: https://stats.stackexchange.com/questions/235667/partial-dependence-plot-interpretation-for-categorical-variables

Would really appreciate some help on this. Thanks!

2 Answers
Related