Residual-based diagnostic plots for cumulative link and general regression
models using tinyplot::tinyplot() graphics.
Usage
# S3 method for class 'resid'
plot(
x,
y = NULL,
what = c("qq", "fitted", "covariate"),
covariate = NULL,
fit = NULL,
distribution = NULL,
ncol = NULL,
alpha = 1,
xlab = NULL,
ylab = NULL,
main = NULL,
smooth = TRUE,
...
)
# S3 method for class 'clm'
plot(
x,
y = NULL,
what = c("qq", "fitted", "covariate"),
covariate = NULL,
fit = NULL,
distribution = NULL,
ncol = NULL,
alpha = 1,
xlab = NULL,
ylab = NULL,
main = NULL,
smooth = TRUE,
...
)
# S3 method for class 'lrm'
plot(
x,
y = NULL,
what = c("qq", "fitted", "covariate"),
covariate = NULL,
fit = NULL,
distribution = NULL,
ncol = NULL,
alpha = 1,
xlab = NULL,
ylab = NULL,
main = NULL,
smooth = TRUE,
...
)
# S3 method for class 'orm'
plot(
x,
y = NULL,
what = c("qq", "fitted", "covariate"),
covariate = NULL,
fit = NULL,
distribution = NULL,
ncol = NULL,
alpha = 1,
xlab = NULL,
ylab = NULL,
main = NULL,
smooth = TRUE,
...
)
# S3 method for class 'polr'
plot(
x,
y = NULL,
what = c("qq", "fitted", "covariate"),
covariate = NULL,
fit = NULL,
distribution = NULL,
ncol = NULL,
alpha = 1,
xlab = NULL,
ylab = NULL,
main = NULL,
smooth = TRUE,
...
)
# S3 method for class 'vglm'
plot(
x,
y = NULL,
what = c("qq", "fitted", "covariate"),
covariate = NULL,
fit = NULL,
distribution = NULL,
ncol = NULL,
alpha = 1,
xlab = NULL,
ylab = NULL,
main = NULL,
smooth = TRUE,
...
)Arguments
- x
An object of class
"resid"(returned byresids()), or a fitted model object of classordinal::clm(),rms::lrm(),rms::orm(),MASS::polr(), orVGAM::vglm(). Forstats::glm()fits, useplot(resids(fit), fit = fit).- y
Ignored.
- what
Character string specifying what to plot. Default is
"qq"which produces a quantile-quantile plot of the residuals.- covariate
A vector giving the covariate values to use for residual-by- covariate plots (i.e., when
what = "covariate").- fit
The fitted model from which the residuals were extracted. Required if
what = "fitted"andxinherits from class"resid"; when supplied, it also determines the default reference distribution for the quantile-quantile plot.- distribution
Function that computes the quantiles for the reference distribution to use in the quantile-quantile plot. Default is
NULL, which uses U(-0.5, 0.5) for residuals obtained by jittering on the probability scale, the distribution implied by the link function offitwhen it is supplied, andqnormotherwise.- ncol
Integer specifying the number of columns to use for the plot layout (if requesting multiple plots). Default is
NULL.- alpha
A single value in the interval
[0, 1]controlling the opacity alpha of the plotted points. Only used whennsim> 1.- xlab
Character string giving the text to use for the x-axis label. Default is
NULL.- ylab
Character string giving the text to use for the y-axis label. Default is
NULL.- main
Character string giving the plot title. Default is
NULL.- smooth
Logical indicating whether or not to add a nonparametric smooth to certain plots. Default is
TRUE.- ...
Additional optional arguments to be passed onto
tinyplot::tinyplot()(e.g.,col,pch,cex, etc.) orresids()(if calling the plot method directly on a fitted model object).
Note
For vglm (and vgam) objects, the VGAM package defines its own S4 plot
method which will override this S3 method if VGAM is loaded. In such cases,
we recommend extracting the residuals first using resids() and then plotting the
resulting resid object (e.g. plot(resids(fit), fit = fit)), which will
correctly dispatch to plot.resid().
There is no plot() method for glm objects, since it would replace the
standard diagnostic plots from stats::plot.lm(). Use
plot(resids(fit), fit = fit) instead.
