gglm, The Grammar of Graphics for Linear Model Diagnostics, is an R package and official
ggplot2 extension that creates beautiful
ggplot2 diagonostic plots for linear models that are easy to use and adhere to The Grammar of Graphics. The purpose of this package is to provide a sensible alternative to using the base-R
plot() function to produce diagnostic plots for linear models.
You can now install
gglm from CRAN, do so with this code:
Or, you can install the developmental version from GitHub:
gglm has two main types of functions. First, the
gglm() function for quickly creating the four main diagnostic plots, similar to when you call
plot() on an
lm type object. Second, the
stat_*() functions, which produce diagnostic plots the align with The Grammar of Graphics by creating
ggplot2 layers that allow for easy plotting of particular model diagnostic plots.
# We can also add layers such as themes to these `ggplot`s and adjust features of the plot: ggplot(data = model) + stat_cooks_leverage(alpha = 1) + theme_minimal()