Using R for Nonparametric Statistics: The Kruskal-Wallis Test, Part Two

**A Tutorial by Douglas M. Wiig**

Before we can run the Kruskal-Wallis test we need to define which column contains the factors (independent variables) and which contains the authoritarianism scores (dependent variable). Once we define the factor column R will match the correct score to each of the 14 observations.

As set up in the study, ‘Group’ is the factor(independent variable), and ‘authscore’ is the dependent variable. Use the command:

**> Group <-factor(1,2,3)**

This designates which observation belongs to each group. To make sure the data structure has been set up correctly use the command:

**> str(kruskal)**

**‘data.frame’: 14 obs. of 2 variables:**

** $ Group : num 1 1 1 1 1 2 2 2 2 2 …**

** $ authscore: num 96 128 83 61 101 82 124 132 135 109 …**

**>**

The output of this command shows a summary of the structure of the data frame created. We can now run the Kruskal Wallis test with the command:

**> kruskal.test(authscore ~ Group, data=kruskal)**

The output will be:

**Kruskal-Wallis rank sum test**

**data: authscore by Group**

**Kruskal-Wallis chi-squared = 6.4057, df = 2, p-value = 0.04065**

>

As seen in the above output the analysis of authoritarianism score by group indicates that the probability of differences in scores among the three groups being due to chance alone is less that the .05 alpha level that was set for the study. (pobt < .05). Further post hoc analysis would be necessary to determine the exact nature of the differences among the scores of the three groups. This will be the topic of a future tutorial.

**More to come: Part Three will explore the use of multiple comparison techniques to analyze ranked means**

### Like this:

Like Loading...

Reblogged this on Political Pipeline.

LikeLike

This was a loveely blog post

LikeLike