[R] kstest vs shapirotest

Greg Snow Greg.Snow at imail.org
Wed Sep 22 19:02:25 CEST 2010


The way that you called ks.test below your null hypothesis is that your data comes from a normal distribution with mean 0 and standard deviation 1.  Now I am not familiar with your data, but I would be very surprised in general to find a population of trees where half of them had negative heights so it is not surprising that the ks test shows your data to not be consistent with the null of normal with mean 0, sd 1.

If you are interested in normality of populations based on samples greater than 250 then you should look into SnowsPenultimateNormalityTest() in the TeachingDemos package, note however that the documentation is likely to be more useful than the test itself.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of "Sibylle Stöckli"
> Sent: Wednesday, September 22, 2010 6:32 AM
> To: r-help at r-project.org
> Subject: [R] kstest vs shapirotest
> 
> Dear R-users
> 
> Idea:
> Analysing tree height frequency with hist(), normal distribution
> (ks.test & shapiro.test) and skewness (package e1071 - thanks a lot for
> this useful package)as an indication of possible self-thinning in an
> experimental tree stand.
> 
> Problem:
> Results from the ks.test and the shapiro.test are not comparable (see
> example of both tests). Tree height is a nice continuous variable.
> Sample size is around n= 250-350. Does anybode know about a problem in
> ks tests using a large sample size and working with subsets (e.g
> file[,])? Comparing tests with qqplots, I would appreciate shapiro, but
> I am wondering about the results from ks (test ist not very sensitive,
> D=1, p=2.2e-16 many times?
> 
> Thanks
> Sibylle
> 
> 
> > shapiro.test(Biotree[Ac,]$Height2008)
> 
> 	Shapiro-Wilk normality test
> 
> data:  Biotree[Ac, ]$Height2008
> W = 0.9908, p-value = 0.05175
> 
> > ks.test(Biotree[Ac,]$Height2008, "pnorm")
> 
> 	One-sample Kolmogorov-Smirnov test
> 
> data:  Biotree[Ac, ]$Height2008
> D = 1, p-value < 2.2e-16
> alternative hypothesis: two-sided
> 
> Warning message:
> In ks.test(Biotree[Ac, ]$Height2008, "pnorm") :
>   cannot compute correct p-values with ties
> 
> --
> 
> ______________________________________________
> 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.



More information about the R-help mailing list