plot.qqrplot | R Documentation |
Generic plotting functions for Q-Q residual plots for objects of class "qqrplot"
returned by link{qqrplot}
.
## S3 method for class 'qqrplot' plot( x, single_graph = FALSE, detrend = NULL, simint = NULL, confint = NULL, confint_type = c("pointwise", "simultaneous", "tail-sensitive"), confint_level = 0.95, ref = NULL, ref_identity = TRUE, ref_probs = c(0.25, 0.75), xlim = c(NA, NA), ylim = c(NA, NA), xlab = NULL, ylab = NULL, main = NULL, axes = TRUE, box = TRUE, col = "black", pch = 19, simint_col = "black", simint_alpha = 0.2, confint_col = "black", confint_lty = 2, confint_lwd = 1.25, ref_col = "black", ref_lty = 2, ref_lwd = 1.25, ... ) ## S3 method for class 'qqrplot' points( x, detrend = NULL, simint = FALSE, col = "black", pch = 19, simint_col = "black", simint_alpha = 0.2, ... ) ## S3 method for class 'qqrplot' autoplot( object, single_graph = FALSE, detrend = NULL, simint = NULL, confint = NULL, confint_type = c("pointwise", "simultaneous", "tail-sensitive"), confint_level = 0.95, ref = NULL, ref_identity = TRUE, ref_probs = c(0.25, 0.75), xlim = c(NA, NA), ylim = c(NA, NA), xlab = NULL, ylab = NULL, main = NULL, legend = FALSE, theme = NULL, alpha = NA, colour = "black", fill = NA, shape = 19, size = 2, stroke = 0.5, simint_fill = "black", simint_alpha = 0.2, confint_colour = NULL, confint_fill = NULL, confint_size = NULL, confint_linetype = NULL, confint_alpha = NULL, ref_colour = "black", ref_size = 0.5, ref_linetype = 2, ... )
x, object |
an object of class |
single_graph |
logical, defaults to |
detrend |
logical. Should the qqrplot be detrended, i.e, plotted as a
'wormplot()'? If |
simint |
logical or quantile specification. Should the simint of quantiles of the randomized quantile residuals be visualized? |
confint |
logical or character string describing the style for plotting 'c("polygon", "line")'. |
confint_type |
character. Should |
confint_level |
numeric. The confidence level required, defaults to |
ref |
logical. Should a reference line be plotted? |
ref_identity, ref_probs |
Should the identity line be plotted as reference and otherwise which probabilities should be used for defining the reference line? |
xlim, ylim, axes, box |
additional graphical
parameters for base plots, whereby |
xlab, ylab, main, ... |
graphical plotting parameters passed to
|
col, pch |
graphical parameters for the main part of the base plot. |
simint_col, simint_alpha, confint_col, confint_lty, confint_lwd, ref_col, ref_lty, ref_lwd |
Further graphical parameters for the 'confint' and 'simint' line/polygon in the base plot. |
legend |
logical. Should a legend be added in the |
theme |
name of the 'ggplot2' theme to be used. If |
colour, fill, alpha, shape, size, stroke |
graphical parameters passed to |
simint_fill, confint_colour, confint_fill, confint_size, confint_linetype, confint_alpha, ref_colour, ref_size, ref_linetype |
Further graphical parameters for the 'confint' and 'simint' line/polygon using |
Q-Q residuals plots draw quantile residuals (by default on the standard normal
scale) against theoretical quantiles from the same distribution.
Alternatively, quantile residuals can also be compared on the uniform scale
(scale = "uniform"
) using no transformation.
Q-Q residuals plots can be rendered as ggplot2
or base R graphics by
using the generics autoplot
or
plot
. points
(points.qqrplot
) can be used to add Q-Q residuals to an
existing base R graphics panel.
Dunn KP, Smyth GK (1996). “Randomized Quantile Residuals.” Journal of Computational and Graphical Statistics, 5(3), 236–244. doi: 10.2307/1390802
qqrplot
, wormplot
,
qresiduals
, qqnorm
## speed and stopping distances of cars m1_lm <- lm(dist ~ speed, data = cars) ## compute and plot qqrplot qqrplot(m1_lm) ## customize colors qqrplot(m1_lm, plot = "base", ref_col = "blue", lty = 2, pch = 20) ## add separate model if (require("crch", quietly = TRUE)) { m1_crch <- crch(dist ~ speed | speed, data = cars) points(qqrplot(m1_crch, plot = FALSE), col = 2, lty = 2, simint = 2) } #------------------------------------------------------------------------------- if (require("crch")) { ## precipitation observations and forecasts for Innsbruck data("RainIbk", package = "crch") RainIbk <- sqrt(RainIbk) RainIbk$ensmean <- apply(RainIbk[,grep('^rainfc',names(RainIbk))], 1, mean) RainIbk$enssd <- apply(RainIbk[,grep('^rainfc',names(RainIbk))], 1, sd) RainIbk <- subset(RainIbk, enssd > 0) ## linear model w/ constant variance estimation m2_lm <- lm(rain ~ ensmean, data = RainIbk) ## logistic censored model m2_crch <- crch(rain ~ ensmean | log(enssd), data = RainIbk, left = 0, dist = "logistic") ## compute qqrplots qq2_lm <- qqrplot(m2_lm, plot = FALSE) qq2_crch <- qqrplot(m2_crch, plot = FALSE) ## plot in single graph plot(c(qq2_lm, qq2_crch), col = c(1, 2), simint_col = c(1, 2), single_graph = TRUE) } #------------------------------------------------------------------------------- ## determinants for male satellites to nesting horseshoe crabs data("CrabSatellites", package = "countreg") ## linear poisson model m3_pois <- glm(satellites ~ width + color, data = CrabSatellites, family = poisson) ## compute and plot qqrplot as "ggplot2" graphic qqrplot(m3_pois, plot = "ggplot2")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.