wilcoxon: Wilcoxon Signed Rank and Mann-Whitney-Wilcoxon Rank Sum Test

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/wilcoxon.R

Description

Performs Wilcoxon signed rank test or Mann-Whitney-Wilcoxon rank sum test depending on data and logicals entered. Relies heavily on the function wilcox.test. Adds formatting and variances, and prints the z-score and p-value in addition to the test statistic and p-value.

Usage

1
2
3
## S3 method for class 'wilcoxon'
wilcoxon(y, x=NULL, alternative="two.sided", mu=0, paired=FALSE, 
        exact=NULL, correct=FALSE, conf.int=FALSE, conf.level=0.95)

Arguments

y

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

x

optional numeric vector of data values. Non-finite (missing or infinite) values will be omitted.

alternative

specifies the alternative hypothesis for the test; acceptable values are "two.sided", "greater", or "less".

mu

the value of the null hypothesis.

paired

logical indicating whether the data are paired or not. Default is FALSE. If TRUE, data must be the same length.

exact

logical value indicating whether or not an exact test should be computed.

correct

logical indicating whether or not a continuity correction should be used and displayed.

conf.int

logical indicating whether or not to calculate and display a 'confidence interval' (performs a semi-parametric test on medians, and is non-robust) and point estimate.

conf.level

confidence level for the interval.

...

only used in the generic S3 class.

Details

See above.

Value

A list with class "wilcoxon" is returned. The print method lays out the information in an easy to read format.

statistic

the value of the test statistic with a name describing it.

parameter

the parameter(s) for the exact distribution of the test statistic.

p.value

the p-value for the test (calculated for the test statistic).

null.value

the parameter mu.

alternative

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 (only present if the argument conf.int=TRUE).

estimate

an estimate of the location parameter (only present if the argument conf.int=TRUE).

table

a formatted table of rank sum and number of observation values, for printing.

vars

a formatted table of variances, for printing.

hyps

a formatted table of the hypotheses, for printing.

inf

a formatted table of inference values, for printing.

Author(s)

Scott S. Emerson, M.D., Ph.D., Andrew J. Spieker, Brian D. Williamson

See Also

wilcox.test

Examples

1
2
3
4
5
6
7
8
9
#- Create the data -#
cf <- c(1153, 1132, 1165, 1460, 1162, 1493, 1358, 1453, 1185, 1824, 1793, 1930, 2075)
healthy <- c(996, 1080, 1182, 1452, 1634, 1619, 1140, 1123, 1113, 1463, 1632, 1614, 1836)

#- Perform the test -#
wilcoxon(cf, healthy, paired=TRUE)

#- Perform the test -#
wilcoxon(cf, healthy, conf.int=TRUE)

Example output

Attaching package: 'uwIntroStats'

The following object is masked from 'package:base':

    tabulate


 Wilcoxon signed rank test 
         obs sum ranks expected
positive  10        71     45.5
negative   3        20     45.5
zero       0         0      0.0
all       13        91     91.0
                            
unadjusted variance   204.75
adjustment for ties     0.00
adjustment for zeroes   0.00
adjusted variance     204.75
                    H0 Ha       
Hypothesized Median 0  two.sided
  Test Statistic p-value 
V 71             0.080322
Z 1.7821         0.037368

 Wilcoxon rank sum test 
         obs rank sum expected
Y         13      157    175.5
X         13      194    175.5
combined  26      351    351.0
                          
unadjusted variance 380.25
adjustment for ties   0.00
adjusted variance   380.25
                    H0 Ha       
Hypothesized Median 0  two.sided
  Test Statistic p-value CI          Point Estimate
W 103            0.36216 [-174, 341] 62            
Z 0.94872        0.17138                           
Warning message:
In print.wilcoxon(x) :
  The 'confidence interval' presented is semi-parametric and non-robust, and is a test of medians.

uwIntroStats documentation built on Oct. 10, 2018, 5:04 p.m.