Skip to contents

For "mid.conditional" objects, plot() visualizes ICE curves of a MID model.

Usage

# S3 method for class 'mid.conditional'
plot(
  x,
  type = c("iceplot", "centered"),
  theme = NULL,
  term = NULL,
  var.alpha = NULL,
  var.color = NULL,
  var.linetype = NULL,
  var.linewidth = NULL,
  reference = 1L,
  dots = TRUE,
  sample = NULL,
  ...
)

Arguments

x

a "mid.conditional" object to be visualized.

type

a character string specifying the type of the plot. One of "iceplot" or "centered". If "centered", the ICE values of each observation are set to zero at the leftmost point of the varriable.

theme

a character string specifying the color theme or any item that can be used to define "color.theme" object.

term

an optional character string specifying the interaction term. If passed, the ICE for the specified term is plotted.

var.alpha

a name of the variable or an expression to be used to set alpha.

var.color

a name of the variable or an expression to be used to set colour.

var.linetype

a name of the variable or an expression to be used to set linetype.

var.linewidth

a name of the variable or an expression to be used to set linewidth.

reference

an integer specifying the index of the sample points to be used as reference point for the centered ICE plot. Default is 1. If negative, the maximum value of the variable is used.

dots

logical. If TRUE, the points representing the predictions for each observation are plotted.

sample

an optional vector specifying the names of observations to be plotted.

...

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.conditional() produces an ICE plot and invisibly returns the ICE matrix used for the plot.

Details

The S3 method of plot() for "mid.conditional" objects creates an visualization of ICE curves of a fitted MID model using the functions of the graphics package.

Examples

data(airquality, package = "datasets")
library(midr)
mid <- interpret(Ozone ~ .^2, airquality, lambda = 0.1)
#> 'model' not passed: response variable in 'data' is used
ice <- mid.conditional(mid, "Temp", data = airquality)
plot(ice, var.color = "Wind")

plot(ice, type = "centered", theme = "Purple-Yellow",
     var.color = factor(Month), var.linetype = Wind > 10)