plot.EffectData | R Documentation |
Versatile plot function for an "EffectData" object. By default, all calculated
statistics (except "resid_mean") are shown. To select certain statistics,
use the stats
argument. Set plotly = TRUE
for interactive plots. Note that
all statistics are plotted at bin means, except for ALE
(shown at right bin breaks).
## S3 method for class 'EffectData'
plot(
x,
stats = NULL,
ncol = grDevices::n2mfrow(length(x))[2L],
byrow = TRUE,
share_y = c("no", "all", "rows", "cols"),
ylim = NULL,
discrete_lines = TRUE,
continuous_points = FALSE,
title = "",
subplot_titles = TRUE,
ylab = NULL,
legend_labels = NULL,
interval = c("no", "ci", "ciw", "sd"),
ci_level = 0.95,
colors = getOption("effectplots.colors"),
fill = getOption("effectplots.fill"),
alpha = 1,
bar_height = 1,
bar_width = 1,
bar_measure = c("weight", "N"),
wrap_x = 10,
rotate_x = 0,
plotly = getOption("effectplots.plotly"),
...
)
x |
An object of class "EffectData". |
stats |
Vector of statistics to show. The default |
ncol |
Number of columns of the plot layout, by default
|
byrow |
Should plots be placed by row? Default is |
share_y |
Should y axis be shared across subplots? The default is "no".
Other choices are "all", "rows", and "cols". Note that this currently does not
take into account error bars/ribbons.
Has no effect if |
ylim |
A vector of length 2 with manual y axis limits, or a list thereof. |
discrete_lines |
Show lines for discrete features. Default is |
continuous_points |
Show points for continuous features. Default is |
title |
Overall plot title, by default |
subplot_titles |
Should variable names be shown as subplot titles?
Default is |
ylab |
Label of the y axis. The default |
legend_labels |
Vector of legend labels in the same order as the
statistics plotted, or |
interval |
What intervals should be shown for observed y and residuals? One of
|
ci_level |
The nominal level of the Z confidence intervals (only when
|
colors |
Vector of line/point colors of sufficient length.
By default, a color blind friendly palette from "ggthemes".
To change globally, set |
fill |
Fill color of bars. The default equals "lightgrey".
To change globally, set |
alpha |
Alpha transparency of lines and points. Default is 1. |
bar_height |
Relative bar height (default 1). Set to 0 for no bars. |
bar_width |
Bar width multiplier (for discrete features). By default 1. |
bar_measure |
What should bars represent? Either "weight" (default) or "N". |
wrap_x |
Should categorical x axis labels be wrapped after this length?
The default is 10. Set to 0 for no wrapping. Vectorized over |
rotate_x |
Should categorical xaxis labels be rotated by this angle?
The default is 0 (no rotation). Vectorized over |
plotly |
Should 'plotly' be used? The default is |
... |
Passed to |
If a single plot, an object of class "ggplot" or "plotly". Otherwise, an object of class "patchwork", or a "plotly" subplot.
feature_effects()
, average_observed()
, average_predicted()
,
partial_dependence()
, bias()
, ale()
fit <- lm(Sepal.Length ~ ., data = iris)
xvars <- colnames(iris)[-1]
M <- feature_effects(fit, v = xvars, data = iris, y = "Sepal.Length", breaks = 5)
plot(M, share_y = "all")
plot(M, stats = c("pd", "ale"), legend_labels = c("PD", "ALE"))
plot(M, stats = "resid_mean", share_y = "all", interval = "ci")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.