Session Ready
Exercise

Nonparametric methods: The Kruskall-Wallis test (2)

The first step in conducting a Kruskal-Wallis test is ranking the entire sample. When ties occur between two or more values, these values are given the mean of the ranks for which they are tied. After ranking the data, you return the scores to their groups and sum these scores within each group. The sum of ranks for each group is denoted Ri (where i is used to denote the particular group). You also calculate the mean rank over all groups denoted by \(\bar{R}\). Lastly you detract \(\bar{R}\) from each mean group rank, square this difference and multiply it by the group sample size.

The test statistic that is calculated by the Kruskal-Wallis test has an approximate chi-squared distribution with g - 1 degrees of freedom. In R you can do such a test with the kruskal.test() function. This test again works with a formula interface that you can provide a dependent variable and an independent variable.

Instructions
100 XP
  • There is a dataframe beer_data available in your console. It contains two vectors: rating and group. Peform a Kruskall-Wallis test using the function kruskal.test() and print the output to the console.
  • Assign your conclusion to the variable conclusion. Is the null hypothesis that there is no difference in satisfaction between the different beer groups accepted or not? Assign either "rejected" or "not" to the variable conclusion.