ggmid {midr} | R Documentation |
Plot MID with ggplot2 Package
Description
For "mid" objects, ggmid()
visualizes a MID component function using the ggplot2 package.
Usage
ggmid(object, ...)
## S3 method for class 'mid'
ggmid(
object,
term,
type = c("effect", "data", "compound"),
theme = NULL,
intercept = FALSE,
main.effects = FALSE,
data = NULL,
jitter = 0.3,
cells.count = c(100L, 100L),
limits = c(NA, NA),
...
)
## S3 method for class 'mid'
autoplot(object, ...)
Arguments
object |
a "mid" object to be visualized. |
... |
optional parameters to be passed to the main layer. |
term |
a character string specifying the component function to be plotted. |
type |
character string. The method for plotting the interaction effects. |
theme |
a character string specifying the color theme or any item that can be used to define "color.theme" object. |
intercept |
logical. If |
main.effects |
logical. If |
data |
a data.frame to be plotted with the corresponding MID values. If not passed, data is extracted from |
jitter |
a numeric value specifying the amount of jitter for points. |
cells.count |
an integer or integer-valued vector of length two, specifying the number of cells for the raster type interaction plot. |
limits |
|
Details
The S3 method of ggmid()
for "mid" objects creates a "ggplot" object that visualizes a MID component function.
The main layer is drawn using geom_line()
or geom_path()
for a main effect of a quantitative variable, geom_col()
for a main effect of a qualitative variable, and geom_raster()
or geom_rect()
for an interaction effect.
For other methods of ggmid()
, see help(ggmid.mid.importance)
, help(ggmid.mid.breakdown)
or help(ggmid.mid.conditional)
.
Value
ggmid.mid()
returns a "ggplot" object.
Examples
data(diamonds, package = "ggplot2")
set.seed(42)
idx <- sample(nrow(diamonds), 1e4)
mid <- interpret(price ~ (carat + cut + color + clarity)^2, diamonds[idx, ])
ggmid(mid, "carat")
ggmid(mid, "clarity")
ggmid(mid, "carat:clarity", main.effects = TRUE)
ggmid(mid, "clarity:color", type = "data", theme = "Mako", data = diamonds[idx, ])
ggmid(mid, "carat:color", type = "compound", data = diamonds[idx, ])