plotPartialEffs: Partial effects plots for any model type, based on the...

Description Usage Arguments Details

View source: R/PartialPlots.r

Description

Note: in randomForest::partialPlot, they scale classificiation probabilities to the log scale, and set any prob of 0 equal to .Machine$double.eps prior to logging. Subjective choice of what to assign to a prob of 0 will effect the shape of the resulting partial effect plot, so results form randomForest::partialPlot should be interpreted cautiously for datasets where classification probabilities contain a substantial number of estimated 0 values. The approach used here is to plot whatever is passed through the predFnx, so if pass probabilities, it'll show the partial effect on the probability scale directly.

Usage

1
2
plotPartialEffs(mod, dat, predFnx, colNms, type = "all", dWeights = rep(1,
  dim(dat)[1]), CIOn = FALSE, totPerPage = 12, pdfFile = NULL)

Arguments

mod

model object

dat

the dataset (or sample dataset) to get median values (type='median') or make predictions directly on (type='all')

predFnx

a prediction function with arguments 'function(mod, newdata)' - must return numeric values. If CIOn=TRUE, column names for returned data.frame should be [colNm]_lower and [colNm]_upper, e.g., c('pred', 'pred_low', 'pred_high').

colNms

names of the predictors to get the values from

type

prediction dataset for each variable value: median=use median/most common value for covariates; all=use full datasaet for covariates

CIOn

whether or not to plot confidence bounds, if so assumes that predFnx passes this in

totPerPage

Total number of figures per page (default=9)

pdfFile

The file path/name to save to.

colNms

names of the predictors to get the values from

Details

Here the key is to pass an approriate user-defined predFnx, where the function must return a data frame: a single column for single-value response (e.g., regression), a single column for binary classification, or multiple columns for multiclass classification. If only certain classes are desired from multiclass classification, just have the predFnx return columns for those predicted probabilities.


wtcooper/vizrd documentation built on May 4, 2019, noon