ggDiagnose.lm: Diagnostic plot for lm and glm objects (ggplot based)

Description Usage Arguments Details Value See Also Examples

View source: R/lm.R

Description

This function leverages code from the plot.lm function from the stats library. It allows for the same imput (except when related directly to 'par' functionality, which makes no sense to include). We also include "newer" functionality.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ggDiagnose.lm(x, which = c(1L:3L, 5L),
  caption = list("Residuals vs Fitted", "Normal Q-Q", "Scale-Location",
  "Cook's distance", "Residuals vs Leverage",
  expression("Cook's dist vs Leverage  " * h[ii]/(1 - h[ii]))),
  sub.caption = NULL, main = NULL, ..., id.n = 3,
  labels.id = factor(names(stats::residuals(x)), levels =
  names(stats::residuals(x))), qqline = TRUE, cook.levels = c(0.5, 1),
  show.plot = TRUE, return = FALSE, shape = 1, nrow = min(2,
  length(which)), smooth.color = "blue", dashed.color = c("red",
  "blue", NA, NA, "red", "black"))

Arguments

x

lm or glm object

which

which plots you'd like to create

caption

title per plot

sub.caption

caption for bottom of multiple plot visual (defaults to the formula of the model.)

main

title for the mulitple plot visual

...

extra attributes (currently not used)

id.n

id the n observations with largest residuals

labels.id

labels for all observations

qqline

logic for whether a qqline should be drawn (a line between the 25 and 75 quantiles in the Q-Q plot)

cook.levels

levels of cooks distance to visualize in the leverage vs standardized residual graphic

show.plot

logic to display the graphics (group of graphics in this case)

return

logic to return list of graphics and the data frame to make the majority of graphics

shape

shape of points (the default is 1, an open circle)

nrow

number of rows in the displayed graphic

smooth.color

color for smoothing lines

dashed.color

color for dashed line (a vector of length 6 is expected)

Details

This function can deal with lm and glm objects.

Value

depending on show.plot and return it will return the visualization of the graphics and/or a list of both the data frame used the make the majority of the graphic and a list of each individual graphic.

See Also

see dfCompile.lm for data creation.

Examples

1
2
3
4
5
6
lm.object <- lm(Sepal.Length ~., data = iris)

par(mfrow = c(2,3))
plot(lm.object, which = 1:6)

ggDiagnose.lm(lm.object, which = 1:6)

benjaminleroy/ggDiagnose documentation built on May 4, 2019, 3:07 a.m.