Skip to contents

For "mid" objects, plot() visualizes a MID component function.

Usage

# S3 method for class 'mid'
plot(
  x,
  term,
  type = c("effect", "data", "compound"),
  theme = NULL,
  intercept = FALSE,
  main.effects = FALSE,
  data = NULL,
  jitter = 0.3,
  cells.count = c(100L, 100L),
  limits = NULL,
  ...
)

Arguments

x

a "mid" object to be visualized.

term

a character string specifying the component function to be plotted.

type

character string.

theme

a character vector of color names or a character string specifying the color theme.

intercept

logical. If TRUE, the intercept is added to the MID values and the plotting scale is shifted.

main.effects

logical. If TRUE, the main effects are included in the interaction plot.

data

a data.frame to be plotted with the corresponding MID values. If not passed, data is extracted from parent.env() based on the function call of the "mid" object.

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

NULL or a numeric vector of length two specifying the limits of the plotting scale. NAs are replaced by the minimum and/or maximum MID values.

...

optional parameters to be passed to the graphing function. Possible arguments are "col", "fill", "pch", "cex", "lty", "lwd" and aliases of them.

Value

plot.mid() produces a line plot or bar plot for a main effect and a filled contour plot for an interaction and returns NULL.

Details

The S3 method of plot() for "mid" objects creates a visualization of a MID component function using the functions of the graphics package.

Examples

data(diamonds, package = "ggplot2")
set.seed(42)
idx <- sample(nrow(diamonds), 1e4)
mid <- interpret(price ~ (carat + cut + color + clarity)^2, diamonds[idx, ])
#> 'model' not passed: response variable in 'data' is used
plot(mid, "carat")

plot(mid, "clarity")

plot(mid, "carat:clarity", main.effects = TRUE)

plot(mid, "clarity:color", type = "data", theme = "Mako", data = diamonds[idx, ])

plot(mid, "carat:color", type = "compound", data = diamonds[idx, ])