Closed ehrlinger closed 1 year ago
We no longer recommend using the plot.variable
function for custom partial plot calls. This is meant to be a user friendly helper function and actually is just a wrapper to the more advanced function partial.rfsrc
which provides a direct and fast interface to develop partial plots. This latter function should be used for custom calls as illustrated below for Boston Housing.
## boston housing regression example
library(mlbench)
data(BostonHousing)
## run the forest
o <- rfsrc(medv~., BostonHousing, nodesize=1)
## obtain partial effect for room using specified values
rm.pts <- c(3.561, 4.906, 5.093, 5.390, 5.456, 5.572, 5.613, 5.682, 5.713, 5.783)
partial.obj <- partial(o,
partial.xvar = "rm",
partial.values = rm.pts)
pdta <- get.partial.plot.data(partial.obj)
## plot partial values
plot(pdta$x, pdta$yhat, type = "b", pch = 16,
xlab = "room", ylab = "partial effect of room")
Using the current CRAN release (R 4.2.1, randomForestSRC 3.1.1), I have a set of pts (rm_pts) that I want to manipulate and call the plot.variable function. Previously, I could edit the xvar data.frame within the rfsrc object to generate a partial plot with a single value and loop over the values of interest. This no longer works.
This is reported in the ggRandomForest issue https://github.com/ehrlinger/ggRandomForests/issues/42 which is demonstrated in the vignette/ggrfRegression.Rmd partial coplots. Both the contour and surface plots are built using the same partial plot curves for all input values that we are submitting.