wilcox.test(x, y, alternative="two.sided", mu=0, paired=F, exact=T, correct=T)
NA
s) are allowed but ignored at calculation.
paired=TRUE
then
x
and
y
must have the same length.
Missing values (
NA
s) are allowed but ignored at calculation.
"greater"
(the location of
x
is greater than that of
y
) or
"less"
(the location of
x
is less than that of
y
)
or
"two.sided"
(the locations of
x
and
y
are different).
Only enough of the string to determine a unique match is required.
x
.
TRUE
, the Wilcoxon signed rank test is computed.
The default is the Wilcoxon rank sum test.
TRUE
the exact distribution for the test statistic is used to
compute the p-value if possible.
TRUE
a continuity correction is applied to the normal approximation
for the p-value.
class
attribute
"htest"
,
representing the result of the Wilcoxon rank sum
or Wilcoxon signed rank test:
names
attribute
"n"
(number
of meaningful observations in
x
) for
the exact Wilcoxon signed rank statistic
or
"n"
and
"m"
(number of meaningful observations in
x
and
y
,
respectively) for the exact Wilcoxon rank sum test.
This component is missing if a normal approximation is use for the test.
mu
with
names
attribute
"mu"
.
alternative
.
For the Wilcoxon rank sum test, the null hypothesis is that the
locations of the distributions of
x
and
y
differ by
mu
.
For the one-sample Wilcoxon signed rank test, the null hypothesis
is that the median of the distribution of
x
(if only
x
is supplied) is
mu
.
For the two-sample paired case, where both
x
and
y
are provided (and
paired
is
TRUE
), the null hypothesis
is that the median of the distribution of
x - y
is
mu
.
For the Wilcoxon rank sum test, the
x
and
y
vectors are
independent samples from their respective distributions,
and there is mutual independence between the two sample.
For the Wilcoxon signed rank test the values of
x
or
x - y
are
independent observations from the same symmetric distribution.
The Wilcoxon rank sum test statistic, W, is defined as
sum(rank(c(x-mu,y))[seq(along=x)])
To compute probabilities for large datasets,
a normal approximation is used for the distribution of the test statistic
when the length of
x
or
y
is greater than 49
(or when
exact=F
).
If there are ties in the vector
c(x-mu,y)
an exact p-value for the test cannot be computed.
In this case, the normal approximation given by Lehmann (1975, p. 20) is used.
The Wilcoxon signed-rank test statistic, V,
is the rank sum of those
abs(x - mu - y)
with x - mu - y > 0.
For
n = length(x)
greater than 25,
a normal approximation is used to compute the probability
(or if
exact=F
).
If there are ties in the absolute values of the differences,
x - mu - y
,
an exact probability for the test cannot be computed.
The normal approximation given by Lehmann (1975, p. 130) is used in this case.
Conover, W. J. (1980).
Practical Nonparametric Statistics, 2nd ed.
Wiley, New York.
Lehmann, E. L. (1975).
Nonparametrics: Statistical Methods Based on Ranks.
Holden and Day, San Francisco.
x <- c(8.2, 9.4, 9.6, 9.7, 10.0, 14.5, 15.2, 16.1, 17.6, 21.5) y <- c(4.2, 5.2, 5.8, 6.4, 7.0, 7.3, 10.1, 11.2, 11.3, 11.5) # A Wilcoxon rank sum test: wilcox.test(x, y) # A Wilcoxon signed rank sum test: wilcox.test(x, y, paired=T)