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

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri, 06 Jul 2007 15:46:07 +0100 (BST)

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 06 Jul 2007 - 15:27:23 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 06 Jul 2007 - 15:36:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.