wormplot {topmodels} | R Documentation |
Visualize goodness of fit of regression models by Worm plots using quantile residuals.
wormplot(object, ...) ## Default S3 method: wormplot(object, newdata = NULL, plot = TRUE, flavor = NULL, trafo = qnorm, nsim = 1L, delta = NULL, confint = TRUE, confint_level = 0.95, confint_nsim = 250, confint_seed = 1, single_graph = FALSE, xlab = "Theoretical quantiles", ylab = "Deviation", main = NULL, ...)
object |
an object (for which a |
newdata |
optionally, a data frame in which to look for variables with which to predict. If omitted, the original observations are used. |
plot |
logical. Should the |
flavor |
Should the rootogram be a |
trafo |
function for tranforming residuals from probability scale to a different distribution scale (default: Gaussian). |
nsim, delta |
arguments passed to |
confint |
logical or quantile specification. Should the range of
quantiles of the randomized quantile residuals be visualized? If |
confint_level |
numeric. The confidence level required. |
confint_nsim |
numeric. The number of simulated quantiles. |
confint_seed |
numeric. The seed to be set for calculating the confidence interval. |
single_graph |
logical. Should all computed extended reliability diagrams be plotted in a single graph? |
xlab, ylab, main, ... |
graphical plotting parameters
passed to |
FIXME: Q-Q residual draw quantile residuals (by default: transformed to standard
normal scale) against theoretical quantiles from the same distribution.
Alternatively, transformations to other distributions can also be used, specifically
using no transformation at all, i.e., remaining on the uniform scale
(via trafo = NULL
or equivalently qunif
or identity
).
Additional options are offered for models with discrete responses where randomization of quantiles is needed.
An list is returned invisibly with:
normal |
the theoretical normal quantiles, |
residuals |
the empirical quantile residuals. |
FIXME: Dunn KP, Smyth GK (1996). “Randomized Quantile Residuals.” Journal of Computational and Graphical Statistics, 5, 1–10.
data("CrabSatellites", package = "countreg") CrabSatellites2 <- CrabSatellites[CrabSatellites$satellites <= 1, ] m1 <- glm(satellites ~ width + color, data = CrabSatellites, family = poisson) m2 <- glm(satellites ~ width + color, data = CrabSatellites2, family = binomial) m3 <- lm(dist ~ speed, data = cars) w1 <- wormplot(m1, nsim = 100, confint = TRUE) w2 <- wormplot(m2, nsim = 100, confint = TRUE, plot = FALSE) w3 <- wormplot(m3, nsim = 100, confint = TRUE, plot = FALSE) plot(c(w1, w2), single_graph = FALSE, fill = c(1, 3), ref = c(2, 2)) points(w3, col = "lightblue")