ggmid.mid.conditional {midr} | R Documentation |
Plot ICE of MID Model with ggplot2 Package
Description
For "mid.conditional" objects, ggmid()
visualizes ICE curves of a MID model.
Usage
## S3 method for class 'mid.conditional'
ggmid(
object,
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,
...
)
## S3 method for class 'mid.conditional'
autoplot(object, ...)
Arguments
object |
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 an interaction term. If passed, the ICE curve 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 main layer. |
Details
The S3 method of ggmid()
for "mid.conditional" objects creates a "ggplot" object that visualizes ICE curves of a fitted MID model using geom_line()
.
Value
ggmid.mid.conditional()
returns a "ggplot" object.
Examples
data(airquality, package = "datasets")
library(midr)
mid <- interpret(Ozone ~ .^2, airquality, lambda = 0.1)
ice <- mid.conditional(mid, "Temp", data = airquality)
ggmid(ice, var.color = "Wind")
ggmid(ice, type = "centered", theme = "Purple-Yellow",
var.color = factor(Month), var.linetype = Wind > 10)