Skip to contents

Histogram of model residuals

Usage

residuals_hist_plot(
  model,
  type = NULL,
  n_bins = c("sturges", "scott", "fd"),
  ylab = NULL,
  xlab = NULL,
  title = NULL,
  subtitle = NULL,
  caption = NULL,
  seed = NULL,
  by_family = NULL,
  conditioning = NULL,
  ...,
  n_dharma = 250L
)

Arguments

model

a fitted model supported by diagnostic_support.

type

character or NULL; residual type: "deviance", "pearson", "response", "pit", "quantile", "dharma", or "surrogate" (for ocat() or multinom() GAMs). Grouped models automatically use quantile residuals when all active components are supported, otherwise all use deviance residuals with a message. Ordinary models retain deviance residuals by default. See appraise() for distributional support.

n_bins

character or numeric; either the number of bins or a string indicating how to calculate the number of bins.

ylab

character or expression; the label for the y axis. If not supplied, a suitable label will be generated.

xlab

character or expression; the label for the x axis. If not supplied, a suitable label will be generated.

title

character or expression; the title for the plot. See ggplot2::labs().

subtitle

character or expression; the subtitle for the plot. See ggplot2::labs().

caption

character or expression; the plot caption. See ggplot2::labs().

seed

integer; random seed to use for PIT, quantile, surrogate or DHARMa-style residuals.

by_family

logical or NULL; separate indexed grouped-family components into facets. The default pools quantile residuals with component colours and facets traditional residuals. TRUE and FALSE explicitly select the layout. In appraise(), observed-versus-fitted values always use component facets. Standalone observed_fitted_plot() facets by default and permits explicit pooling. Ignored for ordinary models.

conditioning

character or NULL; "conditional" holds fitted random effects fixed, "marginal" averages over new effects, and "gam_component" uses the extracted GAM. Availability and defaults depend on the model; see diagnostic_support.

...

optional arguments passed to model preparation, such as the sdmTMB field_method.

n_dharma

positive integer; number of response simulations for type = "dharma". This is separate from n_simulate, which controls traditional QQ reference calculations. Defaults to 250.

Details

Pooled grouped-family histograms use common bin edges and component-specific densities, with faint group-coloured fills and opaque stepped upper boundaries. Set by_family = TRUE for separate panels.