light_ice | R Documentation |
Generates Individual Conditional Expectation (ICE) profiles. An ICE profile shows how the prediction of an observation changes if one or multiple variables are systematically changed across its ranges, holding all other values fixed (see the reference below for details). The curves can be centered in order to increase visibility of interaction effects.
light_ice(x, ...)
## Default S3 method:
light_ice(x, ...)
## S3 method for class 'flashlight'
light_ice(
x,
v = NULL,
data = x$data,
by = x$by,
evaluate_at = NULL,
breaks = NULL,
grid = NULL,
n_bins = 27L,
cut_type = c("equal", "quantile"),
indices = NULL,
n_max = 20L,
seed = NULL,
use_linkinv = TRUE,
center = c("no", "first", "middle", "last", "mean", "0"),
...
)
## S3 method for class 'multiflashlight'
light_ice(x, ...)
x |
An object of class "flashlight" or "multiflashlight". |
... |
Further arguments passed to or from other methods. |
v |
The variable name to be profiled. |
data |
An optional |
by |
An optional vector of column names used to additionally group the results. |
evaluate_at |
Vector with values of |
breaks |
Cut breaks for a numeric |
grid |
A |
n_bins |
Approximate number of unique values to evaluate for numeric |
cut_type |
Should a numeric |
indices |
A vector of row numbers to consider. |
n_max |
If |
seed |
An integer random seed. |
use_linkinv |
Should retransformation function be applied? Default is |
center |
How should curves be centered?
|
There are two ways to specify the variable(s) to be profiled.
Pass the variable name via v
and an optional vector with evaluation points
evaluate_at
(or breaks
). This works for dependence on a single variable.
More general: Specify any grid
as a data.frame
with one or
more columns. For instance, it can be generated by a call to expand.grid()
.
The minimum required elements in the (multi-)flashlight are "predict_function", "model", "linkinv" and "data", where the latest can be passed on the fly.
Which rows in data
are profiled? This is specified by indices
.
If not given and n_max
is smaller than the number of rows in data
,
then row indices will be sampled randomly from data
.
If the same rows should be used for all flashlights in a multiflashlight,
there are two options: Either pass a seed
or a vector of indices used to select rows.
In both cases, data
should be the same for all flashlights considered.
An object of class "light_ice" with the following elements:
data
A tibble containing the results. Can be used to build fully customized
visualizations. Column names can be controlled by options(flashlight.column_name)
.
by
Same as input by
.
v
The variable(s) evaluated.
center
How centering was done.
light_ice(default)
: Default method not implemented yet.
light_ice(flashlight)
: ICE profiles for a flashlight object.
light_ice(multiflashlight)
: ICE profiles for a multiflashlight object.
Goldstein, A. et al. (2015). Peeking inside the black box: Visualizing statistical learning with plots of individual conditional expectation. Journal of Computational and Graphical Statistics, 24:1 <doi.org/10.1080/10618600.2014.907095>.
light_profile()
, plot.light_ice()
fit <- lm(Sepal.Length ~ ., data = iris)
fl <- flashlight(model = fit, label = "lm", data = iris)
light_ice(fl, v = "Species")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.