Show Multiple Diagnostic Plots Simultaneously
Learn how to show multiple diagnostic plots simultaneously
We'll cover the following
How do we show multiple diagnostic plots simultaneously?
Often we are interested in showing multiple diagnostic plots together. There are two easy ways to do this. First, the lm()
function model output allows us to plot six diagnostic plots: (1) residuals-versus-fitted-values; (2) normal Quantile-Quantile plot; (3) Scale-Location plot of the square root of residuals against fitted values; (4) Cook’s D versus observation numbers; (5) residuals- versus-leverages; and (6) Cook’s D versus leverage divided by one minus leverage. The following R code produces a plot of six figures together. But the option which=
allows us to select which one to report.
par(mfrow = c(3, 2))
plot(model1, which = 1:6)
Second, we may use the GGally
and ggplot2
package to request a figure that combines pairwise correlation, variable distribution, and scatter plots through the ggscatmat()
function, as well as a diagnostic figure of all independent variables in a model versus four different diagnostic statistics (residuals, sigma, hat, cooksd).
Get hands-on with 1400+ tech skills courses.