resid_hist_qq: Plot residual histograms and Q-Q plots.

Description Usage Arguments Value See Also Examples

View source: R/resids.R

Description

Plot histograms and Q-Q plots of model residuals to assess residual normality.

Usage

1
2
3
4
resid_hist_qq(model, plot_type = "both", resid_type = "std", bins = 9,
  qqline = TRUE, htitle = "Histogram", qtitle = "Normal Q-Q Plot",
  subtitle = TRUE, hxlab = "Residuals", qxlab = "Theoretical Quantiles",
  hylab = "Count", qylab = "Sample Quantiles", ...)

Arguments

model

An lm or aov model object.

plot_type

A string indicating which type of plot to produce. The default "both" produces both histograms and Q-Q plots side by side, "hist" produces only histograms, and "qq" produces only Q-Q plots.

resid_type

A string indicating which type of residuals to use. The default "std" uses standardized residuals, "unstd" uses unstandardized residuals, and "both" produces both plots stacked with "unstd" on top and "std" on the bottom.

bins

How many bins to use for the histograms.

qqline

A logical indicating whether to include a qqline on the Q-Q plots.

htitle

A string indicating what to title the histograms.

qtitle

A string indicating what to title the Q-Q plots.

hxlab

A string indicating what to title the histogram x-axes.

qxlab

A string indicating what to title the Q-Q plot x-axes.

hylab

A string indicating what to title the histogram y-axes.

qylab

A string indicating what to title the Q-Q plot y-axes.

...

Additional arguments passed to ggplot2::theme().

subittle

A logical indicating whether to include the default subtitles.

Value

If single plot_ and resid_ types are specified (i.e., a single histogram or Q-Q plot is requested), a ggplot2 plot object is returned. If more than one plot is requested, a call to gridExtra::grid.arrange draws on the current device and a gtable is returned.

See Also

resid_fitted_plot for residual vs. fitted values plots.

Examples

1
2
3
4
mtcars_lm <- lm(mpg ~ wt, mtcars)
resid_hist_qq(mtcars_lm)
resid_hist_qq(mtcars_lm, plot_type = "qq", resid_type = "unstd")
resid_hist_qq(mtcars_lm, resid_type = "both")

ricompute/llusmstats documentation built on May 24, 2019, 6:18 a.m.