Residual-based diagnostic plots for cumulative link and general
regression models using ggplot
graphics.
# S3 method for resid
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)# S3 method for glm
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)
# S3 method for clm
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)
# S3 method for lrm
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)
# S3 method for orm
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)
# S3 method for polr
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)
# S3 method for vglm
autoplot(
object,
output = c("qq", "fitted", "covariate"),
x = NULL,
fit = NULL,
distribution = qnorm,
ncol = NULL,
alpha = 1,
xlab = NULL,
color = "#444444",
shape = 19,
size = 2,
qqpoint.color = "#444444",
qqpoint.shape = 19,
qqpoint.size = 2,
qqline.color = "#888888",
qqline.linetype = "dashed",
qqline.size = 1,
smooth = TRUE,
smooth.color = "red",
smooth.linetype = 1,
smooth.size = 1,
fill = NULL,
resp_name = NULL,
...
)
Character string specifying what to plot. Default is "qq"
which produces a quantile-quantile plots of the residuals.
A vector giving the covariate values to use for residual-by-
covariate plots (i.e., when output = "covariate"
).
The fitted model from which the residuals were extracted. (Only
required if output = "fitted"
and object
inherits from class
"resid"
.)
Function that computes the quantiles for the reference
distribution to use in the quantile-quantile plot. Default is qnorm
which is only appropriate for models using a probit link function. When
jitter.scale = "probability"
, the reference distribution is always
U(-0.5, 0.5). (Only
required if object
inherits from class "resid"
.)
Integer specifying the number of columns to use for the plot
layout (if requesting multiple plots). Default is NULL
.
A single values in the interval [0, 1] controlling the opacity
alpha of the plotted points. Only used when nsim
> 1.
Character string giving the text to use for the x-axis label in
residual-by-covariate plots. Default is NULL
.
Character string or integer specifying what color to use for the
points in the residual vs fitted value/covariate plot.
Default is "black"
.
Integer or single character specifying a symbol to be used for plotting the points in the residual vs fitted value/covariate plot.
Numeric value specifying the size to use for the points in the residual vs fitted value/covariate plot.
Character string or integer specifying what color to use for the points in the quantile-quantile plot.
Integer or single character specifying a symbol to be used for plotting the points in the quantile-quantile plot.
Numeric value specifying the size to use for the points in the quantile-quantile plot.
Character string or integer specifying what color to use for the points in the quantile-quantile plot.
Integer or character string (e.g., "dashed"
)
specifying the type of line to use in the quantile-quantile plot.
Numeric value specifying the thickness of the line in the quantile-quantile plot.
Logical indicating whether or not too add a nonparametric
smooth to certain plots. Default is TRUE
.
Character string or integer specifying what color to use for the nonparametric smooth.
Integer or character string (e.g., "dashed"
)
specifying the type of line to use for the nonparametric smooth.
Numeric value specifying the thickness of the line for the nonparametric smooth.
Character string or integer specifying the color to use to fill
the boxplots for residual-by-covariate plots when x
is of class
"factor"
. Default is NULL
which colors the boxplots according
to the factor levels.
Character string to specify the response name that will be displayed in the figure.
Additional optional arguments to be passed onto ggplot
.
A "ggplot"
object.
A "ggplot"
object.
# NOT RUN {
# Load data
data(df1)
# Fit cumulative link model
fit <- glm(y ~ x + I(x ^ 2), data = df1, family = binomial)
# Construct residual plots
p1 <- ggplot2::autoplot(fit, jitter.scale = "probability", output = "qq")
p2 <- ggplot2::autoplot(fit, output = "covariate", x = df1$x)
p3 <- ggplot2::autoplot(fit, output = "fitted")
p4 <- ggplot2::autoplot(fit, output = "fitted", nsim = 10)
# }
Run the code above in your browser using DataLab