[R] Help with the Shapiro Wilk normality test

Kurt Hornik Kurt.Hornik at ci.tuwien.ac.at
Wed Feb 23 09:58:43 CET 2000


>>>>> Kenneth Cabrera writes:

> Hello:
> I want to ask about the accuracy of the Shapiro-Wilk's test.

> I use this short program in SAS
> ____________________________________________________________________________
> data test1;
>  input x @@;
>  cards;
>  1.00 1.70 2.13 2.13 2.03 2.50 2.00 2.87 2.40 2.20 1.47 1.70 1.70 1.50 1.80
>  1.03 0.63 0.60 1.87 1.13 1.10 1.27 0.83 0.67 1.73 2.23 2.50 1.60 1.97 2.17
>  2.10 0.90 0.80 2.23 0.10 0.43 0.83 0.10 0.40 0.60 1.67 1.13 1.53 1.47 0.67
>  0.50 1.03 1.33 1.73 1.27 0.90 1.70 2.17 0.70 0.90 0.70 1.07 0.23 0.57 0.90
>  0.67 1.30 1.03 0.33 0.70 1.47 1.53 1.07 0.60 0.40 0.27 1.53 1.43 2.13 0.87
>  1.13
>  ;
> run;
> proc univariate data=test1 normal;
> run;
> _____________________________________________________________________________

> And I obtain the following result for the Shapiro-Wilk's test

>  W:Normal   0.960439  Pr<W  0.0602

> When I use the same data in R, with the following statement:

> ___________________________________________________________________________________

> test1<-c(1.00,1.70,2.13,2.13,2.03,2.50,2.00,2.87,2.40,2.20,1.47,1.70,1.70,1.50,1.80,

>  1.03,0.63,0.60,1.87,1.13,1.10,1.27,0.83,0.67,1.73,2.23,2.50,1.60,1.97,2.17,
>  2.10,0.90,0.80,2.23,0.10,0.43,0.83,0.10,0.40,0.60,1.67,1.13,1.53,1.47,0.67,
>  0.50,1.03,1.33,1.73,1.27,0.90,1.70,2.17,0.70,0.90,0.70,1.07,0.23,0.57,0.90,
>  0.67,1.30,1.03,0.33,0.70,1.47,1.53,1.07,0.60,0.40,0.27,1.53,1.43,2.13,0.87,
>  1.13)
> shapiro.test(test1)
> ____________________________________________________________________________________

> I obtain the following answer:

>        Shapiro-Wilk normality test

> data:  test1
> W = 0.9733, p-value = 0.1083

> The rest of the statistics are the same, mean, median, sd, etc.
> But I don't understand the difference in the Shapiro-Wilk's test of
> normality.

> Thank you very much for your help.

> Kenneth Cabrera
> Universidad Nacional de Colombia, Sede Medellin
> Facultad de Ciencias
> ICNE
> Instituto de Ciencias Naturales y Ecologia
> krcabrer at epm.net.co

I think I was contacted and taught about this some time ago.  If I
recall it correctly, I was told that R's version (which is based on AS
R94) is correct whereas SAS's (apparently based on AS 181) is not.

>From the apstat index:

         R94 --> calculates Shapiro-Wilk normality test and P-value for sample
            sizes 3 <= n <= 5000 .  Handles censored or uncensored data.
            Corrects AS 181, which was found to be inaccurate for n > 50.

Hope this helps.

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list