====== QQ plots ====== A quantile-quantile plot, or QQ plot, is a visual goodness-of-fit test. It checks if two distributions $F$ (distribution we're testing against) and $F_n$ (empirical distribution) are close. This is done by plotting $F^{-1}$ on the x-axis against $F_n^{-1}$ on the y-axis. If the points are close to the line $y=x$, the two distributions are close. To plot a QQ plot: - Reorder the samples in increasing order. Denote the samples $X_i$ such that $X_i$ is the $i$th smallest sample. - Plot the points $$(F^{-1}(\frac{1}{n}),X_{(1)}), (F^{-1}(\frac{2}{n}),X_{(2)}), ... , (F^{-1}(\frac{i}{n}),X_{(i)}), ... , (F^{-1}(\frac{n-1}{n}),X_{(n-1)})$$ ($(F^{-1}(\frac{n}{n}),X_{(n)})$ is skipped because for a Gaussian cdf $F$, $F^{-1}(1) = \infty$. If $F^{-1}(1)$ is defined, the point can be included.) To plot a QQ plot in MATLAB, use the //qqplot// command. pd = makedist(distname, Name1, Value1, Name2, Value2, ...) qqplot(x, pd) distname can be any family of distributions, including Normal, Gamma, Binomial, Beta, Uniform, Poisson, etc. Parameters of the distribution can be specified with the name/value pairs. See the [[https://www.mathworks.com/help/stats/makedist.html|MATLAB help page for makedist]] for more details. x is the array of sample data. ===== Patterns of QQ plots ===== There are four recognizable patterns in QQ plots that gives information about the distribution of the sample. These plots were generated with [[kb:qq_plots_matlab|this MATLAB code]]. ==== Heavy/fat tails ==== {{kb:probstat:t3_pdf.png?400|}} {{kb:probstat:t3_heavytails.png?400|}} ==== Light/skinny tails ==== {{kb:probstat:unifm11_pdf.png?400|}} {{kb:probstat:unifm11_lighttails.png?400|}} ==== Right skewed ==== {{kb:probstat:exp1_pdf.png?400|}} {{kb:probstat:exp1_rightskewed.png?400|}} ==== Left skewed ==== {{kb:probstat:expm1_pdf.png?400|}} {{kb:probstat:expm1_leftskewed.png?400|}}