plot.mid.conditional {midr} | R Documentation |
Plot ICE of MID Model with graphics Package
Description
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 |
var.color |
a name of the variable or an expression to be used to set |
var.linetype |
a name of the variable or an expression to be used to set |
var.linewidth |
a name of the variable or an expression to be used to set |
reference |
an integer specifying the index of the sample points to be used as reference point for the centered ICE plot. Default is |
dots |
logical. If |
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. |
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.
Value
plot.mid.conditional()
produces an ICE plot and invisibly returns the ICE matrix used for the plot.
Examples
data(airquality, package = "datasets")
library(midr)
mid <- interpret(Ozone ~ .^2, airquality, lambda = 0.1)
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)