On 26/10/2014 05:37, Rolf Turner wrote:
On 26/10/14 16:40, David Doyle wrote:
Hello,
I'm trying to run kruskal test on some data but the p values seemed
way too
low. So I tried it on some similar data and still got p-value =
1.611e-09. I'm sure it is a simple mistake but I can't figure it out.
Below is my data and code. Could it be because there are some miss
data /
NAs in the data set?? If so, could some one point me towards a
solution??
Thank you for your time.
David
mydata <-read.csv("http://doylesdartden.com/R/test.csv", sep=",")
kruskal.test(mydata, AMMONIA~Well)
Kruskal-Wallis rank sum test
data: mydata
Kruskal-Wallis chi-squared = 36.3952, df = 1, p-value = 1.611e-09
Thank you for providing a clear question and an easily reproducible
example.
The problem is your syntax for the call to the kruskal.test() function.
It should be:
kruskal.test(AMMONIA ~ Well, data=mydata)
This gives a p-value of 1 (which agrees with wilcox.test); t.test()
gives a p-value of 0.7958) so harmony is restored to the universe.
IMHO there is a bit of a design flaw in kruskal.test(); it should have
thrown an error, given your syntax. The wilcox.test() function *does*
From the help page
## Default S3 method:
kruskal.test(x, g, ...)
Arguments:
x: a numeric vector of data values, or a list of numeric data
vectors.
g: a vector or factor object giving the group for the
corresponding elements of ‘x’. Ignored if ‘x’ is a list.
x was a list, hence g is ignored. The only thing you can quibble about
is if the elements of x were 'numeric data vectors': one is a factor and
it is conventional in R to coerce to the specification, as happened here.
I have added a warning if such coercion is done.
throw an error.
cheers,
Rolf Turner
--
Brian D. Ripley, rip...@stats.ox.ac.uk
Emeritus Professor of Applied Statistics, University of Oxford
1 South Parks Road, Oxford OX1 3TG, UK
______________________________________________
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.