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

After I originally commented I seem to have clicked the -Notify me when new comments are added- checkbox and from

now on each time a comment is added I receive four

emails with the same comment. There has to be an easy method

you can remove me from that service? Kudos!

LikeLike

I will see if I can remove you from the comment que. Hopefully that will solve the problem. I hope you have found my blog useful.

LikeLike