> -----Original Message-----
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of syrvn
> Sent: Tuesday, January 10, 2012 10:28 AM
> To: r-help@r-project.org
> Subject: [R] 2 sample wilcox.test != kruskal.test
> 
> Hello,
> 
> 
> I think I am right in saying that a 2 sample wilcox.test is equal to a
> 2
> sample kruskal.test and
> 
> a 2 sample t.test is equal to a 2 sample anova. This is also stated in
> the
> ?kruskal.test man page:
> 
> The Wilcoxon rank sum test (wilcox.test) as the special case for two
> samples; lm together with anova for performing one-way location
> analysis
> under normality assumptions; with Student's t test (t.test) as the
> special
> case for two samples.
> 
> 
> >From this example it seems like it doesn't but I cannot figure out
> what I am
> doing wrong.
> 
> 
> x <- c(10,11,15,8,16,12,20)
> y <- c(10,14,18,25,28,30,35)
> f <- c(rep("a",7), rep("b",7))
> d <- c(x,y)
> 
> wilcox.test(x,y)
> kruskal.test(x,y)
> kruskal.test(x~y)
> kruskal.test(f~d)
> 
> t.test(x,y)
> anova(lm(x~y))
> summary(aov(lm(x~y)))
> 
> 
> And why does kruskal.test(x~y) differ from kruskal.test(f~d)??
> 
> 

You have received answers about the kruskal.test.  But, to make a final point, 
if your purpose for these statements

> t.test(x,y)
> anova(lm(x~y))
> summary(aov(lm(x~y)))

Was to compare the t.test results with anova, you have misspecified the call to 
lm(). To get comparable results you should look at

t.test(x,y)
summary(lm(d ~ as.factor(f)))

The difference between the two is that t.test() use the Welch adjustment to the 
degrees of freedom.


Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204


______________________________________________
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