diagnostic_plot | R Documentation |
These are short-hand functions to quickly draw diagnostic parades.
lin_plot()
plots the models' residuals against (by default) their corresponding fitted values.
The residuals can also be plotted against a specific predictor if the predictor
parameter is set.
This function is useful for checking the linearity assumption.
var_plot()
plots the models' absolute residuals against (by default)
their corresponding fitted values if it is fed an object generated using parade()
.
The absolute residuals can also be plotted against a specific predictor if the predictor
argument
is set. If it is fed an object generated using parade_summary()
,
it plots the sample standard deviation of the residuals per cell.
This function is useful for checking the constant-variance assumption.
norm_qq()
and norm_hist()
plot normal quantile-quantile plots and histograms of the
models' residuals, respectively. This function is useful for checking the normality assumption.
lin_plot(parade, predictor = NULL, rank = FALSE)
var_plot(parade, predictor = NULL, rank = FALSE)
norm_qq(parade)
norm_hist(parade, bins = 30)
parade |
The name of an object generated using |
predictor |
The name of a variable in the parade object against which the residuals should be plotted. If this parameter isn't specified (default), the residuals will be plotted against their respective fitted values. |
rank |
Should the values along the x-axis be converted to ranks ( |
bins |
How many bins should the histograms contain? Defaults to 30. |
# A simple regression model
m <- lm(mpg ~ disp, data = mtcars)
# Generate parade and check linearity
my_parade <- parade(m)
lin_plot(my_parade)
reveal(my_parade)
# Regenerate parade and check constant variance
my_parade <- parade(m)
var_plot(my_parade)
reveal(my_parade)
# Regenerate parade and check normality
my_parade <- parade(m)
norm_qq(my_parade)
norm_hist(my_parade)
norm_hist(my_parade, bins = 10)
reveal(my_parade)
# Example with gam
library(mgcv)
m.gam <- gam(mpg ~ s(disp) + wt + s(qsec, by = am), data = mtcars)
my_parade <- parade(m.gam)
lin_plot(my_parade)
lin_plot(my_parade, predictor = "wt")
lin_plot(my_parade, predictor = "qsec")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.