qqrplot {topmodels}R Documentation

Q-Q Plots for Quantile Residuals

Description

Visualize goodness of fit of regression models by Q-Q plots using quantile residuals.

Usage

qqrplot(object, ...)

## Default S3 method:
qqrplot(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 = "Quantile residuals",
  main = NULL, ...)

Arguments

object

an object (for which a qresiduals method exists).

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 plot method be called to draw the computed Q-Q plot?

flavor

Should the rootogram be a base or ggplot2 style graphic, accordingly the invisible return value is either a data.frame or a tibble. Either set flavor expicitly to "base" vs. "tidyverse", or it's chosen automatically conditional if the packages ggplot2 and dplyr or tibble are loaded.

trafo

function for tranforming residuals from probability scale to a different distribution scale (default: Gaussian).

nsim, delta

arguments passed to qresiduals.

confint

logical or quantile specification. Should the range of quantiles of the randomized quantile residuals be visualized? If TRUE, then range = c(0.01, 0.99) is used.

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 plot or points, respectively.

Details

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.

Value

An list is returned invisibly with:

normal

the theoretical normal quantiles,

residuals

the empirical quantile residuals.

References

Dunn KP, Smyth GK (1996). “Randomized Quantile Residuals.” Journal of Computational and Graphical Statistics, 5, 1–10.

See Also

qresiduals, qqnorm

Examples

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)

q1 <- qqrplot(m1, nsim = 100, confint = TRUE)
q2 <- qqrplot(m2, nsim = 100, confint = TRUE, plot = FALSE)
q3 <- qqrplot(m3, nsim = 100, confint = TRUE, plot = FALSE)

plot(c(q1, q2), single_graph = FALSE, fill = c(1, 3), ref = c(2, 2))
points(q3, col = "lightblue")

[Package topmodels version 0.1-0 Index]