Creates a panel of interactive residual diagnostic plots given a model. Currently accepts models of type "lm", "glm", "lmerMod", "lmerModLmerTest", "lme", and "glmerMod".

resid_interact(
  model,
  plots = "default",
  type = NA,
  bins = 30,
  smoother = FALSE,
  qqline = TRUE,
  scale = 0.9,
  theme = "bw",
  axis.text.size = 10,
  title.text.size = 12,
  title.opt = TRUE,
  nrow = NULL
)

Arguments

model

Model fit using either lm, glm, lmer, lmerTest, lme, or glmer.

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 in the help file for resid_panel for the options available.)

type

Type of residuals to use in the plot. If not specified, the default residual type for each model type is used. (See details in the help file for resid_panel for the options available.)

bins

Number of bins to use when creating a histogram of the residuals. Default is set to 30.

smoother

Indicates whether or not to include a smoother on the index, residual-leverage, location-scale, and residual plots. 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. (The option of qqbands has not been implemented in plotly, so it is not available as an option with resid_interact.)

scale

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

theme

ggplot2 theme to be used. Current 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 in the panel.

title.text.size

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

title.opt

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

nrow

Sets the number of rows in the panel.

Value

A panel of interactive residual diagnostic plots containing plots specified.

Details

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

Examples


# Fit a model to the penguin data
penguin_model <- lme4::lmer(heartrate ~ depth + duration + (1|bird), data = penguins)

# Create the default interactive panel
resid_interact(penguin_model)
#> Warning: geom_GeomFunction() has yet to be implemented in plotly.
#>   If you'd like to see this geom implemented,
#>   Please open an issue with your example code at
#>   https://github.com/ropensci/plotly/issues
# Select only the residual plot and qq-plot to be included in the panel, # set the number of rows to 2, change the theme to classic resid_interact(penguin_model, plots = c("resid", "qq"), nrow = 2, theme = "classic")