Easy ggplot Q-Q plot
This function creates a qq-plot with a confidence interval.
ggqq(x, distribution = "norm", ..., ci = TRUE, line.estimate = NULL, conf.level = 0.95, sampleSizeOverride = NULL, xlab = "Theoretical quantiles", ylab = "Observed quantiles", theme = theme_bw())
- A vector containing the values to plot.
The distribution to (a 'd' and 'q' are prepended, and the resulting functions are used, e.g.
qnormfor the normal curve).
Any additional arguments are passed to the quantile function (e.g.
qnorm). Because of these dots, any following arguments must be named explicitly.
- Whether to show the confidence interval.
- Whether to show the line showing the match with the specified distribution (e.g. the normal distribution).
- THe confidence of the confidence leven arround the estimate for the specified distribtion.
It can be desirable to get the confidence intervals for a different sample size (when the sample size is very large, for example, such as when this plot is generated by the function
normalityAssessment). That different sample size can be specified here.
- The label for the X axis.
- The label for the Y axis.
- The theme to use.
This is strongly based on the answer by user Floo0 to a Stack Overflow question at Stack Exchange (see http://stackoverflow.com/questions/4357031/qqnorm-and-qqline-in-ggplot2/27191036#27191036), also posted at GitHub (see https://gist.github.com/rentrop/d39a8406ad8af2a1066c). That code is in turn based on the
qqPlot function from the
ggplotplot is returned.