resid_auxpanel: Panel of Diagnostic Residual Plots.

Description Usage Arguments Details Value Examples

View source: R/resid_auxpanel.R

Description

Creates a panel of residual diagnostic plots given inputs of residuals and fitted values.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
resid_auxpanel(
  residuals,
  predicted,
  plots = "default",
  bins = 30,
  smoother = FALSE,
  qqline = TRUE,
  qqbands = FALSE,
  scale = 1,
  theme = "bw",
  axis.text.size = 10,
  title.text.size = 12,
  title.opt = TRUE,
  nrow = NULL
)

Arguments

residuals

The residuals from the model.

predicted

The fitted values from the model.

plots

Plots chosen to include in the panel of plots. The default panel includes a residual plot, a normal quantile plot, an index plot, and a histogram of the residuals. (See details for the options available.)

bins

Number of bins for histogram of the residuals. Default is set to 30.

smoother

Indicates whether or not to include a smoother on the residual plot and/or index plot. Specify TRUE or FALSE. Default is set to FALSE.

qqline

Indicates whether to include a 1-1 line on the qq-plot. Specify TRUE or FALSE. Default is set to TRUE.

qqbands

Indicates whether to include confidence bands on the qq-plot. Specify TRUE or FALSE. Default is set to FALSE.

scale

Scales the size of the graphs in a panel. Takes values in (0,1].

theme

ggplot2 theme to be used. Options are "bw", "classic", and "grey" (or "gray"). Default is "bw".

axis.text.size

Specifies the size of the text for the axis labels of all plots.

title.text.size

Specifies the size of the text for the titles of all plots.

title.opt

Indicates whether or not to include a title on the plots. Specify TRUE or FALSE. Default is set to TRUE.

nrow

Sets the number of rows in the panel.

Details

The following grid options can be chosen for the plots argument.

Details on the creation of the plots can be found in the details section of the help file for resid_panel.

Value

A panel of residual diagnostic plots containing plots specified.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Fit a regression tree to the penguins data
penguin_tree <- rpart::rpart(heartrate ~ depth + duration, data = penguins)

# Obtain the predictions from the model on the observed data
penguin_tree_pred <- predict(penguin_tree)

# Obtain the residuals from the model
penguin_tree_resid <- penguins$heartrate - penguin_tree_pred

# Create a panel with the residual and index plot
resid_auxpanel(residuals = penguin_tree_resid,
             predicted = penguin_tree_pred,
             plots = c("resid", "index", "yvp"))

goodekat/ggResidpanel documentation built on Jan. 4, 2022, 5:35 a.m.