In order to check our statistical model it is often useful
to use a quantile plot to assess how well the model fits
the data. A quantile plot or Q-Q plot compares model quantiles
with sample quantiles.
Define order statistics to be the re-ordered data
points sorted in ascending order.
The
th order statistic is defined to be the sample p-quantile with
.
Now we have the sample quantiles we need the theoretical
quantiles of the model. We denote the theoretical quantiles
with Qi where
We can then produce a scatter plot of the theoretical quantiles against
the sample quantiles.
R-Code
y <- rnorm(200,mean=0,sd=1)
ordered_y <- sort(y)
p <- ((1:200)-0.5)/200
Q <- qnorm(p,mean=0,sd=1)
dat <- data.frame(Q=Q,y=ordered_y)
ggplot(dat, aes(x=Q, y=y)) +
geom_point() +
geom_abline()