Calculates the Accumulated Local Effects (ALE) from a given data.frame, model, predictions, and covariate. This riffs on the ALEPlot function available in the ALEPlot package.

ALE_fn(X, X.model, pred.fun, J, K = 40, type = "response", multi = FALSE)

Arguments

X

the data.frame to get the covariate from

X.model

the name of the response variable

pred.fun

a function to calculate new predictions from the model

J

the column index of the covariate of interest

K

an integer value that determines the number of "windows" or breaks to calculate the model predictions over. More increase computational time but serves smooths the ALE predictions.

type

is either (response) or (prob) from predict.randomForest; if (prob) then n sets of predictions are returned for the n levels in var- if "response" then the factorized predicted response values are returned

multi

is a logical for either multivariate factor as the response variable (TRUE) or not (FALSE- the default)

Value

A list that contains:

  • K: the number of realized breaks

  • x.values: the break values trialed

  • class: the class of the covariate

  • quantile: the quantile of the breaks

  • fJ: the ALEs evaluated at a given x value