| plot_discrim | R Documentation |
Discriminant analysis can be more easily understood from plots of the data variables showing how observations are classified.
plot_discrim() uses the ideas behind effect plots: Visualize predicted values for two focal variables over a
grid, with other variables in a model held fixed.
plot_discrim(
model,
vars,
data,
resolution = 100,
contour = TRUE,
contour.color = "black",
point.size = 3,
showgrid = c("tile", "point", "none"),
...,
modes.means
)
model |
a discriminant analysis model object from |
vars |
either a character vector of length 2 of the names of variables, or a formula of form V1 ~ V2 specifying y and x axis in the plot respectively. |
data |
data to use for visualization. Should contain all the data needed to use the model |
resolution |
number of points in x, y variables to use for visualizating the predicted class boundaries and regions. |
contour |
logical; should the plot display the boundaries of the classes by contours? |
contour.color |
color of the lines for the contour boundaries |
point.size |
size of the plot symbols use to show the data observations |
showgrid |
a character string; how to display predicted class regions: |
... |
further parameters passed to |
modes.means |
levels to use for evaluating predictions using the variables *not specified in |
In setting up this plot for ggplot2::ggplot(), this function maps color and shape of class-specific elements of the plot to the value of
the class variable in the discriminant analysis. But it simply uses the ggplot defaults...
Original code by Oliver on SO https://stackoverflow.com/questions/63782598/quadratic-discriminant-analysis-qda-plot-in-r. Generalized by Michael Friendly
klaR::partimat()
library(MASS)
library(ggplot2)
library(dplyr)
library(candisc)
iris.lda <- lda(Species ~ ., iris)
plot_discrim(iris.lda, Petal.Length ~ Petal.Width, data=iris, showgrid = "tile")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.