! QQ Plots:
QuantileQuantile plots provide a graphical way of
comparing a sample from an unknown distribution with
a stratified sample of the same size from a hypothesized
known distribution.
Method:
The sample of unknown distribution is
sorted into increasing order. Each observation from
the unknown distribution is assumed to be from a
quantile of the distribution. Each observation is
paired with an observation from the corresponding
quantile of the known distribution. If the two
samples are in fact from the same distribution,
except for a shift and a scale factor, then the
scatter plot of pairs should appear as
approximately a straight line.
;
! Keywords: QQ plot, Scatter plot,
Distribution identification;
SETS:
OBS: X, Y, POSN;
ENDSETS DATA:
! A sample of some price change data
from an unknown distribution;
X =
6.63720 5.25590 5.30745 5.39319 7.48938
5.49371 5.50063 5.59790 5.61768 5.70234
7.53937 7.94979 8.02154 8.64716 10.0878
1.90635 3.42523 3.90875 4.05281 4.32659
4.52476 4.74702 4.75941 4.89041 5.01090
5.76529 5.83823 5.88315 5.93804 5.99352
6.02313 6.08731 6.14521 6.20736 6.25867
5.21009 6.95652 7.08109 7.22246 7.25855
6.30321 6.37623 6.40571 6.44752 6.55521
6.57048 6.77461 6.79741 6.86744 5.12348
;
ENDDATA
CALC:
@SET('TERSEO',2); ! Turn off default output;
nobs = @SIZE( OBS);
! Get the position of each observation in the sort order;
POSN = @RANK( X);
! Generate a Y(i) from the matching quantile of
a hypothesized distribution;
@FOR(OBS(i):
! Normal distribution;
Y(i) = @PNORMINV( 0, 1, POSN(i)/(nobs+1));
! Symmetric Triangular distribution;
! Y(i) = @PTRIAINV( 1, +1, 0, POSN(i)/(nobs+1));
! Exponential distribution;
! Y(i) = @PEXPOINV( 1, POSN(i)/(nobs+1));
! Cauchy distribution;
! Y(i) = @PCACYINV( 0, 1, POSN(i)/(nobs+1));
! Student t with 4 degrees of freedom;
! Y(i) = @PSTUTINV( 4, POSN(i)/(nobs+1));
);
! Generate the QQ  Scatter plot of the pairs;
@CHARTSCATTER( ' QQ Plot', 'Actual observations',
'Hypothesized distribution', 'Paired points', X, Y);
ENDCALC
