Monday, August 9, 2010

R::Kruskal-Wallis Test

Lamb’s-quarter is a common weed that interferes with the growth of corn. A re-
searcher planted corn at the same rate in 16 small plots of ground, then randomly
assigned the plots to four groups. He weeded the plots by hand to allow a fixed num-
ber of lamb’s-quarter plants to grow in each meter of corn row. These numbers were 0, 1, 3, and 9 in the four groups of plots. No other weeds were allowed to grow, and
all plots received identical treatment except for the weeds. Here are the yields of corn
(bushels per acre) in each of the plots:12


Weeds Corn Weeds Corn Weeds Corn Weeds Corn
per meter yield per meter yield per meter yield per meter yield

0 166.7 1 166.2 3 158.6 9 162.8
0 172.2 1 157.3 3 176.4 9 142.4
0 165.0 1 166.7 3 153.1 9 162.7
0 176.9 1 161.1 3 156.0 9 162.4

H 0 : yields have the same distribution in all groups
H a : yields are systematically higher in some groups than in others


> w<-c(166.7,172.2,165,176.9) > ww<-c(166.2,157.3,166.7,161.1) > www<-c(158.6,176.4,153.1,156) > wwww<-c(162.8,142.4,162.7,162.4) > kruskal.test(list(w,ww,www,wwww))

Kruskal-Wallis rank sum test

data: list(w, ww, www, wwww)
Kruskal-Wallis chi-squared = 5.5725, df = 3, p-value = 0.1344



This small experiment suggests that more weeds decrease yield but does not provide convincing evidence that weeds have an effect.





Example 2: Ranking of students according to different teaching books:
Gp1 Ranking(Programmed Text book): 1,2,4,6,8,9

Gp2 Ranking(Conventional Text book): 10,14,18,20,21,25,26

Gp3 Ranking(Own Printed book): 3,5,7,11,12,16,17,22

Gp4 Ranking(No written Material): 13,15,19,23,24,27

H0:All Groups have same Medians or
Summation of Ranks are same Summation R1=Summation R2=Summation R3
Ha:All Groups have different Medians or
Summation of Ranks are not same,i.e., Summation R1!=Summation R2!=Summation R3



> d<-c(1,2,4,6,8,9)
> dd<-c(10,14,18,20,21,25,26)
> ddd<-c(3,5,7,11,12,16,17,22)
> dddd<-c(13,15,19,23,24,27)
> kruskal.test(list(d,dd,ddd,dddd))

Kruskal-Wallis rank sum test

data: list(d, dd, ddd, dddd)
Kruskal-Wallis chi-squared = 14.991, df = 3, p-value = 0.001824



The tabled critical .05 and .01 chi-squared values are chisq.05= 7.81 and chisq.01=11.34. Since obtained value H=14.991 is greater than both of the critical values, the null hypothesis can be rejected at both the .05 and .01 levels. Thus one can conclude that ranking for at least two of the four groups differed significantly from one another.

No comments:

Post a Comment