geom_* and stat_* for Producing Quantile Residual Q-Q Plots with `ggplot2`geom_qqr_point.RdVarious geom_* and stat_* used within
autoplot for producing quantile residual Q-Q plots.
geom_qqr_point( mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... ) stat_qqr_range( mapping = NULL, data = NULL, geom = "qqr_range", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... ) geom_qqr_range( mapping = NULL, data = NULL, stat = "qqr_range", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ... ) stat_qqr_ref( mapping = NULL, data = NULL, geom = "qqr_ref", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, detrend = FALSE, identity = TRUE, probs = c(0.25, 0.75), trafo = qnorm, ... ) geom_qqr_ref( mapping = NULL, data = NULL, stat = "qqr_ref", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, detrend = FALSE, identity = TRUE, probs = c(0.25, 0.75), trafo = qnorm, ... ) geom_qqr_confint( mapping = NULL, data = NULL, stat = "qqr_confint", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, xlim = NULL, n = 101, detrend = FALSE, identity = TRUE, probs = c(0.25, 0.75), trafo = qnorm, style = c("polygon", "line"), ... ) GeomQqrConfint
| mapping | Set of aesthetic mappings created by |
|---|---|
| data | The data to be displayed in this layer. There are three options: If A A |
| stat | The statistical transformation to use on the data for this layer, as a string. |
| position | Position adjustment, either as a string, or the result of a call to a position adjustment function. |
| na.rm | If |
| show.legend | logical. Should this layer be included in the legends?
|
| inherit.aes | If |
| ... | Other arguments passed on to |
| geom | The geometric object to use display the data |
| detrend | Fix description. |
| identity | logical, should the identity line be plotted or a theoretical line
which passes through |
| probs | numeric vector of length two, representing probabilities of reference
line used in |
| trafo | function for calculating reference line through first and third
quartile of theoretical distribution (default: Gaussian |
| xlim | Fix description. |
| n | Fix description. |
| style | Fix description. |
An object of class GeomQqrConfint (inherits from Geom, ggproto, gg) of length 6.
if (require("ggplot2")) { ## Fit model data("CrabSatellites", package = "countreg") m1_pois <- glm(satellites ~ width + color, data = CrabSatellites, family = poisson) m2_pois <- glm(satellites ~ color, data = CrabSatellites, family = poisson) ## Compute qqrplot q1 <- qqrplot(m1_pois, plot = FALSE) q2 <- qqrplot(m2_pois, plot = FALSE) d <- c(q1, q2) ## Get label names xlab <- unique(attr(d, "xlab")) ylab <- unique(attr(d, "ylab")) main <- attr(d, "main") main <- make.names(main, unique = TRUE) d$group <- factor(d$group, labels = main) ## Polygon CI around identity line used as reference gg1 <- ggplot(data = d, aes(x, y, na.rm = TRUE)) + geom_qqr_ref() + geom_qqr_confint(fill = "red") + geom_qqr_point() + geom_qqr_range( aes( x = x_rg_lwr, ymin = y_rg_lwr, ymax = y_rg_upr, group = group ) ) + xlab(xlab) + ylab(ylab) gg1 gg1 + facet_wrap(~group) ## Polygon CI around robust reference line gg2 <- ggplot(data = d, aes(x, y, na.rm = TRUE)) + geom_qqr_ref(identity = FALSE, trafo = attr(d, "trafo")) + geom_qqr_confint(identity = FALSE, trafo = attr(d, "trafo"), style = "line") + geom_qqr_point() + geom_qqr_range( aes( x = x_rg_lwr, ymin = y_rg_lwr, ymax = y_rg_upr, group = group ) ) + xlab(xlab) + ylab(ylab) gg2 gg2 + facet_wrap(~group) ## Use different `trafo`s with confidence intervals q1 <- qqrplot(m1_pois, trafo = qunif, plot = FALSE) q2 <- qqrplot(m2_pois, plot = FALSE) gg3 <- ggplot(data = q1, aes(x, y, na.rm = TRUE)) + geom_qqr_ref() + geom_qqr_confint(fill = "red", trafo = qunif) + geom_qqr_point() gg3 gg4 <- ggplot(data = q2, aes(x, y, na.rm = TRUE)) + geom_qqr_ref() + geom_qqr_confint(fill = "red", trafo = qnorm) + geom_qqr_point() gg4 }