Method · Statistics Library

Q-Q plot

A Q-Q plot sorts a column's values and plots each one against the value a chosen distribution (normal, exponential or uniform) would put in the same position, so points close to a straight line mean the values have that distribution's shape, and the way they bend shows how they differ.

Topic indexA reference reading outside the guided chapter sequence

Understand the idea

Line your values up from smallest to largest. Then ask: if they came from a normal distribution, where would the smallest one be expected to sit, the second smallest, and so on? The Q-Q plot places each real value against that expected position. When the shapes match, the points lie close to a straight line. The line's height and tilt only reflect the center and the spread, which do not matter here.

How to read the bends. A curve that lifts at the right end (a 'smile') means a long upper tail, right skew; the opposite curve is left skew. Both ends bending away from the line in opposite directions (the low end below it, the high end above it) means more extreme values than a normal curve gives (heavy tails); both ends bending toward the middle means fewer. Flat steps are repeated, rounded values, not a shape problem.

Small samples wobble. With 15 or 20 values the points wander off the line even when the values really come from a normal distribution, so a slight wiggle in a small sample says little. The optional 95% band shows how far a point usually strays at its position; it is set one point at a time, so about 1 point in 20 falls outside it by chance. In a large sample the opposite happens: the band is narrow, and a bend can be real yet too small to matter for what you plan. Judge whether a departure is big enough to matter, not whether one exists.

The reference line goes through the first and third quartiles, so the middle half of the data sets it. Choose exponential to check waiting times or lifetimes, and uniform for values that should be spread evenly.

Practitioner explanation

Plotting positions are R's ppoints(n), (i − a)/(n + 1 − 2a) with a = 3/8 for n ≤ 10 and 1/2 otherwise, as qqnorm uses; the theoretical quantiles are the standard distribution's quantile function at those positions (standard normal, exponential with rate 1, uniform on 0 to 1), so the reference line carries location and scale. The line is R's qqline: through the type-7 quartiles of the data and of the distribution; for the normal its slope is IQR/1.349, a robust SD, and its intercept a robust center. The optional band is car::qqPlot's pointwise envelope around that line, ± 1.96 (slope/f(z)) √(p(1 − p)/n), with f the density at the theoretical quantile: narrow in the middle, wide in the tails, and pointwise, so about 5% of points fall outside it even when the distribution is right.

The Q-Q correlation (sorted values against theoretical quantiles) summarizes straightness; it is close kin to the Shapiro-Francia statistic but is not tested here. Group draws one series, line and band per group. Above 5,000 values per series the chart draws 5,000 evenly spaced order statistics; every number uses all values. A mixture of groups bends the plot as well: on penguin flipper length (342 values, two clusters of species) 174 of 342 points fall outside the band. For a test, use the Normality Test; for model assumptions, plot the residuals, not the raw response.

When to use it

Consider it when

You want to see whether a numeric column has a normal (or exponential, or uniform) shape, and if not, how it differs: skew, heavy or light tails, rounding, or a mixture of groups.

Use caution when

You need a yes or no answer with a p-value (use the Normality Test), the assumption you are checking is about a model's residuals rather than the raw column, or the column is a category.

Formulas and symbols

Plotting positions (R's ppoints)

pi=i−an+1−2a,a={3/8n≤101/2n>10,zi=F−1(pi)p_i = \dfrac{i - a}{n + 1 - 2a}, \quad a = \begin{cases} 3/8 & n \le 10 \\ 1/2 & n > 10 \end{cases}, \qquad z_i = F^{-1}(p_i)

i the rank of the value from smallest to largest, n the number of values, F the chosen distribution (normal, exponential or uniform).

Reference line slope (R's qqline)

b=Q3−Q1F−1(0.75)−F−1(0.25),a=Q1−b F−1(0.25)b = \dfrac{Q_3 - Q_1}{F^{-1}(0.75) - F^{-1}(0.25)}, \qquad a = Q_1 - b\,F^{-1}(0.25)

Q1 and Q3 the first and third quartiles of the data (type 7); for the normal, b = IQR/1.349.

Pointwise 95% band (car::qqPlot)

a+b zi±1.96 bf(zi)pi(1−pi)na + b\,z_i \pm 1.96\,\dfrac{b}{f(z_i)}\sqrt{\dfrac{p_i(1 - p_i)}{n}}

f the density of the chosen distribution at z_i; the band is set one position at a time.

Alternatives

  • Normality Test (Battery) (Normality Test (Battery)). A formal test is wanted; it reports Shapiro-Wilk and related tests and draws a Q-Q plot too.
  • Histogram (Histogram) or Density Plot (Density Plot). You want the overall shape, such as one peak or two, rather than the detail of the tails.

Worked example

Scenario

Q-Q plots of Ozone in the airquality sample (116 values; 37 blank rows left out), against the normal and then the exponential distribution.

Result

Normal: the upper end bends above the line (a longer upper tail, right skew), Q-Q correlation 0.9373, line intercept 40.625 and slope 33.544. Exponential: the points stay close to the line, Q-Q correlation 0.9887.

Interpretation

Ozone has a long upper tail: its shape is much closer to an exponential than to a normal one, so a method that assumes normal values needs care here (a log scale, or a rank-based method).

Dataset: airquality.csv

Common misconceptions

Misconception

My Q-Q plot of 15 values wiggles around the line, so the values cannot be normal.

Correction

Small samples wobble a lot even when they come from a normal distribution. Look for a clear, systematic bend rather than a wiggle, and use the 95% band as a guide.

Misconception

Every point is inside the band, so the distribution is exactly normal.

Correction

Inside the band means the values are consistent with the distribution, not that it is exactly right. In a small sample the band is wide enough to hide real departures.

Misconception

Before a t-test or a regression, the raw column must give a straight Q-Q plot.

Correction

Regression and ANOVA assume normal residuals, not a normal raw column, and with large samples the t-test relies on the sample mean being close to normal, which it usually is. Plot what the assumption is about, and judge whether a departure is large enough to matter.

Read more: Misconception: the normality assumption applies to the raw data, not the residuals

References

  1. NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.3.24 Quantile-Quantile Plot, NIST/SEMATECH (2012), §1.3.3.24.
  2. NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.3.21 Normal Probability Plot, NIST/SEMATECH (2012), §1.3.3.21.