qqPoints | R Documentation |
Makes data that can be used in quantile comparison plots.
qqPoints(
x,
distribution = "norm",
line = c("quartiles", "robust", "none"),
conf = 0.95,
...
)
x |
vector of values whose quantiles will be calculated. |
distribution |
String giving the theoretical distribution
against which the quantiles of the observed data will be compared.
These need to be functions that have |
line |
String giving the nature of the line that should be drawn through the points. If "quartiles", the line is drawn connecting the 25th and 75th percentiles. If "robust" a robust linear model is used to fit the line. |
conf |
Confidence level to be used. |
... |
Other parameters to be passed down to the quantile function. |
A data frame with variables x
observed quantiles,
theo
the theoretical quantiles and lwr
and upr
the confidence bounds. The slope and intercept of the line running
through the points are returned as a
and b
as an
attribute of the data.a
x <- rchisq(100, 3)
qqdf <- qqPoints(x)
a <- attr(qqdf, "ab")[1]
b <- attr(qqdf, "ab")[2]
l <- min(qqdf$theo) * b + a
u <- max(qqdf$theo) * b + a
library(ggplot2)
ggplot(qqdf, aes(x=theo, y=x)) +
geom_ribbon(aes(ymin=lwr, ymax=upr), alpha=.15) +
geom_segment(aes(x=min(qqdf$theo), xend=max(qqdf$theo), y = l, yend=u)) +
geom_point(shape=1) +
theme_classic() +
labs(x="Theoretical Quantiles",
y="Observed Quantiles")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.