Kruskall-Wallis Test with R

Data Description
 

The female Cuckoo lays her eggs in other birds' nests. The "foster parents" are usually deceived, probably because of the similarity in sizes of their own eggs. 

The data file "cuckoo.txt" at http://ramanujan.math.trinity.edu/ekwessi/misc/cuckoo.txt  represents the lenghts of Cuckoo eggs (in millimeters) that were found in the nest of three species: Hedge sparrow, Robin, Wren.
 
We would like to use the Kruskal-Wallis procedure to find out if there  is any significant difference between the means lengths of Cuckoo's eggs found in the nests of these three species.
 
The motivation for doing a nonparametric procedure is  that hypotheses of One-Factor Anova are violated.
 
The response variable here is "Length" and the Factor is "Species" and the Treatments or Levels are Hedge sparrow, Robin, Wren.
 
Analysis
 
 
>install.packages("coin")   # Installling and uloading the necessary packages into the R-workspace
>install.packages("multcomp")
>require(coin)
>require(multcomp) 
>cuckoo<-read.table(file="http://ramanujan.math.trinity.edu/ekwessi/misc/cuckoo.txt",header=T)   # Loading the data set into the R-workspace
>attach(cuckoo)
>kruskal.test(Length~Species,data=cuckoo)   # Performing the Kruskal-Wallis test
 
Kruskal-Wallis rank sum test
 
data:  Length by Species
Kruskal-Wallis chi-squared = 22.3316, df = 2, p-value =1.415e-05  
 
Post-Hoc Analysis
 

>pairwise.wilcox.test(Length,Species,p.adj="bonferroni",exact=F)   # performing the pairwise comparison using the Bonferroni Method. Note that the value "bonferrono" in p.adj can be replaced with "holm" to obtain the Holm comparison Method.

Pairwise comparisons using Wilcoxon rank sum test 
 
data:  Length and Species 
 
         HedgeSparrow   Robin  
Robin 0.27892             -      
Wren  0.00039            0.00017
 
 
Interpretation of the results
 
1. The P-value (1.415e-05) shows that at least two treatments are not equal, that is, the mean length of cuckoo's eggs in the nests of at least two species differs statistically.
2. The pairwise comparison shows that mean length of cuckoo's eggs in the nest of Hedge Sparrow and Wren (P-value=0.00039) and in the nests of Robin and Wren (P-value=0.00017)  differs significantly.
3. This confirms te results of Anova, so the assumption of normality does not gravely affects the overall outcome.