- x
An object of class "gkwreg"
, typically the result of a
call to gkwreg
.
- which
Integer vector specifying which diagnostic plots to produce.
If a subset of the plots is required, specify a subset of the numbers 1:6.
Defaults to 1:6
. The plots correspond to:
Residuals vs. Observation Indices: Checks for time trends or patterns.
Cook's Distance Plot: Helps identify influential observations.
Generalized Leverage vs. Fitted Values: Identifies points with high leverage.
Residuals vs. Linear Predictor: Checks for non-linearity and heteroscedasticity.
Half-Normal Plot of Residuals (with simulated envelope): Assesses normality
of residuals, comparing against simulated quantiles.
Predicted vs. Observed Values: Checks overall model prediction accuracy.
- caption
Character vector providing captions (titles) for the plots.
Its length must be at least max(which)
. Defaults are provided for plots 1-6.
- sub.caption
Character string used as a common subtitle positioned above all plots
(especially when multiple plots are arranged). Defaults to the deparsed model call.
- main
An optional character string to be prepended to the individual plot captions
(from the caption
argument).
- ask
Logical. If TRUE
(and using base R graphics with multiple plots
on an interactive device), the user is prompted before displaying each plot.
Defaults to TRUE
if more plots are requested than fit on the current screen layout.
- ...
Additional arguments passed to the underlying plotting functions
(e.g., graphical parameters like col
, pch
, cex
for base R plots).
- type
Character string indicating the type of residuals to be used for plotting.
Defaults to "quantile"
. Valid options are:
"quantile"
: Randomized quantile residuals (Dunn & Smyth, 1996).
Recommended for bounded responses as they should be approximately N(0,1)
if the model is correctly specified.
"pearson"
: Pearson residuals (response residual standardized by
estimated standard deviation). Useful for checking the variance function.
"deviance"
: Deviance residuals. Related to the log-likelihood
contribution of each observation.
- family
Character string specifying the distribution family assumptions
to use when calculating residuals and other diagnostics. If NULL
(default),
the family stored within the fitted object
is used. Specifying a different
family can be useful for diagnostic comparisons. Available options match those
in gkwreg
: "gkw", "bkw", "kkw", "ekw", "mc", "kw", "beta"
.
- nsim
Integer. Number of simulations used to generate the envelope in the
half-normal plot (which = 5
). Defaults to 100. Must be positive.
- level
Numeric. The confidence level (between 0 and 1) for the simulated
envelope in the half-normal plot (which = 5
). Defaults to 0.90.
- use_ggplot
Logical. If TRUE
, plots are generated using the ggplot2
package. If FALSE
(default), base R graphics are used. Requires the
ggplot2
package to be installed if set to TRUE
.
- arrange_plots
Logical. Only relevant if use_ggplot = TRUE
and multiple
plots are requested (length(which) > 1
). If TRUE
, attempts to arrange
the generated ggplot
objects into a grid using either the gridExtra
or ggpubr
package (requires one of them to be installed). Defaults to FALSE
.
- sample_size
Integer or NULL
. If specified as an integer less than the
total number of observations (x$nobs
), a random sample of this size is
used for calculating diagnostics and plotting. This can be useful for speeding up
plots with very large datasets. Defaults to NULL
(use all observations).
- theme_fn
A function. Only relevant if use_ggplot = TRUE
. Specifies a
ggplot2
theme function to apply to the plots (e.g., theme_bw
,
theme_classic
). Defaults to ggplot2::theme_minimal
.
- save_diagnostics
Logical. If TRUE
, the function invisibly returns a list
containing the calculated diagnostic measures (residuals, leverage, Cook's distance, etc.)
instead of the model object. If FALSE
(default), the function invisibly
returns the original model object x
.