resid_fitted_plot: Plot residuals vs. fitted values.

Description Usage Arguments Value See Also Examples

View source: R/resids.R

Description

Plot model residuals vs. fitted values with ggplot2 to assess a model fit.

Usage

1
2
3
resid_fitted_plot(model, resid_type = "std", outlier_2sd_lines = TRUE,
  title = "Residuals vs. Fitted Values", subtitle = TRUE,
  xlab = "Fitted Values", ylab = "Residuals", ...)

Arguments

model

An lm or aov model object.

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.

outlier_2sd_lines

A logical indicating whether to draw horizontal red lines on the standardized residual plot at a y-value of +/- 2.

title

A string indicating what to title the plot.

subtitle

A logical indicating whether to include the default subtitle.

xlab

A string indicating what to label the x-axis.

ylab

A string indicating what to label the y-axis.

...

Additional arguments passed to ggplot2::theme().

Value

If a single plot type ("std" or "unstd") is specified, a ggplot2 plot object is returned. If "both" plot types are requested, a call to gridExtra::grid.arrange draws on the current device and a gtable is returned.

See Also

resid_hist_qq for residual histograms and Q-Q plots.

Examples

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

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