| 1 |
Statistics-Normality |
| 2 |
|
| 3 |
INSTALLATION |
| 4 |
|
| 5 |
To install this module, run the following commands: |
| 6 |
|
| 7 |
perl Makefile.PL |
| 8 |
make |
| 9 |
make test |
| 10 |
make install |
| 11 |
|
| 12 |
NORMALITY TESTS |
| 13 |
|
| 14 |
####################### |
| 15 |
# SHAPIRO-WILK TEST # |
| 16 |
####################### |
| 17 |
|
| 18 |
The L<Shapiro-Wilk W-Statistic test|http://en.wikipedia.org/wiki/Shapiro%E2%80%93Wilk_test> |
| 19 |
[Shapiro65] is considered to be among the most objective tests of |
| 20 |
normality [Royston92] and also one of the most powerful ones for detecting |
| 21 |
non-normality [Chen71]. |
| 22 |
Its statistic is essentially the roughly best unbiased estimator |
| 23 |
of population standard deviation to the sample variance [Dagostino71]. |
| 24 |
The test is mathematically complex and most implementations use several |
| 25 |
conventional approximations (as we do here), including Blom's formula |
| 26 |
for the expected value of the order statistics [Harter61] and transformation |
| 27 |
to standard normal distribution for evaluation, especially for large |
| 28 |
samples [Royston92]. |
| 29 |
|
| 30 |
$pval = shapiro_wilk_test ([0.34, -0.2, 0.8, ...]); |
| 31 |
($pval, $w_statistic) = shapiro_wilk_test ([0.34, -0.2, 0.8, ...]); |
| 32 |
|
| 33 |
This test may not be the best if there are many repeated values in the test |
| 34 |
distribution or when the number of points in the test distribution is very |
| 35 |
large, e.g. more than 5000. |
| 36 |
The routine will L<carp|Carp> about the latter, but not the |
| 37 |
former. |
| 38 |
This particular implementation of the test also requires at |
| 39 |
least 6 data points in the sample distribution and will L<croak|Carp> |
| 40 |
otherwise. |
| 41 |
|
| 42 |
|
| 43 |
############################## |
| 44 |
# D'AGOSTINO K-SQUARE TEST # |
| 45 |
############################## |
| 46 |
|
| 47 |
The L<D'Agostino K-Squared test|http://en.wikipedia.org/wiki/D%27Agostino%27s_K-squared_test> is a good test against non-normality arising from |
| 48 |
L<kurtosis|http://en.wikipedia.org/wiki/Kurtosis> and/or |
| 49 |
L<skewness|http://en.wikipedia.org/wiki/Skewness> [Dagostino90]. |
| 50 |
|
| 51 |
$pval = dagostino_k_square_test ([0.34, -0.2, ...]); |
| 52 |
($pval, $ksq_statistic) = dagostino_k_square_test ([0.34, -0.2, ...]); |
| 53 |
|
| 54 |
The test statistic depends upon both the sample kurtosis and skewness, as |
| 55 |
well as the moments of these parameters from a normal population, as quantified |
| 56 |
by Pearson's coefficients [Pearson31]. |
| 57 |
These are transformed [Dagostino70,Anscombe83] to expressions that sum |
| 58 |
to the K-squared statistic, which is essentially chi-square-distributed |
| 59 |
with 2 degrees of |
| 60 |
freedom [Dagostino90]. |
| 61 |
The kurtosis transform, and thus the overall test, generally works best |
| 62 |
when the sample distribution has at least 20 data points [Anscombe83] and the |
| 63 |
routine will L<carp|Carp> |
| 64 |
otherwise. |
| 65 |
|
| 66 |
GENERAL IMPLEMENTATION NOTES FOR STATISTICAL TESTS |
| 67 |
|
| 68 |
(1) Use standard Horner's Rule for polynomial evaluations, see e.g. Forsythe, |
| 69 |
Malcolm, and Moler "Computer Methods for Mathematical Computations" |
| 70 |
(1977) Prentice-Hall, pp 68. |
| 71 |
|
| 72 |
(2) VAGARIES OF THE PERL Statistics::Distributions PACKAGE symmetric |
| 73 |
This package is implemented in the opposite way that one : | |
| 74 |
finds tables of the standard normal function presented in /:\ | |
| 75 |
textbooks, where F(z) = A1 is the area from -infinity to : / : \ | |
| 76 |
Z (or sometimes from 0 to Z). Instead, the Perl package :/ : \| |
| 77 |
gives f(z) = A2 as the area from Z to +infinity, i.e. / : \ |
| 78 |
in the *context of a significance test*. Note the /: : |\ |
| 79 |
following implications for this package: / : A1 | \ |
| 80 |
/ : : |A2\ |
| 81 |
f(Z) = F(-Z) F(Z) + f(Z) + 1 __/___:___:___|___\___ |
| 82 |
-Z 0 Z |
| 83 |
-1 -1 -1 |
| 84 |
udistr: Z = f [f(Z)] = f [1 - F(Z)] = f (1 - A1) |
| 85 |
|
| 86 |
and the same appears to be true for other distributions in this package, |
| 87 |
e.g. chi-square, student's T, etc. |
| 88 |
|
| 89 |
(3) Tests that should perhaps be implemented in future versions: |
| 90 |
|
| 91 |
* Anderson-Darling test |
| 92 |
* Jarque-Bera test |
| 93 |
|
| 94 |
SUPPORT AND DOCUMENTATION |
| 95 |
|
| 96 |
After installing, you can find documentation for this module with the |
| 97 |
perldoc command. |
| 98 |
|
| 99 |
perldoc Statistics::Normality |
| 100 |
|
| 101 |
You can also look for information at: |
| 102 |
|
| 103 |
RT, CPAN's request tracker |
| 104 |
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Statistics-Normality |
| 105 |
|
| 106 |
AnnoCPAN, Annotated CPAN documentation |
| 107 |
http://annocpan.org/dist/Statistics-Normality |
| 108 |
|
| 109 |
CPAN Ratings |
| 110 |
http://cpanratings.perl.org/d/Statistics-Normality |
| 111 |
|
| 112 |
Search CPAN |
| 113 |
http://search.cpan.org/dist/Statistics-Normality/ |
| 114 |
|
| 115 |
|
| 116 |
COPYRIGHT AND LICENSE |
| 117 |
|
| 118 |
Copyright (C) 2012 Mike Wendl |
| 119 |
|
| 120 |
This program is free software; you can redistribute it and/or modify it |
| 121 |
under the same terms as Perl itself. |
| 122 |
|