Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot.dice

Create a plot of a dice object.


Description

Plotting of dice objects.

Usage

## S3 method for class 'dice'
plot(x, plot_margin = 0.05, frac_to_plot = 1, 
      plot_sd = TRUE, plot_orig_pts_deriv = TRUE, pts_preds_size = 1.5, 
      colorvec, color_by = NULL, x_quantile = FALSE, plot_dpdp = TRUE, 
      rug_quantile = seq(from = 0, to = 1, by = 0.1), ...)

Arguments

x

Object of class dice to plot.

plot_margin

Extra margin to pass to ylim as a fraction of the range of x$d_ice_curves.

frac_to_plot

If frac_to_plot is less than 1, randomly plot frac_to_plot fraction of the curves in x$d_ice_curves.

plot_sd

If TRUE, plot the cross-observation sd of partial derivatives below the derivative plots.

plot_orig_pts_deriv

If TRUE, marks each curve at the location of the derivative estimate at the location of predictor actually occurring in the data. If FALSE no mark is drawn.

pts_preds_size

Size of points to make if plot_orig_pts_deriv is TRUE.

colorvec

Optional vector of colors to use for each curve.

color_by

Optional variable name (or column number) in Xice to color curves by. If the color_by variable has 10 or fewer unique values, a discrete set of colors is used for each value and a legend is printed and returned. If there are more values, curves are colored from light to dark corresponding to low to high values of the variable specified by color_by.

x_quantile

If TRUE, the plot is drawn with the x-axis taken to be quantile(gridpts). If FALSE, the predictor's original scale is used.

plot_dpdp

If TRUE, the estimated derivative of the PDP is plotted and highlighted in yellow.

rug_quantile

If not null, tick marks are drawn on the x-axis corresponding to the vector of quantiles specified by this parameter. Forced to NULL when x_quantile is set to TRUE.

...

Additional plotting arguments.

Value

A list with the following elements.

plot_points_indices

Row numbers of Xice of those observations presented in the plot.

legend_text

If the color_by argument was used, a legend describing the map between the color_by predictor and curve colors.

See Also

dice

Examples

## Not run: 
require(ICEbox)
require(randomForest)
require(MASS) #has Boston Housing data, Pima

data(Boston) #Boston Housing data
X = Boston
y = X$medv
X$medv = NULL

## build a RF:
bhd_rf_mod = randomForest(X, y)

## Create an 'ice' object for the predictor "age":
bhd.ice = ice(object = bhd_rf_mod, X = X, y = y, predictor = "age", frac_to_build = .1) 

# estimate derivatives, then plot.
bhd.dice = dice(bhd.ice)
plot(bhd.dice)

## End(Not run)

ICEbox

Individual Conditional Expectation Plot Toolbox

v1.1.2
GPL-2 | GPL-3
Authors
Alex Goldstein, Adam Kapelner, Justin Bleich
Initial release
2017-07-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.