Hi! I am Mike Marin and in this video
we'll talk about how to conduct the "Mann-Whitney U" test
also known as the "Wilcoxon Rank-Sum" test using R statistical software.
The Mann-Whitney U
also known as Wilcoxon Rank-Sum test
is a nonparametric method appropriate for examining
the difference in medians for two independent populations.
This can also be thought of as a way of examining the relationship between a
numeric outcome
or Y variable and a categorical explanatory
or X variable when the groups formed by the explanatory variable
are independent. We will be working
with the Lung Capacity Data that was introduced earlier
in this series of videos. I've already gone ahead
and imported the data into R and attached it.
We will explore the relationship between Smoking and Lung Capacity.
We can use the "wilcox.test" command
to conduct this nonparametric test.
To access the Help menu in R, type "help"
and in brackets the name of the command/function you would like help for,
or simply throw a question mark (?) in front of the name of the command.
Before conducting the test
it can be useful to examine a boxplot of the data;
here we can examine the relationship between Lung Capacity
and Smoking.
Now, let's go ahead and test the null hypothesis
that 'the median Lung Capacity
of Smokers is equal to that of Non-Smokers.'
Let's also go ahead
and conduct a two-sided test. We can do this test in R programming language
using the "wilcox.test" command.
Here we would like to compare Lung Capacities for Smokers and Non-Smokers.
We can set the "mu" argument equal to 0,
to test that the difference in medians is 0.
We can use the "alt" argument to specify that we would like a two-sided alternative.
We can use the "conf.int" argument
and set this equal to TRUE to have a nonparametric
confidence interval returned to us. We can use the "conf.level" argument
to set the level of confidence we would like
for our confidence interval. We can set the "paired" argument
equal to FALSE or simply capital F,
to let R know that these groups are not paired,
that they are independent. Finally
we can set the "exact" argument equal to TRUE if you would like to have
an exact p-value computed, not an approximate one.
And we can set the "correct" argument
equal to TRUE if you would like R to use a continuity correction.
We can see the test statistic of 20128,
the p-value of 0.0055.
The 95 percent confidence interval of -1.399 up to -0.2499,
as well as the difference in medians of -0.8;
We can also see
a warning from R letting us know that the exact p-value and
an exact confidence interval cannot be calculated
when there are ties in the ranks of the observations.
As noted earlier, we can set the exact argument equal to FALSE,
If we would not like to have exact p-values and confidence intervals
calculated.
You can also note the change
in p-value and confidence interval are fairly minimal.
It's worth noting that all the arguments set
in the initial command we provided to R are the default values
except for the "conf.int" argument equal to TRUE,
R will not return a confidence interval unless we specifically asked
for this.
In the next video in this series we will discuss the paired t-test
and how to conduct this test using R.
Thanks for watching this video! Make sure to subscribe to marinstatslectures for more videos