ggResidpanel is an R package for creating panels of diagnostic plots for a model using ggplot2 and interactive versions of the plots using plotly.

Installation

The code below shows how ggResidpanel can be installed from CRAN. If desired, the development version of ggResidpanel can be installed from GitHub.

Load the ggResidpanel package.

Learn More

Here are some resources for learning how to use ggResidpanel:

Overview and Examples

The package provides five functions that allow the user to assess diagnostic plots from a model. These functions are:

  • resid_panel: Creates a panel of diagnostic plots of the residuals from a model
  • resid_interact: Creates an interactive panel of diagnostic plots of the residuals form a model
  • resid_xpanel: Creates a panel of diagnostic plots of the predictor variables
  • resid_compare: Creates a panel of diagnostic plots from multiple models
  • resid_auxpanel: Creates a panel of diagnostic plots for model types not included in the package

Currently, ggResidpanel allows the first four functions listed above to work with models fit using the functions of lm, glm, lme (from nlme), and lmer or glmer (from lme4 or fit using lmerTest). Each of these functions is applied below to show the panel that is output from the function. The functions have multiple input options such as the formatting options of scale, theme, axis.text.size, title.text.size, and title.opt.

The penguins data used in the examples below is included in ggResidpanel.

str(penguins)
## 'data.frame':    125 obs. of  4 variables:
##  $ heartrate: num  88.8 103.4 97.4 85.3 60.6 ...
##  $ depth    : num  5 9 22 25.5 30.5 32.5 38 32 6 10.5 ...
##  $ duration : num  1.05 1.18 1.92 3.47 7.08 ...
##  $ bird     : Factor w/ 9 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...

resid_panel

This function creates a panel of residual diagnostic plots given a model. It allows the user to select a panel of plots from the options in the package or create their own panel by selecting from the plots available for this function.

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

# Create the default panel of plots
resid_panel(penguin_model)

resid_interact

This function creates interactive versions of residual diagnostic plot panels given a model. Similar to resid_panel, it allows the user to select a panel of plots from the options in the package or to create their own panel by selecting from the plots available for this function.

resid_xpanel

This function creates a panel of plots of the residuals or response variable versus the predictor (x) variables in the model.

resid_compare

This function creates a panel of residual diagnostic plots given a list of models. This allows the user to compare the diagnostic plots from multiple models.

resid_auxpanel

This function creates a panel of residual diagnostic plots given inputs of residuals and fitted values to use for models not accepted by resid_panel. Users can select from panel options in the package or create their own panel from the plots available for this function.