[R] shapiro.test()

peter dalgaard pdalgd at gmail.com
Tue Jun 26 20:22:59 CEST 2012


On Jun 26, 2012, at 16:43 , reso at uni-potsdam.de wrote:

> Hey,
> today I wanted to use the shapiro.test() on data containing 3 numerical values per group.
> It is the first time that an NA was given back for some of the groups.
> In the follwing an example of code and output is shown:
> 
> 
>> shapiro.test(c(0.000637806, 0.00175561, 0.001196708))
> 
> 	Shapiro-Wilk normality test
> 
> data:  c(0.000637806, 0.00175561, 0.001196708)
> W = 1, p-value = NA
> 
> I am not able to find the bug in our data, so I think there might be a problem with the shapiro.test().

The clue is that

> diff(sort(c(0.000637806, 0.00175561, 0.001196708)))
[1] 0.000558902 0.000558902

which is either an extreme coincidence or a sign that your data are not independent samples from a continuous distribution. Since the normal quantiles are also equidistant, you get a correlation of W=1 in the QQ-plot, and apparently this triggers the NA p-value. 

I suppose returning p=1.0 would arguably be a better choice for this case, but it _is_ pretty extreme. 

-pd

> 
> I use the following technical background:
> 
> platform       x86_64-pc-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status
> major          2
> minor          14.1
> year           2011
> month          12
> day            22
> svn rev        57956
> language       R
> version.string R version 2.14.1 (2011-12-22)
> 
> 
> Thanks,
> Judith
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list