Skip to contents

Calculates one-step-ahead (OSA) residuals for the Dirichlet-multinomial tag recapture likelihood using compResidual::resDirM().

Usage

plot_tags_residuals(
  fit = NULL,
  obj = NULL,
  include_not_recaptured = FALSE,
  seed = 123L,
  data = NULL,
  ...
)

Arguments

fit

An sbt_fit object.

obj

Legacy RTMB objective used only with a legacy data-list input.

include_not_recaptured

Logical. If true, retain the constrained not-recaptured category in the attached data. Its residual is NA because compResidual::resDirM() omits the final category, so it is excluded from both the plotted points and finite-residual summary.

seed

Integer seed for the randomized quantile residuals, or NULL to use the current random-number stream. The default makes repeated diagnostics reproducible without changing the caller's random state.

data

Legacy named alias for a model data list; supply obj as well.

...

Additional arguments passed to compResidual::resDirM().

Value

A ggplot2 object. The residual data used by the function is attached as the "residual_data" attribute; finite plotting data, the SDNR/MAR summary, and the residual source are attached as "plot_data", "residual_summary", and "residual_source".

Details

compResidual is an optional dependency because it is not needed for model fitting or other standard diagnostics. This function stops with an installation message when it is unavailable. The upstream package requires an external OSA distribution header when installed from source; the sbt README gives the reproducible installation command using tools/prepare-comp-residual.sh.

Examples

if (FALSE) { # \dontrun{
fit <- sbt_example_fit()
plot_tags_residuals(fit)
} # }