plot4in1: Plot 4-in-1

Description Usage Arguments Details Value See Also Examples

View source: R/plot4in1.R

Description

Generates a 2x2 panel graph including four residual diagnostic plots as is popular in some other statistics packages. This was initially written to support students learning R for the first time in a regression modeling course. plot4in1 generates four commonly-used residual diagnostic plots that can be used to assess the linear regression assumptions and ensures a consistent, reasonably-pleasing graphical style across each plot.

Usage

1
2
3
4
5
6
7
8
9
plot4in1(
  out,
  type = "Regular",
  PP = TRUE,
  pch = 19,
  col = "steelblue",
  cex = 1.2,
  ...
)

Arguments

out

the output of the lm function (an object of class "lm"). The components of greatest importance from this object are residuals (perhaps passed to rstandard of rstudent, depending on type) and fitted.values.

type

the type of residuals to be used. There are three possible values: "Regular", "Standardized", and "Studentized". Using type = "Regular" results in untransformed residuals being used, type = "Standardized" uses standardized residuals (computed using rstandard), and type = "Studentized" uses externally studentized residuals (computed using rstudent).

PP

logical. If PP = TRUE, a Normal Percentile Plot (P-P Plot) is displayed in the top-left panel. If PP = FALSE, a Normal Quantile Plot (Q-Q Plot) is displayed in the top-left panel.

pch

symbol to be used in plotting. pch = 19 is a filled circle (see par).

col

color of symbol specified in pch to be used in graphing. The default is "steelblue" (see par).

cex

character expansion value, used to adjust the size of the symbol specified in pch. The default value is cex = 1.2 (see par).

...

other arguments to be passed to the graphing functions.

Details

plot4in1 creates a 2 by 2 panel using par(mfrow = c(2,2)) and then generates four residual diagnostic plots: a Percentile-Percentile (or Quantile-Quantile plot if PP = FALSE), a scatterplot of the fitted.values against the residuals, a histogram of the residuals, and scatterplot of the residuals against their order, overplotted.

Value

None

See Also

influence.measures for more information about standardized (rstandard) and studentized (rstudent) residuals; qqnorm for more information about the Quantile-Quanitle (Q-Q) plot; par for information about the graphical parameters.

Examples

1
2
out <- lm(Girth ~ Volume, data = trees)
plot4in1(out)

douglaswhitaker/MVQuickGraphs documentation built on Aug. 26, 2020, 11:51 p.m.