plot.mid | R Documentation |
For "mid" objects (i.e., fitted MID models), plot()
visualizes a single component function specified by the term
argument.
## S3 method for class 'mid'
plot(
x,
term,
type = c("effect", "data", "compound"),
theme = NULL,
intercept = FALSE,
main.effects = FALSE,
data = NULL,
limits = NULL,
jitter = 0.3,
resolution = c(100L, 100L),
...
)
x |
a "mid" object to be visualized. |
term |
a character string specifying the component function to be plotted. |
type |
the plotting style. One of "effect", "data" or "compound". |
theme |
a character string or object defining the color theme. See |
intercept |
logical. If |
main.effects |
logical. If |
data |
a data frame to be plotted with the corresponding MID values. If not provided, data is automatically extracted from the function call. |
limits |
a numeric vector of length two specifying the limits of the plotting scale. |
jitter |
a numeric value specifying the amount of jitter for the data points. |
resolution |
an integer or vector of two integers specifying the resolution of the raster plot for interactions. |
... |
optional parameters to be passed to the graphing function. Possible arguments are "col", "fill", "pch", "cex", "lty", "lwd" and aliases of them. |
This is an S3 method for the plot()
generic that produces a plot from a "mid" object, visualizing a component function of the fitted MID model.
The type
argument controls the visualization style.
The default, type = "effect"
, plots the component function itself.
In this style, the plotting method is automatically selected based on the effect's type:
a line plot for quantitative main effects; a bar plot for qualitative main effects; and a filled contour (level) plot for interactions.
The type = "data"
option creates a scatter plot of data
, colored by the values of the component function.
The type = "compound"
option combines both approaches, plotting the component function alongside the data points.
plot.mid()
produces a plot as a side-effect and returns NULL
invisibly.
interpret
, ggmid
data(diamonds, package = "ggplot2")
set.seed(42)
idx <- sample(nrow(diamonds), 1e4)
mid <- interpret(price ~ (carat + cut + color + clarity)^2, diamonds[idx, ])
# Plot a quantitative main effect
plot(mid, "carat")
# Plot a qualitative main effect
plot(mid, "clarity")
# Plot an interaction effect with data points and a raster layer
plot(mid, "carat:clarity", type = "compound", data = diamonds[idx, ])
# Use a different color theme
plot(mid, "clarity:color", theme = "RdBu")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.