[banner]

An R Companion for the Handbook of Biological Statistics

Salvatore S. Mangiafico

Wilcoxon Signed-rank Test

Examples in Summary and Analysis of Extension Program Evaluation


SAEEPER: Two-sample Paired Rank-sum Test

SAEEPER: Sign Test for Two-sample Paired Data

 

Packages used in this chapter

The following commands will install these packages if they are not already installed:


if(!require(BSDA)){install.packages("BSDA")}

 

When to use it

The poplar example is shown below in the “How to do the test” section.

 

Null hypothesis

How it works

Examples

Graphing the results

See the Handbook for information on these topics.

 

Similar tests

Paired t-test and permutation test are described in the Paired t–test chapter.  The sign test is described below.

 

How to do the test

Wilcoxon signed-rank test example

 

### --------------------------------------------------------------
### Wilcoxon signed-rank test, poplar example, p. 189
### --------------------------------------------------------------

Input = ("
 Clone          August  November
 Balsam_Spire    8.1    11.2
 Beaupre        10.0    16.3
 Hazendans      16.5    15.3
 Hoogvorst      13.6    15.6
 Raspalje        9.5    10.5
 Unal            8.3    15.5
 Columbia_River  18.3   12.7
 Fritzi_Pauley   13.3   11.1
 Trichobel        7.9   19.9
 Gaver            8.1   20.4
 Gibecq           8.9   14.2
 Primo           12.6   12.7
 Wolterson       13.4   36.8
")

Data = read.table(textConnection(Input),header=TRUE)

wilcox.test(Data$August,
            Data$November,
            paired=TRUE)

 

Wilcoxon signed rank test

 

V = 16, p-value = 0.03979

 

   ### Matches “Signed Rank” p-value in SAS output

 

 

Simple 1-to-1 plot of values

 

plot(Data$August, Data$November,
     pch = 16,
     xlab="August",
     ylab="November")

abline(0,1, col="blue", lwd=2)

 

 

RPlot

 

Plot of paired samples from a Wilcoxon signed-rank test.  Circles above and to the left of the blue one-to-one line indicate observations with a higher value for November than for August.

 

#     #     #

 

 

Sign test example

The following is an example of the two-sample dependent-samples sign test.  The data are arranged as a data frame in which each row contains the values for both measurements being compared for each experimental unit.  This is sometimes called “wide format” data.  The SIGN.test function in the BSDA package is used.  The option md=0 indicates that the expected difference in the medians is 0 (null hypothesis).  This function can also perform a one-sample sign test.

 

### --------------------------------------------------------------
### Two-sample sign test, poplar example, p. 189
### --------------------------------------------------------------

Input = ("
 Clone          August  November
 Balsam_Spire    8.1    11.2
 Beaupre        10.0    16.3
 Hazendans      16.5    15.3
 Hoogvorst      13.6    15.6
 Raspalje        9.5    10.5
 Unal            8.3    15.5
 Columbia_River  18.3   12.7
 Fritzi_Pauley   13.3   11.1
 Trichobel        7.9   19.9
 Gaver            8.1   20.4
 Gibecq           8.9   14.2
 Primo           12.6   12.7
 Wolterson       13.4   36.8
")

Data = read.table(textConnection(Input),header=TRUE)


library(BSDA)

SIGN.test(x = Data$ August,
          y = Data$ November,
          md = 0,                
          alternative = "two.sided",
          conf.level = 0.95)

 

Dependent-samples Sign-Test

 

S = 3, p-value = 0.09229

 

   ### Matches “Sign” p-value in SAS output

 

#     #     #