How to do it...

We will work with nonparametric ANOVA using the same dataset that we used in Chapter 2Univariate and Multivariate Tests for Equality of Means, (Calculating ANOVA sum of squares and F tests). The dataset will contain weight measurements for animals, and these will depend on which food type they were fed on and which lot the animals were assigned to. 

  1. First, we load the necessary libraries, as in the following example:
library(FSA)
library(dplyr)
  1. This dataset contains a food type variable and a numeric variable (Result). Because Kruskal-Wallis only accepts one-way ANOVA, we can only use one of the variables. We will need to disregard the blocking factor (LOT) and model just the food type. As we can see, we reject the null hypothesis that all of the food types yield the same result. This is shown in the following example:
t = read.csv("./anova__lot_type.csv") 
kruskal.test(Result ~ Food.Type,data=t)

The preceding command displays the following output:

  1. After we have rejected the null hypothesis, we need to find which are the statistically significative comparisons. This is a multiple comparison problem, and the p-values need to be adjusted (for the same reasons we have stated in the ANOVA chapter). This can be done via Dunn's test. As it can be verified below all of the comparisons are statistically significative and A-C is actually the largest one. The most relevant difference is A - C, as shown in the following code:
dunnTest(Result ~ Food.Type,data=t)

The preceding command displays the following output:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.127.253