The way you are running the test the null hypothesis is that the data comes 
from a normal distribution with mean=0 and standard deviation = 1.  If your 
minimum data value is 0, then it seems very unlikely that the mean is 0.  So 
the test is being strongly influenced by the mean and standard deviation not 
just the shape of the distribution.

Note that the KS test was not designed to test against a distribution with 
parameters estimated from the same data (you can do the test, but it makes the 
p-value inaccurate).  You can do a little better by simulating the process and 
comparing the KS statistic to the simulations rather than looking at the 
computed p-value.

However you should ask yourself why you are doing the normality tests in the 
first place.  The common reasons that people do this don't match with what the 
tests actually test (see the fortunes on normality).

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


> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Kerry
> Sent: Wednesday, November 10, 2010 9:23 PM
> To: r-help@r-project.org
> Subject: [R] Kolmogorov Smirnov Test
> 
> I'm using ks.test (mydata, dnorm) on my data. I know some of my
> different variable samples (mydata1, mydata2, etc) must be normally
> distributed but the p value is always < 2.0^-16 (the 2.0 can change
> but not the exponent).
> 
> I want to test mydata against a normal distribution. What could I be
> doing wrong?
> 
> I tried instead using rnorm to create a normal distribution: y = rnorm
> (68,mean=mydata, sd=mydata), where N= the sample size from mydata.
> Then I ran the k-s: ks.test (mydata,y). Should this work?
> 
> One issue I had was that some of my data has a minimum value of 0, but
> rnorm ran as I have it above will potentially create negative numbers.
> 
> Also some of my variables will likely be better tested against non-
> normal distributions (uniform etc.), but if I figure I should learn
> how to even use ks.test first.
> 
> I used to use SPSS but am really trying to jump into R instead, but I
> find the help to assume too heavy of statistical knowledge.
> 
> I'm guessing I have a long road before I get this, so any bits of
> information that may help me get a bit further will be appreciated!
> 
> Thanks,
> kbrownk
> 
> ______________________________________________
> R-help@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.

______________________________________________
R-help@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.

Reply via email to