Title: | Grammar of Graphics for Linear Model Diagnostic Plots |
---|---|
Description: | Allows for easy creation of diagnostic plots for a variety of model objects using the Grammar of Graphics. Provides functionality for both individual diagnostic plots and an array of four standard diagnostic plots. |
Authors: | Grayson White [aut, cre] |
Maintainer: | Grayson White <[email protected]> |
License: | CC0 |
Version: | 1.0.3.9000 |
Built: | 2025-03-12 04:01:36 UTC |
Source: | https://github.com/graysonwhite/gglm |
Provides four standard visual model diagnostic plots with 'ggplot2'.
gglm(data, theme = ggplot2::theme_gray(), ...)
gglm(data, theme = ggplot2::theme_gray(), ...)
data |
A model object of type 'lm' or 'glm'. |
theme |
The theme of the 'ggplot's to be produced. |
... |
Currently ignored. For extendability. |
A a 'ggplot2' object for visual diagnostic of model validity.
data(mtcars) m1 <- lm(mpg ~ cyl + disp + hp, data = mtcars) gglm(m1)
data(mtcars) m1 <- lm(mpg ~ cyl + disp + hp, data = mtcars) gglm(m1)
Returns the possible model classes that 'gglm' works with.
list_model_classes(...)
list_model_classes(...)
... |
Currently ignored. For extendability. |
A character vector containing the possible model classes that 'gglm' works with.
Note that these are not always the exact name of the class that that can be used. This is due to how some methods are written in the packages 'gglm' imports. For example, the model class "merMod" refers to a variety of model outputs from 'lme4', even when the outputted class is not called "merMod".
list_model_classes()
list_model_classes()
Cook's Distance vs. Leverage
stat_cooks_leverage( alpha = 0.5, method = "loess", color = "steelblue", se = FALSE, ... )
stat_cooks_leverage( alpha = 0.5, method = "loess", color = "steelblue", se = FALSE, ... )
alpha |
Adjust transparency of points. |
method |
Method for fitting the line to the points. |
color |
Color of the line. |
se |
Keep standard error bands around line? |
... |
Currently ignored. For extendability. |
A ‘ggplot2' layer for plotting Cook’s Distance vs. Leverage.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_cooks_leverage()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_cooks_leverage()
‘ggplot2' layer for plotting cook’s distance by observation number.
stat_cooks_obs(...)
stat_cooks_obs(...)
... |
Currently ignored. For extendability. |
A ‘ggplot2' layer for plotting cook’s distance by observation number.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_cooks_obs()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_cooks_obs()
'ggplot2' layer for plotting a fitted vs. residual scatter plot.
stat_fitted_resid(alpha = 0.5, ...)
stat_fitted_resid(alpha = 0.5, ...)
alpha |
Adjust transparency of points. |
... |
Currently ignored. For extendability. |
A 'ggplot2' layer for plotting a fitted vs. residual scatter plot.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_fitted_resid()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_fitted_resid()
Normal QQ plot.
stat_normal_qq(alpha = 0.5, ...)
stat_normal_qq(alpha = 0.5, ...)
alpha |
Adjust transparency of points. |
... |
Currently ignored. For extendability. |
A 'ggplot2' layer for plotting a Normal Q-Q plot.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_normal_qq()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_normal_qq()
Visualize the distribution of the residuals of a model.
stat_resid_hist(bins = 30, ...)
stat_resid_hist(bins = 30, ...)
bins |
Adjust the number of bins. |
... |
Currently ignored. For extendability. |
A 'ggplot2' layer for plotting a histogram of residuals.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_resid_hist()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_resid_hist()
Residual vs. leverage plot.
stat_resid_leverage( alpha = 0.5, method = "loess", se = FALSE, color = "steelblue", ... )
stat_resid_leverage( alpha = 0.5, method = "loess", se = FALSE, color = "steelblue", ... )
alpha |
Adjust transparency of points. |
method |
Method for fitting the line to the points. |
se |
Keep standard error bands around line? |
color |
Color of the line. |
... |
Currently ignored. For extendability. |
A 'ggplot2' layer for plotting a fitted vs. residual scatter plot.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_resid_leverage()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_resid_leverage()
Scale location diagnostic plot.
stat_scale_location( alpha = 0.5, na.rm = TRUE, se = FALSE, method = "loess", color = "steelblue", ... )
stat_scale_location( alpha = 0.5, na.rm = TRUE, se = FALSE, method = "loess", color = "steelblue", ... )
alpha |
Adjust the transparency of points. |
na.rm |
Remove points with value NA? |
se |
Keep standard error bands around line? |
method |
Method for fitting the line to the points. |
color |
Color of the line. |
... |
Currently ignored. For extendability. |
A 'ggplot2' layer for plotting the scale location diagnostic plot.
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_scale_location()
data(mtcars) model <- lm(mpg ~ cyl + disp + hp, data = mtcars) ggplot2::ggplot(data = model) + stat_scale_location()