Title: R Handbook: Two-sample Mann–Whitney U Test
Headings: Two-sample Mann–Whitney U Test
Two-sample Mann–Whitney U Test
When to use this test
Packages used in this chapter
Two-sample Mann–Whitney U test example
Summarize data treating Likert scores as factors
Bar plots of data by group
Summarize data treating Likert scores as numeric
Two-sample Mann–Whitney U test example
Effect size
Optional: Comparison among effect size statistics
References
Exercises J

Content: require (FSA)) {install.packages ("FSA")}
if (! require (lattice)) {install.packages ("lattice")}
if (! require (rcompanion)) {install.packages ("rcompanion")}
if (! require (coin)) {install.packages ("coin")}
if (! require (DescTools)) {install.packages ("DescTools")}
if (! require (effsize)) {install.packages ("effsize")}
Two-sample Mann–Whitney U test example
This example re-visits the Pooh and Piglet data from the Descriptive Statistics with the likert Package chapter. It answers the question, “Are Pooh's scores significantly different from those of Piglet?” The Mann–Whitney U test is conducted with the wilcox.test function, which produces a p -value for the hypothesis. First the data are summarized and examined using bar plots for each group. Input = ("
Speaker Likert
Pooh 3
Pooh 5
Pooh 4
Pooh 4
Pooh 4
Pooh 4
Pooh 4
Pooh 4
Pooh 5
Pooh 5
Piglet 2
Piglet 4
Piglet 2
Piglet 2
Piglet 1
Piglet 2
Piglet 3
Piglet 2
Piglet 2
Piglet 3
")
Data = read.table (textConnection (Input),header=TRUE)
### Create a new variable which is the Likert scores as an ordered factor
Data$Likert.f = factor (Data$Likert,
ordered = TRUE)
### Check the data frame
library (psych)
headTail (Data)
str (Data)
summary (Data)
### Remove unnecessary objects
rm (Input)
Summarize data treating Likert scores as factors
Note that the variable we want to count is Likert.f , which is a factor variable.