Last data update: 2014.03.03

R: Wilcox Exact Test
wilcoxE.testR Documentation

Wilcox Exact Test

Description

Performs exact one sample and two sample Wilcoxon tests on vectors of data.

Usage

wilcoxE.test(x, y = NULL, mu = 0, paired = FALSE,
alternative = "two.sided", conf.level = 0.95)

Arguments

x

is a numeric vector of data values. Non-finite (i.e. infinite or missing) values will be omitted.

y

an optional numeric vector of data values

mu

a number specifying an optional parameter used to form the null hypothesis

paired

a logical indicating whether you want a paired test

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater", or "less". The initial letter only may be given.

conf.level

confidence level of the interval

Details

If only x is given, or if both x and y are given and paired="TRUE", a Wilcoxon signed rank test of the null hypothesis that the distribution of x (in the one sample case) or of x - y (in the paired two sample case) is symmetric about mu is performed.

Otherwise, if both x and y are given and paired="FALSE", a Wilcoxon rank sum test is done. In this case, the null hypothesis is that the distributions of x and y differ by a location shift of mu and the alternative is that they differ by some other location shift (and the one-sided alternative "greater" is that x is shifted to the right of y).

Value

A list with class htest containing the following components:

statistic

the value of the test statistic with a name describing it

p.value

the p-value for the test

null.value

the location parameter mu

alternative

a character string describing the alternative hypothesis

method

the type of test applied

data.name

a character string giving the names of the data

conf.int

a confidence interval for the location parameter

estimate

an estimate of the location parameter

Note

The function is rather primitive and should only be used for problems with fewer than 19 observations as the memory requirements are rather large.

Author(s)

Alan T. Arnholt

References

Gibbons, J.D. and Chakraborti, S. (1992). Nonparametric Statistical Inference. Marcel Dekker Inc., New York.

Myles Hollander & Douglas A. Wolfe (1999), Nonparametric Statistical Inference. New York: John Wiley & Sons.

See Also

wilcox.test

Examples

# Wilcoxon Signed Rank Test - Example 10.3
PH <- c(7.2,7.3,7.3,7.4)
wilcoxE.test(PH, mu=7.25, alternative="greater")
# Wilcoxon Signed Rank Test (Dependent Samples) - Example 10.5 part c.
with(data = Aggression,
wilcoxE.test(violence,noviolence,paired=TRUE,alternative="greater"))
# Wilcoxon Rank Sum Test - Example 10.7
x <- c(7.2,7.2,7.3,7.3)
y <- c(7.3,7.3,7.4,7.4)
wilcoxE.test(x,y)
rm(PH, x, y)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(PASWR)
Loading required package: e1071
Loading required package: MASS
Loading required package: lattice
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/PASWR/wilcoxE.test.Rd_%03d_medium.png", width=480, height=480)
> ### Name: wilcoxE.test
> ### Title: Wilcox Exact Test
> ### Aliases: wilcoxE.test
> ### Keywords: htest
> 
> ### ** Examples
> 
> # Wilcoxon Signed Rank Test - Example 10.3
> PH <- c(7.2,7.3,7.3,7.4)
> wilcoxE.test(PH, mu=7.25, alternative="greater")

	Wilcoxon Signed Rank Test

data:  PH
t+ = 8, p-value = 0.25
alternative hypothesis: true median is greater than 7.25
93.75 percent confidence interval:
 7.25  Inf
sample estimates:
(pseudo)median 
           7.3 

> # Wilcoxon Signed Rank Test (Dependent Samples) - Example 10.5 part c.
> with(data = Aggression,
+ wilcoxE.test(violence,noviolence,paired=TRUE,alternative="greater"))

	Wilcoxon Signed Rank Test (Dependent Samples)

data:  violence and noviolence
t+ = 118.5, p-value = 0.003265
alternative hypothesis: true median difference is greater than 0
95.20569 percent confidence interval:
   2 Inf
sample estimates:
(pseudo)median 
           4.5 

> # Wilcoxon Rank Sum Test - Example 10.7
> x <- c(7.2,7.2,7.3,7.3)
> y <- c(7.3,7.3,7.4,7.4)
> wilcoxE.test(x,y)

	Wilcoxon Rank Sum Test

data:  x and y
w = 12, p-value = 0.1714
alternative hypothesis: true median is not equal to 0
82.85714 percent confidence interval:
 -0.2  0.0
sample estimates:
difference in location 
                  -0.1 

> rm(PH, x, y)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>