Residuals against fitted values with a zero reference line and a loess trend, the first plot to look at when checking a linear model.

geom_residual(
  mapping = NULL,
  data = NULL,
  color = NULL,
  smooth = TRUE,
  size = NULL,
  alpha = NULL
)

Arguments

mapping, data

Standard layer overrides. Map fitted values to x and residuals to y.

color

Point color.

smooth

Overlay a loess trend through the residuals.

size

Point radius.

alpha

Point opacity.

Value

A Layer to add with +.

Examples

m <- lm(dist ~ speed, cars)
d <- data.frame(fitted = fitted(m), resid = resid(m))
ggnext(d, aes(fitted, resid)) + geom_residual()
#> <ggnext plot>
#>   data:  50 x 2
#>   aes:   x = fitted, y = resid
#>   layers: 1 
#>   coord: cartesian
#>   mode:  static