## Not run:
# ## run a forest, then make a call to stat.split
# grow.obj <- rfsrc(mpg ~., data = mtcars, membership=TRUE, statistics=TRUE)
# stat.obj <- stat.split(grow.obj)
#
# ## nice wrapper to extract split-statistic for desired variable
# ## for continuous variables plots ECP data
# get.split <- function(splitObj, xvar, inches = 0.1, ...) {
# which.var <- which(names(splitObj[[1]]) == xvar)
# ntree <- length(splitObj)
# stat <- data.frame(do.call(rbind, sapply(1:ntree, function(b) {
# splitObj[[b]][which.var]})))
# dpth <- stat$dpthID
# ecp <- 1/2 - stat$spltEC
# sp <- stat$contPT
# if (!all(is.na(sp))) {
# fgC <- function(x) {
# as.numeric(as.character(cut(x, breaks = c(-1, 0.2, 0.35, 0.5),
# labels = c(1, 4, 2))))
# }
# symbols(jitter(sp), jitter(dpth), ecp, inches = inches, bg = fgC(ecp),
# xlab = xvar, ylab = "node depth", ...)
# legend("topleft", legend = c("low ecp", "med ecp", "high ecp"),
# fill = c(1, 4, 2))
# }
# invisible(stat)
# }
#
# ## use get.split to investigate ECP behavior of variables
# get.split(stat.obj, "disp")
# ## End(Not run)
Run the code above in your browser using DataLab