[Rd] Shapiro Test P Value Incorrect? (PR#9768)

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jul 6 16:46:07 CEST 2007


On Fri, 6 Jul 2007, Petr Savicky wrote:

> This is not a bug. The algorithm uses different approximation of the
> p-value for n=3 (exact value), 4<=n<=11 and n>=12 as seen in
>  src/library/stats/src/swilk.c
> below the line 202
> /*  Calculate significance level for W */
>
> The W statistic monotonically decreases in the presented example.

The crucial piece missing from the help page (but in the references) is 
that (at least some of) the approximations used are only claimed to be 
adequate for p < 0.1.  I've added a line to that effect.

> Petr.
>
>> Full_Name: Jason Polak
>> Version: R version 2.5.0 (2007-04-23)
>> OS: Xubuntu 7.04
>> Submission from: (NULL) (137.122.144.35)
>>
>>
>> Dear R group,
>>
>> I have noticed a strange anomaly with the shapiro.test() function. Unfortunately
>> I do not know how to calculate the shapiro test P values manually so I don't
>> know if this is an actual bug.
>>
>> So, to produce the results, run the following code:
>>
>> pvalues = 0;
>> for (i in 1:17)
>> {
>> 	j = 1:(i+3);
>> 	pvalues[i]=shapiro.test(j)$p;
>> }
>>
>> plot(pvalues);
>> print(pvalues);
>>
>> Now I just made the graph to illustrate that the p-values are strictly
>> decreasing. To me this makes intuitive sense: we are using the Shapiro test to
>> test normality of (1,2,3,4),(1,2,3,4,5), and so on. So the p-value should
>> decrease.
>>
>> These are the p-values:
>>  [1] 0.9718776 0.9671740 0.9605557 0.9492892 0.9331653 0.9135602 0.8923668
>>  [8] 0.8698419 0.8757315 0.8371814 0.7964400 0.7545289 0.7123167 0.6704457
>> [15] 0.6294307 0.5896464 0.5513749
>>
>> However, there is an increase in p-value when you go from (1,..,11) to
>> (1,..,12). Is this just a quirk of the Shapiro test, or is there an error in the
>> calculation algorithm?
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list